/**
 * Agent & MCP Security Scanner Types
 *
 * Types for scanning MCP servers, agent systems, and AI tool chains.
 * These scanners extend the deterministic scanner layer with agent-specific
 * security checks: prompt injection fuzzing, exfiltration path analysis,
 * manifest auditing, and permission minimization.
 *
 * @module scanners/agent/types
 */
import { z } from "zod";
/**
 * All agent scanner types as an array for iteration
 */
export const AGENT_SCANNER_TYPES = [
    "manifest-audit",
    "tool-description-drift",
    "prompt-injection-fuzzer",
    "exfil-path-graph",
    "permission-minimiser",
    "supply-chain-mcp",
    "sandbox-audit",
    "credential-scope-audit",
];
/**
 * Zod schema for MCPManifest validation
 */
export const MCPManifestSchema = z.object({
    name: z.string().min(1),
    version: z.string().min(1),
    description: z.string().optional(),
    tools: z.array(z.object({
        name: z.string().min(1),
        description: z.string(),
        inputSchema: z.any().optional(),
        destructiveHint: z.boolean().optional(),
        readOnlyHint: z.boolean().optional(),
        allowedOrigins: z.array(z.string()).optional(),
        networkAccess: z.boolean().optional(),
        codeExecution: z.boolean().optional(),
        requiredPermissions: z.array(z.string()).optional(),
    })),
    resources: z
        .array(z.object({
        uri: z.string(),
        name: z.string(),
        description: z.string().optional(),
        mimeType: z.string().optional(),
    }))
        .optional(),
    prompts: z
        .array(z.object({
        name: z.string(),
        description: z.string().optional(),
        arguments: z
            .array(z.object({
            name: z.string(),
            description: z.string().optional(),
            required: z.boolean().optional(),
        }))
            .optional(),
    }))
        .optional(),
    capabilities: z
        .object({
        tools: z.boolean().optional(),
        resources: z.boolean().optional(),
        prompts: z.boolean().optional(),
        logging: z.boolean().optional(),
    })
        .optional(),
    config: z.record(z.unknown()).optional(),
});
/**
 * Default agent scanner options
 */
export const DEFAULT_AGENT_SCANNER_OPTIONS = {
    scanners: {
        manifestAudit: true,
        toolDrift: true,
        promptInjection: true,
        exfilPath: true,
        permissionMinimiser: false, // Requires traces
        supplyChain: true,
        sandboxAudit: true,
        credentialScope: true,
    },
    baselinesDir: ".vaspera/agent/baselines",
    tracesDir: ".vaspera/traces",
    fuzzerOptions: {
        corpus: "standard",
        redactResponses: true,
    },
    timeout: 300000, // 5 minutes per scanner
    concurrency: 2,
};
// ============================================================================
// Finding Category Prefixes
// ============================================================================
/**
 * Convert agent scanner type to finding ID prefix
 */
export function toAgentFindingId(scanner, index) {
    const prefix = {
        "manifest-audit": "mft",
        "tool-description-drift": "drf",
        "prompt-injection-fuzzer": "inj",
        "exfil-path-graph": "exf",
        "permission-minimiser": "prm",
        "supply-chain-mcp": "scp",
        "sandbox-audit": "sbx",
        "credential-scope-audit": "crd",
    };
    return `${prefix[scanner]}-${String(index + 1).padStart(3, "0")}`;
}
/**
 * Severity mappings for agent scanner findings
 */
export const AGENT_SEVERITY_MAPPINGS = {
    // Manifest audit
    "missing-destructive-hint": "high",
    "missing-readonly-hint": "medium",
    "missing-input-schema": "high",
    "unbounded-origins": "critical",
    "version-drift": "medium",
    "missing-description": "low",
    "excessive-permissions": "high",
    "undeclared-network": "high",
    "undeclared-code-execution": "critical",
    // Drift types
    "tool-added": "info",
    "tool-removed": "medium",
    "description-changed": "high",
    "schema-changed": "critical",
    "permission-changed": "high",
    "capability-changed": "high",
    // Sandbox escapes
    child_process: "critical",
    eval: "critical",
    Function: "critical",
    vm: "high",
    require: "high",
    "import-dynamic": "high",
    "fs-outside-scope": "high",
    "net-undeclared": "critical",
    "env-access": "medium",
    "process-access": "medium",
};
//# sourceMappingURL=types.js.map