"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecuteEnterTextToolDefinition = exports.executeEnterTextClientResponseSchema = exports.executeEnterTextServerResultSchema = exports.executeEnterTextArgumentsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var agentToolNames_js_1 = require("./agentToolNames.js");
var constants_js_1 = require("./constants.js");
var customFind_js_1 = require("./customFind.js");
exports.executeEnterTextArgumentsSchema = zod_1.z.object({
    description: zod_1.z.string().max(100).describe('A brief description of what this step does (max 100 characters)'),
    elementDescription: zod_1.z.string().meta({
        description: constants_js_1.TOOL_ELEMENT_DESCRIPTION_INSTRUCTIONS,
    }),
    text: zod_1.z.string().meta({
        description: "The text to enter in the element. Supports {{@variableName}} syntax to reference test variables \u2014 the client resolves variables before typing. Use ".concat(agentToolNames_js_1.AgentToolNames.GetAvailableVariables, " to verify a variable exists before referencing it."),
    }),
    customFind: customFind_js_1.customFindSchema.optional(),
    reasoning: zod_1.z
        .string()
        .optional()
        .describe('Brief explanation of why this action is being taken and what it aims to achieve'),
});
exports.executeEnterTextServerResultSchema = zod_1.z.object({
    elementDescription: zod_1.z.string(),
    text: zod_1.z.string(),
    elementBoundingBox: zod_1.z
        .object({
        top: zod_1.z.number(),
        left: zod_1.z.number(),
        bottom: zod_1.z.number(),
        right: zod_1.z.number(),
    })
        .optional(),
    elementTargetPoint: zod_1.z
        .object({
        x: zod_1.z.number(),
        y: zod_1.z.number(),
    })
        .optional(),
    // Application-level enter-text preference (the `enter_text_mode` field on the
    // Application). The server passes the enum value through verbatim; the client
    // (mabl-cli) translates it into the matching descriptor shape. Absent means
    // "no preference; client uses its own default" (fill since mabl-cli #3493).
    // Per-step user overrides in the trainer UI still win — this only seeds new
    // steps.
    enterTextMode: zod_1.z.enum(['fill', 'press']).optional(),
});
/**
 * Response schema for execute_enter_text tool.
 * The client should include the new screenshot and current URL after the text entry
 * to provide context for the next agent decision without requiring a separate user prompt.
 */
exports.executeEnterTextClientResponseSchema = zod_1.z.object({
    success: zod_1.z.boolean(),
    message: zod_1.z.string().optional(),
    // Context fields - client should include these after executing the action
    new_screenshot: zod_1.z.string().optional().meta({
        description: 'Base64-encoded PNG screenshot of the page after entering text',
    }),
    current_url: zod_1.z.string().optional().meta({
        description: 'The current URL after the action (in case of form submission or navigation)',
    }),
});
exports.ExecuteEnterTextToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.ExecuteEnterText,
    description: "Enters text into an input field in the app identified by the provided description to uniquely identify it in the screenshot. Supports {{@variableName}} syntax \u2014 variables are resolved to their current values before typing. Use ".concat(agentToolNames_js_1.AgentToolNames.GetAvailableVariables, " to confirm a variable exists before referencing it. Can also be used for certain dropdown elements when click fails. The client response will include a new screenshot showing the result."),
    argumentsSchema: exports.executeEnterTextArgumentsSchema,
    serverPrepareResultSchema: exports.executeEnterTextServerResultSchema,
    responseSchema: exports.executeEnterTextClientResponseSchema,
});
//# sourceMappingURL=ExecuteEnterTextDefinition.js.map