/**
 * Adversary Agent - Configuration
 *
 * Default configurations and model settings for the adversary agent.
 *
 * @module agents/adversary/config
 */
// ============================================================================
// Default Configurations
// ============================================================================
/**
 * Default configuration for passive analysis
 */
export const PASSIVE_CONFIG = {
    aggressiveness: "passive",
    generatePoC: false,
    maxAnalysisTime: 60000, // 1 minute
    maxFiles: 50,
    enableChaining: true,
};
/**
 * Default configuration for active analysis
 */
export const ACTIVE_CONFIG = {
    aggressiveness: "active",
    generatePoC: true,
    maxAnalysisTime: 300000, // 5 minutes
    maxFiles: 100,
    enableChaining: true,
};
/**
 * Default configuration for aggressive analysis
 */
export const AGGRESSIVE_CONFIG = {
    aggressiveness: "aggressive",
    generatePoC: true,
    maxAnalysisTime: 600000, // 10 minutes
    maxFiles: 200,
    enableChaining: true,
};
/**
 * All attack focus areas
 */
export const ALL_FOCUS_AREAS = [
    "web-app",
    "api",
    "auth",
    "injection",
    "llm",
    "infra",
    "crypto",
    "data-flow",
    "supply-chain",
];
/**
 * Web-focused attack areas
 */
export const WEB_FOCUS_AREAS = [
    "web-app",
    "api",
    "auth",
    "injection",
];
/**
 * LLM/AI-focused attack areas
 */
export const LLM_FOCUS_AREAS = [
    "llm",
    "data-flow",
    "supply-chain",
];
/**
 * Infrastructure-focused attack areas
 */
export const INFRA_FOCUS_AREAS = [
    "infra",
    "crypto",
    "supply-chain",
];
// ============================================================================
// Model Configuration
// ============================================================================
/**
 * Default model versions - can be overridden via environment variables:
 *   ADVERSARY_SONNET_MODEL - Pro tier model (default: claude-sonnet-4-20250514)
 *   ADVERSARY_OPUS_MODEL   - Enterprise tier model (default: claude-opus-4-20250514)
 *
 * When Anthropic releases new versions, update these or set env vars.
 */
export const DEFAULT_SONNET_MODEL = process.env.ADVERSARY_SONNET_MODEL || "claude-sonnet-4-20250514";
export const DEFAULT_OPUS_MODEL = process.env.ADVERSARY_OPUS_MODEL || "claude-opus-4-20250514";
/**
 * Model pricing per million tokens (as of 2026)
 */
export const MODEL_PRICING = {
    // Sonnet 4 variants
    "claude-sonnet-4-20250514": { input: 3.0, output: 15.0 },
    // Opus 4 variants
    "claude-opus-4-20250514": { input: 15.0, output: 75.0 },
    // Default pricing for unknown models (use Sonnet pricing)
    default: { input: 3.0, output: 15.0 },
};
/**
 * Model capabilities (applies to model families, not specific versions)
 */
export const MODEL_CAPABILITIES = {
    sonnet: {
        contextWindow: 200000,
        maxOutputTokens: 64000,
        bestFor: ["Fast analysis", "Pattern detection", "Code review"],
    },
    opus: {
        contextWindow: 200000,
        maxOutputTokens: 64000,
        bestFor: ["Deep reasoning", "Novel vulnerability discovery", "Complex chains"],
    },
};
/**
 * Get model family from model ID
 */
export function getModelFamily(model) {
    if (model.includes("sonnet"))
        return "sonnet";
    if (model.includes("opus"))
        return "opus";
    return "unknown";
}
/**
 * Get model for plan tier
 * Uses environment variables if set, otherwise defaults
 */
export function getModelForTier(tier) {
    switch (tier) {
        case "free":
            return null; // Adversary not available on free
        case "pro":
            return DEFAULT_SONNET_MODEL;
        case "enterprise":
            return DEFAULT_OPUS_MODEL;
    }
}
/**
 * Get pricing for a model (falls back to default if unknown)
 */
