"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubmitRuntimeRecoverySummaryVerdictToolDefinition = exports.submitRuntimeRecoverySummaryVerdictResponseSchema = exports.submitRuntimeRecoverySummaryVerdictArgumentsSchema = exports.runtimeRecoverySummaryInsightSchema = 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 recoveryVerdictStatus_js_1 = require("./recoveryVerdictStatus.js");
exports.runtimeRecoverySummaryInsightSchema = zod_1.z.object({
    category: zod_1.z
        .string()
        .describe('Short label rendered as a badge in the Insight footer. Use a noun phrase that names the failure pattern at a glance. Examples: "Selector drift", "Application defect", "Flaky environment", "Test design gap".'),
    text: zod_1.z
        .string()
        .describe('One-to-three-sentence description of what the agent learned from this test run, written for the test author. Keep it brief — long explanations belong in the reasoning file.'),
});
exports.submitRuntimeRecoverySummaryVerdictArgumentsSchema = zod_1.z.object({
    verdict: zod_1.z
        .enum(recoveryVerdictStatus_js_1.RECOVERY_VERDICT_STATUS_VALUES)
        .describe('The final verdict on whether the test run should be considered a pass or a fail after reviewing every Runtime Recovery session and auto-heal. Choose fail when any recovery changed the semantic outcome of the test.'),
    summary: zod_1.z
        .string()
        .describe('One-sentence plain-text summary of the verdict outcome — required for both pass and fail. Plain text only; markdown is rendered literally and will look broken. For fail: explain which recovery or auto-heal invalidated the test intent. For pass: confirm that all recoveries preserved it. USER-FACING TEXT — never write the acronym TRA; refer to it as "Runtime Recovery" or "the recovery".'),
    insight: exports.runtimeRecoverySummaryInsightSchema
        .optional()
        .describe('Optional structured learning surfaced in the Insight footer of the Recovery review panel. Include when there is a generalizable observation about the test, application, or environment that the test author would benefit from seeing. Omit when the test run is unremarkable.'),
});
exports.submitRuntimeRecoverySummaryVerdictResponseSchema = zod_1.z.object({
    acknowledged: zod_1.z
        .boolean()
        .describe('True when the verdict was accepted. False means the call was rejected for the reason in error and you should fix it and call again.'),
    error: zod_1.z
        .string()
        .optional()
        .describe('Present only when acknowledged is false; explains what to fix before re-calling.'),
});
exports.SubmitRuntimeRecoverySummaryVerdictToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.SubmitRuntimeRecoverySummaryVerdict,
    description: "Terminal tool - submit the final pass/fail verdict for the test run being evaluated.\n\nBefore calling this tool you MUST:\n1. Call ".concat(agentToolNames_js_1.AgentToolNames.SubmitRuntimeRecoverySummaryStepVerdict, " once for every recovered step (one call per recovered_step_indices entry).\n2. Write ").concat(constants_js_1.REASONING_FILENAME, " and ").concat(constants_js_1.REPAIR_NOTES_FILENAME, " using ").concat(agentToolNames_js_1.AgentToolNames.WriteFile, ". The tool will reject the call if either file is missing.\n\n").concat(constants_js_1.REPAIR_NOTES_FILENAME, " should contain actionable diagnostic information for the developer or next agent: wrong selectors (with text and correct target), the URL to reproduce the issue, and concrete steps to try. Write \"").concat(constants_js_1.NO_RELEVANT_TECHNICAL_DIAGNOSTIC, "\" if there is nothing actionable.\n\nUSER-FACING TEXT: `summary` and `insight.text` are rendered directly to the test author. Never write the acronym TRA in those fields \u2014 refer to it as \"Runtime Recovery\" or \"the recovery\". The acronym is internal only.\n\nYou are an impartial reviewer. Do not bias toward pass or fail. Consider each Runtime Recovery session and each auto-heal on its own merits:\n- Did the recovery preserve the semantic intent of the original step?\n- If the failed step was an assertion, does the post-recovery state still satisfy the assertion?\n- Did any auto-heal bind to an element that is actually the right target (use ").concat(agentToolNames_js_1.AgentToolNames.GetStepScreenshot, " to verify)?\n\nAlways provide a one-sentence summary regardless of verdict:\n- For '").concat(recoveryVerdictStatus_js_1.RECOVERY_VERDICT_FAIL, "': explain which recovery or auto-heal broke the test's intent.\n- For '").concat(recoveryVerdictStatus_js_1.RECOVERY_VERDICT_PASS, "': confirm that all recoveries preserved the test's semantic intent.\n\nOptionally include an insight when there's a generalizable lesson worth surfacing in the Recovery review panel footer: a recurring selector pattern that drifts, an application defect masquerading as flake, or a test design gap that lets recoveries hide failures. Skip the insight when the run is unremarkable."),
    argumentsSchema: exports.submitRuntimeRecoverySummaryVerdictArgumentsSchema,
    responseSchema: exports.submitRuntimeRecoverySummaryVerdictResponseSchema,
});
//# sourceMappingURL=SubmitRuntimeRecoverySummaryVerdictDefinition.js.map