"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetPlanRunInfoToolDefinition = exports.getPlanRunInfoResponseSchema = exports.planRunSummarySchema = exports.testCountsSchema = exports.planRunContextSchema = exports.planContextSchema = exports.environmentContextSchema = exports.applicationContextSchema = exports.getPlanRunInfoParamsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var agentToolNames_js_1 = require("../shared/agentToolNames.js");
/**
 * GetPlanRunInfoDefinition - Tool definition for fetching comprehensive plan run information.
 */
exports.getPlanRunInfoParamsSchema = zod_1.z.object({
    plan_run_id: zod_1.z.string().meta({
        description: "Required. Plan run ID to fetch info for. To compare another run, pass that run's plan_run_id from get_related_plan_runs. When analyzing deployments, use plan_run_id from get_deployment_event_plan_runs results.",
    }),
    include_test_counts: zod_1.z.boolean().optional().meta({
        description: 'Whether to include detailed test count information. Default: true',
    }),
    include_context: zod_1.z.boolean().optional().meta({
        description: 'Whether to include detailed context about application, environment, and plan configuration. Default: true',
    }),
});
// Schema for application context
exports.applicationContextSchema = zod_1.z.object({
    id: zod_1.z.string().meta({ description: 'Application ID' }),
    name: zod_1.z.string().optional().meta({ description: 'Application name' }),
});
// Schema for environment context
exports.environmentContextSchema = zod_1.z.object({
    id: zod_1.z.string().meta({ description: 'Environment ID' }),
    name: zod_1.z.string().optional().meta({ description: 'Environment name' }),
});
// Schema for plan context
exports.planContextSchema = zod_1.z.object({
    id: zod_1.z.string().meta({ description: 'Plan ID' }),
    name: zod_1.z.string().optional().meta({ description: 'Plan name' }),
});
// Schema for plan run context
exports.planRunContextSchema = zod_1.z.object({
    application: exports.applicationContextSchema.optional().meta({ description: 'Application this plan ran against' }),
    environment: exports.environmentContextSchema.optional().meta({ description: 'Environment this plan ran in' }),
    plan: exports.planContextSchema.optional().meta({ description: 'Plan configuration' }),
    triggerType: zod_1.z.string().optional().meta({ description: 'How the plan run was triggered (schedule, manual, etc.)' }),
    isAdHoc: zod_1.z.boolean().optional().meta({ description: 'Whether this was an ad-hoc run' }),
    deploymentIds: zod_1.z.array(zod_1.z.string()).optional().meta({ description: 'Associated deployment IDs' }),
});
// Schema for test counts
exports.testCountsSchema = zod_1.z.object({
    total: zod_1.z.number().meta({ description: 'Total number of tests in the plan run' }),
    passed: zod_1.z.number().meta({ description: 'Number of passed tests' }),
    failed: zod_1.z.number().meta({ description: 'Number of failed tests' }),
    skipped: zod_1.z.number().meta({ description: 'Number of skipped tests' }),
    running: zod_1.z.number().meta({ description: 'Number of currently running tests' }),
    passRate: zod_1.z.number().optional().meta({ description: 'Pass rate as a percentage (0-100)' }),
});
exports.planRunSummarySchema = zod_1.z.object({
    planRunId: zod_1.z.string().meta({ description: 'Plan run ID' }),
    planId: zod_1.z.string().optional().meta({ description: 'Plan ID' }),
    planName: zod_1.z.string().optional().meta({ description: 'Plan name' }),
    status: zod_1.z.enum(['queued', 'running', 'passed', 'failed', 'cancelled', 'terminated']).meta({
        description: 'Overall status of the plan run',
    }),
    startTime: zod_1.z.string().optional().meta({ description: 'Start time as ISO string' }),
    endTime: zod_1.z.string().optional().meta({ description: 'End time as ISO string' }),
    durationMs: zod_1.z.number().optional().meta({ description: 'Total duration in milliseconds' }),
});
exports.getPlanRunInfoResponseSchema = zod_1.z.object({
    summary: exports.planRunSummarySchema.meta({ description: 'Summary information about the plan run' }),
    context: exports.planRunContextSchema.optional().meta({ description: 'Contextual information about the plan run' }),
    testCounts: exports.testCountsSchema.optional().meta({ description: 'Test count statistics' }),
});
exports.GetPlanRunInfoToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.GetPlanRunInfo,
    description: "Retrieves comprehensive information about a plan run including status, timing, configuration, and test counts.\n\nUse this tool to:\n- Understand the overall plan run result and status\n- Get test pass/fail counts and pass rate\n- Learn about the plan run configuration (application, environment, etc.)\n- Understand how the plan run was triggered (scheduled, manual, deployment, etc.)\n- Get timing information about the plan execution",
    argumentsSchema: exports.getPlanRunInfoParamsSchema,
    responseSchema: exports.getPlanRunInfoResponseSchema,
});
//# sourceMappingURL=GetPlanRunInfoDefinition.js.map