export function getModelPricing(model) {
    return MODEL_PRICING[model] || MODEL_PRICING.default;
}
// ============================================================================
// File Patterns
// ============================================================================
/**
 * Default include patterns for analysis
 */
export const DEFAULT_INCLUDE_PATTERNS = [
    "**/*.ts",
    "**/*.tsx",
    "**/*.js",
    "**/*.jsx",
    "**/*.py",
    "**/*.go",
    "**/*.rs",
    "**/*.java",
    "**/*.rb",
    "**/*.php",
    "**/*.cs",
];
/**
 * Default exclude patterns
 */
export const DEFAULT_EXCLUDE_PATTERNS = [
    "**/node_modules/**",
    "**/dist/**",
    "**/build/**",
    "**/.git/**",
    "**/vendor/**",
    "**/venv/**",
    "**/__pycache__/**",
    "**/coverage/**",
    "**/*.test.*",
    "**/*.spec.*",
    "**/test/**",
    "**/tests/**",
    "**/__tests__/**",
    "**/fixtures/**",
];
/**
 * Security-relevant file patterns (prioritized)
 */
export const SECURITY_RELEVANT_PATTERNS = [
    "**/auth/**",
    "**/authentication/**",
    "**/authorization/**",
    "**/login/**",
    "**/session/**",
    "**/jwt/**",
    "**/oauth/**",
    "**/api/**",
    "**/routes/**",
    "**/handlers/**",
    "**/controllers/**",
    "**/middleware/**",
    "**/crypto/**",
    "**/encryption/**",
    "**/db/**",
    "**/database/**",
    "**/sql/**",
    "**/graphql/**",
    "**/upload/**",
    "**/download/**",
    "**/file/**",
    "**/admin/**",
    "**/config/**",
    "**/secrets/**",
    "**/*password*",
    "**/*credential*",
    "**/*token*",
    "**/*key*",
];
// ============================================================================
// MITRE ATT&CK Mappings
// ============================================================================
/**
 * MITRE ATT&CK technique mappings for focus areas
 */
export const FOCUS_AREA_MITRE_MAPPING = {
    "web-app": [
        "T1189", // Drive-by Compromise
        "T1190", // Exploit Public-Facing Application
        "T1059", // Command and Scripting Interpreter
    ],
    "api": [
        "T1190", // Exploit Public-Facing Application
        "T1106", // Native API
        "T1071", // Application Layer Protocol
    ],
    "auth": [
        "T1078", // Valid Accounts
        "T1110", // Brute Force
        "T1539", // Steal Web Session Cookie
        "T1556", // Modify Authentication Process
    ],
    "injection": [
        "T1059", // Command and Scripting Interpreter
        "T1203", // Exploitation for Client Execution
        "T1505", // Server Software Component
    ],
    "llm": [
        "AML.T0043", // Craft Adversarial Data (ATLAS)
        "AML.T0048", // LLM Prompt Injection (ATLAS)
        "AML.T0051", // LLM Jailbreak (ATLAS)
    ],
    "infra": [
        "T1610", // Deploy Container
        "T1525", // Implant Internal Image
        "T1611", // Escape to Host
    ],
    "crypto": [
        "T1552", // Unsecured Credentials
        "T1557", // Adversary-in-the-Middle
        "T1600", // Weaken Encryption
    ],
    "data-flow": [
        "T1020", // Automated Exfiltration
        "T1041", // Exfiltration Over C2 Channel
        "T1567", // Exfiltration Over Web Service
    ],
    "supply-chain": [
        "T1195", // Supply Chain Compromise
        "T1199", // Trusted Relationship
        "T1505", // Server Software Component
    ],
};
// ============================================================================
// CWE Mappings
// ============================================================================
/**
 * Common CWE mappings for focus areas
 */
