import { z } from 'zod';
import { defineTool } from '../toolDefinition.js';
import { AgentToolNames } from '../shared/agentToolNames.js';
import { testInformationSchema } from './schemas.js';
/**
 * Response schema for the save_test_information tool.
 * Returns the resolved test information with entity names for user display.
 */
export const saveTestInformationResponseSchema = z.object({
    message: z.string().meta({
        description: 'A confirmation message describing the saved test information with resolved entity names',
    }),
    test_information: testInformationSchema,
    resolved_names: z
        .object({
        application_name: z.string().optional(),
        environment_name: z.string().optional(),
        deployment_url: z.string().optional(),
        credentials_name: z.string().optional(),
        datatable_name: z.string().optional(),
        scenario_name: z.string().optional(),
        branch_name: z.string().optional(),
        plan_name: z.string().optional(),
        test_name: z.string().optional(),
    })
        .meta({
        description: 'Human-readable names for the resolved entities (deployment, credentials, branch, plan, etc.)',
    }),
});
/**
 * Extended test information schema that includes viewport dimensions, datatable
 * selection, labels, device emulation, branch, and plan.
 *
 * These fields are optional — the agent only sets them when the user's request
 * implies them. The defaults documented below are applied downstream (the
 * desktop trainer / cloud runner) when the field is omitted.
 */
export const saveTestInformationArgumentsSchema = testInformationSchema.extend({
    viewport_width: z.number().optional().meta({
        description: 'Browser viewport width in pixels. Defaults to 1080 if not specified. Only set this if the user explicitly requests a specific viewport size.',
    }),
    viewport_height: z.number().optional().meta({
        description: 'Browser viewport height in pixels. Defaults to 1440 if not specified. Only set this if the user explicitly requests a specific viewport size.',
    }),
    datatable_id: z.string().optional().meta({
        description: 'The ID of the data table to use for the test. Pick this from the workspace context only when the test is data-driven (the user wants to run the same test against multiple inputs). If the user just wants a single test scenario, leave this blank.',
    }),
    scenario_id: z.string().optional().meta({
        description: 'The ID of a specific scenario (row) within the chosen data table. Required when datatable_id is set — the test builder needs concrete variable values from a specific scenario to build with. Call get_data_table_details first to see available scenarios. Additional scenarios can be configured after generation.',
    }),
    labels: z.array(z.string()).optional().meta({
        description: 'Free-form labels to attach to the test (used for tagging / filtering, e.g. "smoke", "checkout"). Only include labels the user explicitly mentioned, or labels that strongly match the test purpose.',
    }),
});
export const SaveTestInformationToolDefinition = defineTool({
    name: AgentToolNames.SaveTestInformation,
    description: 'Lock in the test configuration: name, description, deployment (application + environment + URL), credentials, test case, ' +
        'data table, labels, viewport, device emulation, branch, and plan. This tool validates that all IDs are real and accessible, ' +
        'resolves deployment to its application/environment/URL, and persists the information for the user to review. Call this before ' +
        'presenting the test information to the user — it will fail with a clear error if any required field is missing or any ID is invalid.',
    argumentsSchema: saveTestInformationArgumentsSchema,
    responseSchema: saveTestInformationResponseSchema,
});
//# sourceMappingURL=SaveTestInfoDefinition.js.map