"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResolveTestFailureToolDefinition = exports.resolveTestFailureResponseSchema = exports.resolveTestFailureServerPrepareResultSchema = exports.resolveTestFailureArgumentsSchema = 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");
var schemas_js_1 = require("../shared/schemas.js");
exports.resolveTestFailureArgumentsSchema = zod_1.z.object({
    decision: zod_1.z.enum(['fail', 'resume']).describe('Whether to fail the test or continue execution from the next step'),
    failure_summary: zod_1.z.string().optional().describe('Summary of why the test failed (required if decision is fail)'),
    bounding_box: schemas_js_1.boundingBoxSchema
        .optional()
        .describe('Bounding box of the element that drove your recovery. Only provide it if you already have the coordinates from a prior recovery tool call (e.g., a previous click or text entry). Do NOT make additional tool calls to obtain it.'),
    test_needs_update: zod_1.z
        .boolean()
        .optional()
        .describe("Set to true when your investigation reveals the test definition itself is stale and a downstream test-editing agent should update it: a selector now binds to the wrong element, a step references a removed/renamed control, an assertion targets text that no longer exists, etc. Judge this independently of decision \u2014 set it whether you go on to resume or to fail. In particular, set decision=fail AND test_needs_update=true when you found the test is stale but could not safely recover (e.g. a required control was removed with no valid workaround). Leave false or omitted for (a) transient flakes (timing, network, race conditions) where the test definition is correct as-is \u2014 even if such a flake forced you to fail \u2014 and (b) real application bugs where the test is correct and should keep surfacing the bug. When true, your ".concat(constants_js_1.REPAIR_NOTES_FILENAME, " is the only context the editor will receive: it must contain a URL line and a numbered list of step-level operations (\"Replace step N: ...\", \"Insert between step N and N+1: ...\", \"Delete step N\", \"Change step N parameter X from Y to Z\"), self-contained with no references to other files.")),
});
exports.resolveTestFailureServerPrepareResultSchema = zod_1.z.object({
    elementBoundingBox: schemas_js_1.boundingBoxSchema.optional(),
});
exports.resolveTestFailureResponseSchema = zod_1.z.object({
    acknowledged: zod_1.z.boolean().describe('Whether the decision was acknowledged'),
});
exports.ResolveTestFailureToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.ResolveTestFailure,
    description: "Terminal tool - make the final decision on whether this test should fail or continue execution from the next step.\n\nYou MUST write ".concat(constants_js_1.EVIDENCE_FILENAME, ", ").concat(constants_js_1.REASONING_FILENAME, ", and ").concat(constants_js_1.REPAIR_NOTES_FILENAME, " using ").concat(agentToolNames_js_1.AgentToolNames.WriteFile, " before calling this tool. The tool will reject the call if any file is missing.\n\nWhen decision is 'resume':\n- You have performed the failed step's intended action and the app is ready for the next step\n- If you already have coordinates for the element that drove your recovery, pass them as bounding_box. Do NOT call execute_javascript (or any other tool) just to obtain coordinates.\n\nWhen decision is 'fail':\n- Provide a clear failure_summary explaining why recovery is not possible"),
    argumentsSchema: exports.resolveTestFailureArgumentsSchema,
    serverPrepareResultSchema: exports.resolveTestFailureServerPrepareResultSchema,
    responseSchema: exports.resolveTestFailureResponseSchema,
});
//# sourceMappingURL=ResolveFailureDefinition.js.map