import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from '../shared/agentToolNames.js';
/**
 * GetPlanRunInfoDefinition - Tool definition for fetching comprehensive plan run information.
 */
export const getPlanRunInfoParamsSchema = z.object({
    plan_run_id: 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: z.boolean().optional().meta({
        description: 'Whether to include detailed test count information. Default: true',
    }),
    include_context: z.boolean().optional().meta({
        description: 'Whether to include detailed context about application, environment, and plan configuration. Default: true',
    }),
});
// Schema for application context
export const applicationContextSchema = z.object({
    id: z.string().meta({ description: 'Application ID' }),
    name: z.string().optional().meta({ description: 'Application name' }),
});
// Schema for environment context
export const environmentContextSchema = z.object({
    id: z.string().meta({ description: 'Environment ID' }),
    name: z.string().optional().meta({ description: 'Environment name' }),
});
// Schema for plan context
export const planContextSchema = z.object({
    id: z.string().meta({ description: 'Plan ID' }),
    name: z.string().optional().meta({ description: 'Plan name' }),
});
// Schema for plan run context
export const planRunContextSchema = z.object({
    application: applicationContextSchema.optional().meta({ description: 'Application this plan ran against' }),
    environment: environmentContextSchema.optional().meta({ description: 'Environment this plan ran in' }),
    plan: planContextSchema.optional().meta({ description: 'Plan configuration' }),
    triggerType: z.string().optional().meta({ description: 'How the plan run was triggered (schedule, manual, etc.)' }),
    isAdHoc: z.boolean().optional().meta({ description: 'Whether this was an ad-hoc run' }),
    deploymentIds: z.array(z.string()).optional().meta({ description: 'Associated deployment IDs' }),
});
// Schema for test counts
export const testCountsSchema = z.object({
    total: z.number().meta({ description: 'Total number of tests in the plan run' }),
    passed: z.number().meta({ description: 'Number of passed tests' }),
    failed: z.number().meta({ description: 'Number of failed tests' }),
    skipped: z.number().meta({ description: 'Number of skipped tests' }),
    running: z.number().meta({ description: 'Number of currently running tests' }),
    passRate: z.number().optional().meta({ description: 'Pass rate as a percentage (0-100)' }),
});
export const planRunSummarySchema = z.object({
    planRunId: z.string().meta({ description: 'Plan run ID' }),
    planId: z.string().optional().meta({ description: 'Plan ID' }),
    planName: z.string().optional().meta({ description: 'Plan name' }),
    status: z.enum(['queued', 'running', 'passed', 'failed', 'cancelled', 'terminated']).meta({
        description: 'Overall status of the plan run',
    }),
    startTime: z.string().optional().meta({ description: 'Start time as ISO string' }),
    endTime: z.string().optional().meta({ description: 'End time as ISO string' }),
    durationMs: z.number().optional().meta({ description: 'Total duration in milliseconds' }),
});
export const getPlanRunInfoResponseSchema = z.object({
    summary: planRunSummarySchema.meta({ description: 'Summary information about the plan run' }),
    context: planRunContextSchema.optional().meta({ description: 'Contextual information about the plan run' }),
    testCounts: testCountsSchema.optional().meta({ description: 'Test count statistics' }),
});
export const GetPlanRunInfoToolDefinition = defineTool({
    name: AgentToolNames.GetPlanRunInfo,
    description: `Retrieves comprehensive information about a plan run including status, timing, configuration, and test counts.

Use this tool to:
- Understand the overall plan run result and status
- Get test pass/fail counts and pass rate
- Learn about the plan run configuration (application, environment, etc.)
- Understand how the plan run was triggered (scheduled, manual, deployment, etc.)
- Get timing information about the plan execution`,
    argumentsSchema: getPlanRunInfoParamsSchema,
    responseSchema: getPlanRunInfoResponseSchema,
});
//# sourceMappingURL=GetPlanRunInfoDefinition.js.map