"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetTestRunArtifactsToolDefinition = exports.getTestRunArtifactsResponseSchema = exports.getTestRunArtifactsParamsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var constants_js_1 = require("../shared/constants.js");
var agentToolNames_js_1 = require("../shared/agentToolNames.js");
/**
 * GetTestRunArtifactsDefinition - Tool definition for fetching test run artifacts.
 */
exports.getTestRunArtifactsParamsSchema = zod_1.z.object({
    test_run_id: zod_1.z.string().meta({
        description: 'Required. Test run ID to fetch artifacts from.',
    }),
    artifact_types: zod_1.z
        .array(zod_1.z.enum([
        'chrome_trace',
        'har',
        'console_log',
        'download',
        'network_log',
        'dom_snapshot',
        'full_page_screenshot',
        'variables',
        'accessibility',
        'video',
        'all',
    ]))
        .optional()
        .meta({
        description: 'Types of artifacts to fetch. Default: all. Options: chrome_trace, har, console_log, download, network_log, dom_snapshot, full_page_screenshot, variables, accessibility, video, all',
    }),
    step_index: zod_1.z.number().optional().meta({
        description: 'If specified, only return artifacts from this specific step index.',
    }),
    include_content: zod_1.z.boolean().optional().meta({
        description: 'Whether to include artifact content in the response (for text-based artifacts like console logs). Default: false. Only applies to console_log type.',
    }),
    max_artifacts: zod_1.z.number().optional().meta({
        description: 'Maximum number of artifacts to return. Default: 10. Maximum: 20.',
    }),
});
var artifactInfoSchema = zod_1.z.object({
    type: zod_1.z
        .enum([
        'chrome_trace',
        'har',
        'console_log',
        'download',
        'network_log',
        'dom_snapshot',
        'full_page_screenshot',
        'variables',
        'accessibility',
        'video',
        'other',
    ])
        .meta({ description: 'Type of artifact' }),
    name: zod_1.z.string().meta({ description: 'Name of the artifact' }),
    downloadUrl: zod_1.z.string().optional().meta({
        description: 'Reserved for optional signed download links. The server does not populate this; use artifactUri (stable gs://) in evidence and markdown.',
    }),
    artifactUri: zod_1.z
        .string()
        .optional()
        .meta({
        description: "Stable storage URI for the same object (typically gs://). Use this in ".concat(constants_js_1.EVIDENCE_FILENAME, " and analysis content so HAR/screenshot blocks stay loadable; the UI re-signs it. Prefer over downloadUrl for markdown."),
    }),
    stepIndex: zod_1.z
        .number()
        .optional()
        .meta({
        description: "Execution-order step index (0-based). This matches the step indices from ".concat(agentToolNames_js_1.AgentToolNames.GetTestRunInfo, ". For looped flows, each iteration has unique indices."),
    }),
    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.',
    }),
});
exports.getTestRunArtifactsResponseSchema = zod_1.z.object({
    artifacts: zod_1.z.array(artifactInfoSchema).meta({ description: 'List of artifacts' }),
    totalAvailable: zod_1.z.number().meta({ description: 'Total number of artifacts available' }),
    consoleLogContent: zod_1.z.string().optional().meta({ description: 'Console log content if include_content is true' }),
    note: zod_1.z.string().optional().meta({ description: 'Any notes about the response' }),
});
exports.GetTestRunArtifactsToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.GetTestRunArtifacts,
    description: "Retrieves artifacts from a test run such as chrome traces, HAR files, console logs, and downloaded files.\n\nUse this tool to:\n- Analyze network requests via HAR files\n- Review console logs for JavaScript errors or warnings\n- Examine chrome traces for performance analysis\n- Access files downloaded during the test\n- Inspect DOM snapshots or full page screenshots\n- Review variable values after step execution\n- Check accessibility scan results\n- **For API tests**: Use network_log to see request/response details, status codes, and response times\n\nArtifact types:\n- chrome_trace: Browser performance traces (browser tests only)\n- har: HTTP Archive files with network request details\n- console_log: Browser console output (browser tests only)\n- network_log: Network request/response logs (useful for both browser and API tests)\n- download: Files downloaded during the test\n- dom_snapshot: DOM state at a step (browser tests only)\n- full_page_screenshot: Full page screenshot (browser tests only)\n- variables: Variable values after step execution\n- accessibility: Accessibility check results\n- video: Video recording of test execution (browser/mobile tests)\n\nFor console logs, you can set include_content=true to get the actual log content included in the response.\n\nEach artifact includes **artifactUri** (stable, usually gs://) and **downloadUrl** (signed HTTPS, expires). For evidence files and dashboard-ready markdown (HAR blocks, screenshots), cite **artifactUri** so links remain valid; use **downloadUrl** only for one-off download.",
    argumentsSchema: exports.getTestRunArtifactsParamsSchema,
    responseSchema: exports.getTestRunArtifactsResponseSchema,
});
//# sourceMappingURL=GetTestRunArtifactsDefinition.js.map