export const FOCUS_AREA_CWE_MAPPING = {
    "web-app": [
        "CWE-79", // XSS
        "CWE-352", // CSRF
        "CWE-1021", // Clickjacking
        "CWE-942", // CORS Misconfiguration
    ],
    "api": [
        "CWE-284", // Improper Access Control
        "CWE-770", // Resource Allocation Without Limits
        "CWE-200", // Exposure of Sensitive Information
        "CWE-639", // IDOR
    ],
    "auth": [
        "CWE-287", // Improper Authentication
        "CWE-384", // Session Fixation
        "CWE-798", // Hard-coded Credentials
        "CWE-307", // Brute Force
    ],
    "injection": [
        "CWE-89", // SQL Injection
        "CWE-78", // OS Command Injection
        "CWE-611", // XXE
        "CWE-94", // Code Injection
        "CWE-1336", // SSTI
    ],
    "llm": [
        "CWE-1421", // Prompt Injection (proposed)
        "CWE-200", // Sensitive Information Exposure
        "CWE-284", // Improper Access Control
    ],
    "infra": [
        "CWE-250", // Execution with Unnecessary Privileges
        "CWE-269", // Improper Privilege Management
        "CWE-668", // Exposure of Resource to Wrong Sphere
    ],
    "crypto": [
        "CWE-327", // Use of Broken Crypto Algorithm
        "CWE-326", // Inadequate Encryption Strength
        "CWE-320", // Key Management Errors
        "CWE-338", // Use of Weak PRNG
    ],
    "data-flow": [
        "CWE-200", // Exposure of Sensitive Information
        "CWE-532", // Log Injection
        "CWE-209", // Generation of Error Message Containing Sensitive Info
    ],
    "supply-chain": [
        "CWE-1104", // Use of Unmaintained Third-Party Components
        "CWE-494", // Download of Code Without Integrity Check
        "CWE-829", // Inclusion of Functionality from Untrusted Control Sphere
    ],
};
// ============================================================================
// Factory Functions
// ============================================================================
/**
 * Create default adversary configuration
 */
export function createDefaultConfig(model, aggressiveness = "active") {
    const baseConfig = aggressiveness === "passive"
        ? PASSIVE_CONFIG
        : aggressiveness === "active"
            ? ACTIVE_CONFIG
            : AGGRESSIVE_CONFIG;
    return {
        model,
        aggressiveness,
        focusAreas: ALL_FOCUS_AREAS,
        maxAnalysisTime: baseConfig.maxAnalysisTime,
        generatePoC: baseConfig.generatePoC,
        maxFiles: baseConfig.maxFiles,
        enableChaining: baseConfig.enableChaining,
        includePatterns: DEFAULT_INCLUDE_PATTERNS,
        excludePatterns: DEFAULT_EXCLUDE_PATTERNS,
    };
}
/**
 * Create focused adversary configuration
 */
export function createFocusedConfig(model, focusAreas, aggressiveness = "active") {
    const config = createDefaultConfig(model, aggressiveness);
    config.focusAreas = focusAreas;
    return config;
}
/**
 * Estimate token usage for analysis
 */
export function estimateTokenUsage(filesCount, avgFileSize, config) {
    // Rough estimates based on typical analysis
    const tokensPerKB = 250;
    const avgFileSizeKB = avgFileSize / 1024;
    // Input: code context + prompts
    const codeTokens = filesCount * avgFileSizeKB * tokensPerKB;
    const promptOverhead = filesCount * 500; // ~500 tokens per file for prompts
    const estimatedInputTokens = Math.round(codeTokens + promptOverhead);
    // Output: findings, reasoning, PoCs
    const findingsPerFile = config.aggressiveness === "aggressive" ? 3 :
        config.aggressiveness === "active" ? 2 : 1;
    const tokensPerFinding = config.generatePoC ? 1000 : 500;
    const estimatedOutputTokens = Math.round(filesCount * findingsPerFile * tokensPerFinding);
    // Calculate cost
    const pricing = getModelPricing(config.model);
    const inputCost = (estimatedInputTokens / 1_000_000) * pricing.input;
    const outputCost = (estimatedOutputTokens / 1_000_000) * pricing.output;
    const estimatedCost = inputCost + outputCost;
    return {
        estimatedInputTokens,
        estimatedOutputTokens,
        estimatedCost: Math.round(estimatedCost * 100) / 100,
    };
}
//# sourceMappingURL=config.js.map