agentshield-sdk 11.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/index.d.ts CHANGED
@@ -2531,661 +2531,332 @@ export declare const IPIA_FEATURE_NAMES: string[];
2531
2531
  export declare const IPIA_INJECTION_LEXICON: Record<string, number>;
2532
2532
 
2533
2533
  // =========================================================================
2534
- // v8.0 Smart Config
2535
- // =========================================================================
2536
-
2537
- export type PresetName =
2538
- | 'chatbot'
2539
- | 'coding_agent'
2540
- | 'rag_pipeline'
2541
- | 'customer_support'
2542
- | 'internal_tool'
2543
- | 'multi_agent'
2544
- | 'high_security'
2545
- | 'minimal'
2546
- | 'mcp_server';
2547
-
2548
- export type SensitivityLevel = 'low' | 'medium' | 'high';
2549
-
2550
- export type BlockThresholdLevel = 'low' | 'medium' | 'high' | 'critical';
2551
-
2552
- export type VoterName = 'pattern' | 'tfidf' | 'entropy' | 'ipia' | 'semantic' | 'behavioral' | 'heuristic';
2553
-
2554
- export interface IntentConfig {
2555
- purpose?: string;
2556
- allowedTools?: string[];
2557
- allowedTopics?: string[];
2558
- maxDriftScore?: number;
2534
+ // v10-v11: MCP Guard
2535
+ // =========================================================================
2536
+
2537
+ export declare class MCPGuard {
2538
+ constructor(options?: {
2539
+ requireAuth?: boolean;
2540
+ allowedIssuers?: string[];
2541
+ requiredScopes?: string[];
2542
+ rateLimit?: number;
2543
+ cbThreshold?: number;
2544
+ cbCooldownMs?: number;
2545
+ baselineWindow?: number;
2546
+ zThreshold?: number;
2547
+ onAlert?: (alert: any) => void;
2548
+ scanner?: (text: string) => any;
2549
+ enableMicroModel?: boolean;
2550
+ enableIntentGraph?: boolean;
2551
+ enableIsolation?: boolean;
2552
+ enableIntentBinding?: boolean;
2553
+ enableAttackSurface?: boolean;
2554
+ enableDriftMonitor?: boolean;
2555
+ enableOWASP?: boolean;
2556
+ signingKey?: string;
2557
+ model?: string;
2558
+ });
2559
+ registerServer(serverId: string, toolDefinitions: any, authToken?: any): { allowed: boolean; attestation: any; auth: any; threats: any[] };
2560
+ interceptToolCall(serverId: string, toolName: string, args: any): { allowed: boolean; threats: any[]; anomalies: any[] };
2561
+ interceptToolOutput(serverId: string, toolName: string, output: any, responseTimeMs?: number): { safe: boolean; threats: any[]; anomalies: any[] };
2562
+ setUserIntent(intentText: string): { intentHash: string | null; allowedActions: string[] };
2563
+ detectAttackChains(): { chains: any[]; riskLevel: string };
2564
+ registerAgent(agentId: string, metadata?: { model?: string; servers?: string[]; capabilities?: string[]; owner?: string }): { agentId: string; riskProfile: any; registered: boolean };
2565
+ recordAgentActivity(agentId: string, hadThreat: boolean): void;
2566
+ getFleetStatus(): { totalAgents: number; highRiskAgents: number; agents: any[]; fleetRiskLevel: string };
2567
+ getSecurityPosture(): { securityScore: number; grade: string; activeLayers: number; totalLayers: number; layerCoverage: string; layers: any; servers: any; chainAnalysis: any; timestamp: number };
2568
+ measureDefenseEffectiveness(): { effectiveness: any; totalAttacks: number; recommendation: string };
2569
+ getReport(): any;
2570
+ getAuditLog(): any[];
2571
+ resetCircuitBreaker(serverId: string): void;
2559
2572
  }
2560
2573
 
2561
- export interface LearningConfig {
2562
- persist?: boolean;
2563
- persistPath?: string;
2564
- promotionThreshold?: number;
2565
- maxPatterns?: number;
2574
+ export declare class ServerAttestation {
2575
+ attest(serverId: string, toolDefinitions: any): { trusted: boolean; hash: string; changed: boolean; alert: any | null };
2576
+ update(serverId: string, toolDefinitions: any): void;
2577
+ get(serverId: string): any | null;
2578
+ getAlerts(): any[];
2579
+ clearAlerts(): void;
2566
2580
  }
2567
2581
 
2568
- export interface FeedbackConfig {
2569
- autoRetrain?: boolean;
2570
- maxPending?: number;
2571
- cooldownMs?: number;
2582
+ export declare class CrossServerIsolation {
2583
+ registerServer(serverId: string, toolNames: string[]): void;
2584
+ validate(callingServerId: string, toolName: string, args: any): { allowed: boolean; violation: any | null };
2585
+ getOwner(toolName: string): string | null;
2572
2586
  }
2573
2587
 
2574
- export interface EnsembleConfig {
2575
- voters?: VoterName[];
2576
- threshold?: number;
2577
- requireUnanimous?: boolean;
2588
+ export declare class OAuthEnforcer {
2589
+ constructor(options?: { required?: boolean; allowedIssuers?: string[]; requiredScopes?: string[]; clockSkewMs?: number });
2590
+ validate(token: any | null): { authenticated: boolean; reason: string | null };
2578
2591
  }
2579
2592
 
2580
- export interface GoalDriftConfig {
2581
- checkInterval?: number;
2582
- driftThreshold?: number;
2583
- windowSize?: number;
2593
+ export declare class ToolBehaviorBaseline {
2594
+ constructor(options?: { windowSize?: number; zThreshold?: number });
2595
+ record(toolName: string, observation?: { argLength?: number; responseTimeMs?: number; isError?: boolean }): { anomalies: any[] };
2596
+ getBaseline(toolName: string): any | null;
2584
2597
  }
2585
2598
 
2586
- export interface CrossTurnConfig {
2587
- windowSize?: number;
2588
- scanInterval?: number;
2589
- accumulateAll?: boolean;
2590
- }
2599
+ // =========================================================================
2600
+ // v10-v11: Supply Chain Scanner
2601
+ // =========================================================================
2591
2602
 
2592
- export interface ToolSequenceConfig {
2593
- learningPeriod?: number;
2594
- anomalyThreshold?: number;
2595
- maxChainLength?: number;
2603
+ export declare class SupplyChainScanner {
2604
+ constructor(options?: { knownBadServers?: any; cveRegistry?: any; enableMicroModel?: boolean });
2605
+ fingerprintServer(server: any): string;
2606
+ scanServer(server: { name: string; tools: any[] }, context?: { previousFingerprint?: string; auth?: any; configFiles?: any[] }): { server: string; status: string; score: number; highestSeverity: string; summary: any; findings: any[]; recommendations: string[]; generatedAt: number };
2607
+ scanMultiple(servers: any[]): { serverCount: number; totalFindings: number; worstScore: number; reports: any[] };
2608
+ toSARIF(report: any): any;
2609
+ toMarkdown(report: any): string;
2610
+ getCIExitCode(report: any, options?: { failOn?: string }): { exitCode: number; reason: string };
2611
+ enforce(server: any, options?: { failOn?: string; context?: any }): any;
2596
2612
  }
2597
2613
 
2598
- export interface AdaptiveThresholdsConfig {
2599
- calibrationSamples?: number;
2600
- adjustInterval?: number;
2601
- minConfidence?: number;
2602
- }
2614
+ export declare const KNOWN_BAD_SERVERS: Record<string, { reason: string; severity: string }>;
2615
+ export declare const CVE_REGISTRY: Record<string, Array<{ cve: string; severity: string; description: string; fix: string }>>;
2603
2616
 
2604
- export interface SelfTrainingConfig {
2605
- generations?: number;
2606
- populationSize?: number;
2607
- mutationRate?: number;
2608
- interval?: number;
2609
- }
2610
-
2611
- export interface ShieldCallbacks {
2612
- onThreat?: ((threatInfo: any) => void) | null;
2613
- onDrift?: ((driftInfo: any) => void) | null;
2614
- onAnomaly?: ((anomalyInfo: any) => void) | null;
2615
- }
2617
+ // =========================================================================
2618
+ // v10-v11: OWASP Agentic Scanner
2619
+ // =========================================================================
2616
2620
 
2617
- export interface ShieldConfig {
2618
- preset: PresetName | null;
2619
- sensitivity: SensitivityLevel;
2620
- blockOnThreat: boolean;
2621
- blockThreshold: BlockThresholdLevel;
2622
- intent: IntentConfig | null;
2623
- learning: LearningConfig | null;
2624
- feedback: FeedbackConfig | null;
2625
- ensemble: EnsembleConfig | null;
2626
- goalDrift: GoalDriftConfig | null;
2627
- crossTurn: CrossTurnConfig | null;
2628
- toolSequence: ToolSequenceConfig | null;
2629
- adaptiveThresholds: AdaptiveThresholdsConfig | null;
2630
- selfTraining: SelfTrainingConfig | null;
2631
- readonly callbacks: ShieldCallbacks;
2632
- }
2633
-
2634
- export interface ConfigValidationResult {
2635
- valid: boolean;
2636
- errors: string[];
2621
+ export declare class OWASPAgenticScanner {
2622
+ constructor(options?: { failThreshold?: number });
2623
+ scan(input: string | any): { score: number; exitCode: number; status: string; findings: any[]; summary: any; risks: any[] };
2624
+ scanBatch(inputs: Array<string | any>): { inputCount: number; score: number; exitCode: number; status: string; findings: any[]; summary: any; riskCounts: any };
2625
+ toJSON(scanResult: any): string;
2626
+ toMarkdown(scanResult: any): string;
2627
+ toSARIF(scanResult: any): any;
2637
2628
  }
2638
2629
 
2639
- export declare class ShieldBuilder {
2640
- constructor();
2641
- preset(name: PresetName): this;
2642
- sensitivity(level: SensitivityLevel): this;
2643
- blockOnThreat(bool: boolean): this;
2644
- blockThreshold(level: BlockThresholdLevel): this;
2645
- enableIntent(opts?: IntentConfig): this;
2646
- enableLearning(opts?: LearningConfig): this;
2647
- enableFeedback(opts?: FeedbackConfig): this;
2648
- enableEnsemble(opts?: EnsembleConfig): this;
2649
- enableGoalDrift(opts?: GoalDriftConfig): this;
2650
- enableCrossTurn(opts?: CrossTurnConfig): this;
2651
- enableToolSequence(opts?: ToolSequenceConfig): this;
2652
- enableAdaptiveThresholds(opts?: AdaptiveThresholdsConfig): this;
2653
- enableSelfTraining(opts?: SelfTrainingConfig): this;
2654
- onThreat(callback: (threatInfo: any) => void): this;
2655
- onDrift(callback: (driftInfo: any) => void): this;
2656
- onAnomaly(callback: (anomalyInfo: any) => void): this;
2657
- build(): ShieldConfig;
2658
- }
2659
-
2660
- export declare function createShield(): ShieldBuilder;
2661
- export declare function createShield(preset: PresetName): ShieldConfig;
2662
- export declare function createShield(config: {
2663
- preset?: PresetName;
2664
- sensitivity?: SensitivityLevel;
2665
- blockOnThreat?: boolean;
2666
- blockThreshold?: BlockThresholdLevel;
2667
- intent?: IntentConfig | boolean;
2668
- learning?: LearningConfig | boolean;
2669
- feedback?: FeedbackConfig | boolean;
2670
- ensemble?: EnsembleConfig | boolean;
2671
- goalDrift?: GoalDriftConfig | boolean;
2672
- crossTurn?: CrossTurnConfig | boolean;
2673
- toolSequence?: ToolSequenceConfig | boolean;
2674
- adaptiveThresholds?: AdaptiveThresholdsConfig | boolean;
2675
- selfTraining?: SelfTrainingConfig | boolean;
2676
- onThreat?: (threatInfo: any) => void;
2677
- onDrift?: (driftInfo: any) => void;
2678
- onAnomaly?: (anomalyInfo: any) => void;
2679
- }): ShieldConfig;
2680
- export declare function createShield(builder: ShieldBuilder): ShieldConfig;
2681
-
2682
- export declare function validateConfig(config: any): ConfigValidationResult;
2683
- export declare function describeConfig(config: ShieldConfig): string;
2684
-
2685
- export declare const FEATURE_DEFAULTS: {
2686
- intent: Required<IntentConfig>;
2687
- learning: Required<LearningConfig>;
2688
- feedback: Required<FeedbackConfig>;
2689
- ensemble: Required<EnsembleConfig>;
2690
- goalDrift: Required<GoalDriftConfig>;
2691
- crossTurn: Required<CrossTurnConfig>;
2692
- toolSequence: Required<ToolSequenceConfig>;
2693
- adaptiveThresholds: Required<AdaptiveThresholdsConfig>;
2694
- selfTraining: Required<SelfTrainingConfig>;
2695
- };
2696
-
2697
- export declare const VALID_PRESETS: PresetName[];
2630
+ export declare const OWASP_AGENTIC_2026: ReadonlyArray<{ id: string; name: string; severity: string; description: string; patterns: RegExp[]; remediation: string }>;
2698
2631
 
2699
2632
  // =========================================================================
2700
- // v8.0 Ensemble Voting Classifier
2633
+ // v10-v11: Red Team CLI
2701
2634
  // =========================================================================
2702
2635
 
2703
- export interface VoteResult {
2704
- voter: string;
2705
- isInjection: boolean;
2706
- confidence: number;
2707
- reason: string;
2708
- }
2709
-
2710
- export interface EnsembleScanResult {
2711
- isInjection: boolean;
2712
- confidence: number;
2713
- severity: 'critical' | 'high' | 'medium' | 'low';
2714
- votes: VoteResult[];
2715
- agreement: number;
2716
- method: string;
2717
- timestamp: string;
2718
- }
2719
-
2720
- export interface EnsembleStats {
2721
- totalScans: number;
2722
- injections: number;
2723
- safe: number;
2724
- averageAgreement: number;
2725
- averageConfidence: number;
2726
- voterCount: number;
2727
- voters: string[];
2636
+ export declare class RedTeamCLI {
2637
+ constructor(options?: { scanFn?: (text: string) => any; enableMicroModel?: boolean });
2638
+ run(endpoint: string, options?: { mode?: 'quick' | 'standard' | 'full'; compareWith?: any; serverName?: string; tools?: any[] }): any;
2639
+ writeReports(report: any, outputDir?: string): { jsonPath: string; mdPath: string; htmlPath: string };
2640
+ toMarkdown(report: any): string;
2641
+ toHTML(report: any): string;
2728
2642
  }
2729
2643
 
2730
- export interface EnsembleClassifierOptions {
2731
- voters?: VoterName[];
2732
- threshold?: number;
2733
- requireUnanimous?: boolean;
2734
- weights?: Record<string, number>;
2735
- minVoters?: number;
2736
- voterOptions?: Record<string, any>;
2737
- }
2644
+ export declare const REDTEAM_MODES: Readonly<{ quick: 50; standard: 200; full: 617 }>;
2738
2645
 
2739
- export declare class EnsembleClassifier {
2740
- threshold: number;
2741
- requireUnanimous: boolean;
2742
- minVoters: number;
2743
- weights: Record<string, number>;
2744
- constructor(config?: EnsembleClassifierOptions);
2745
- scan(text: string, context?: { intent?: string; source?: string; conversationHistory?: string[] }): EnsembleScanResult;
2746
- getStats(): EnsembleStats;
2747
- }
2646
+ // =========================================================================
2647
+ // v10-v11: Drift Monitor
2648
+ // =========================================================================
2748
2649
 
2749
- export declare class PatternVoter {
2750
- name: string;
2751
- constructor(options?: { source?: string });
2752
- vote(text: string, context?: any): VoteResult;
2650
+ export declare class DriftMonitor {
2651
+ constructor(options?: { windowSize?: number; alertThreshold?: number; klThreshold?: number; enableCircuitBreaker?: boolean; circuitBreaker?: any; prometheus?: any; metrics?: any; onAlert?: (alert: any) => void });
2652
+ observe(event: { callFreq?: number; responseLength?: number; errorRate?: number; timingMs?: number; topic?: string }): { alert: boolean; zScores?: any; klDivergence?: number; maxZScore?: number; learning?: boolean; baselineReady?: boolean };
2653
+ rebuildBaseline(): void;
2654
+ getPeriodicSummary(): any;
2655
+ getAlertHistory(): any[];
2656
+ reset(): void;
2753
2657
  }
2754
2658
 
2755
- export declare class TFIDFVoter {
2756
- name: string;
2757
- constructor(options?: { similarityThreshold?: number });
2758
- vote(text: string, context?: any): VoteResult;
2759
- }
2659
+ // =========================================================================
2660
+ // v10-v11: Micro Model
2661
+ // =========================================================================
2760
2662
 
2761
- export declare class EntropyVoter {
2762
- name: string;
2763
- constructor(options?: { entropyThreshold?: number; ngramSize?: number });
2764
- vote(text: string, context?: any): VoteResult;
2663
+ export declare class MicroModel {
2664
+ corpus: Array<{ text: string; category: string; severity: string; source: string }>;
2665
+ constructor(options?: { threshold?: number; k?: number; ensembleWeight?: number; additionalCorpus?: any[]; skipTraining?: boolean });
2666
+ classify(text: string): { threat: boolean; category: string; severity: string; confidence: number; method: string; logisticScore: any; topMatches: any[] };
2667
+ scan(text: string): { threats: any[]; severity: string; status: string };
2668
+ addSamples(samples: Array<{ text: string; category: string; severity: string; source: string }>): void;
2669
+ getStats(): { classified: number; threats: number; benign: number; corpusSize: number; categories: string[]; threatRate: number };
2670
+ getCategoryCounts(): Record<string, number>;
2765
2671
  }
2766
2672
 
2767
- export declare class IPIAVoter {
2768
- name: string;
2769
- constructor(options?: { classifierThreshold?: number });
2770
- vote(text: string, context?: { intent?: string }): VoteResult;
2673
+ export declare class LogisticClassifier {
2674
+ constructor(categories: string[], featureCount: number, options?: { learningRate?: number; epochs?: number; l2?: number; precomputedWeights?: any });
2675
+ train(data: Array<{ features: number[]; category: string }>): void;
2676
+ predict(features: number[]): { category: string; confidence: number; scores: Record<string, number> };
2677
+ getWeights(): any;
2771
2678
  }
2772
2679
 
2773
- export declare const VOTER_NAMES: string[];
2680
+ export declare function extractFeatures(text: string): number[];
2681
+ export declare function shannonEntropy(text: string): number;
2774
2682
 
2775
2683
  // =========================================================================
2776
- // v8.0 — Agent Intent & Goal Drift
2684
+ // v11: Self-Training
2777
2685
  // =========================================================================
2778
2686
 
2779
- export interface MessageCheckResult {
2780
- onTopic: boolean;
2781
- relevanceScore: number;
2782
- drift: number;
2783
- reason: string;
2784
- }
2785
-
2786
- export interface ToolCheckResult2 {
2787
- allowed: boolean;
2788
- reason: string;
2789
- }
2790
-
2791
- export interface DriftResult {
2792
- driftScore: number;
2793
- driftDetected: boolean;
2794
- trend: 'stable' | 'drifting' | 'recovering';
2795
- turnsSincePurpose: number;
2796
- topicShift: boolean;
2797
- reason: string;
2798
- }
2799
-
2800
- export interface GoalDriftStats {
2801
- totalMessages: number;
2802
- messagesInWindow: number;
2803
- driftEvents: number;
2804
- topicShifts: number;
2805
- averageDrift: number;
2806
- maxDrift: number;
2807
- currentTrend: 'stable' | 'drifting' | 'recovering';
2808
- historyLength: number;
2687
+ export declare class SelfTrainer {
2688
+ constructor(options?: { scanFn?: (text: string) => any; microModel?: MicroModel; maxRoundsPerCycle?: number });
2689
+ runCycle(seedAttacks: Array<{ text: string; category: string; severity: string }>): { bypasses: number; mutations: number; newSamples: number; bypassRate: number };
2690
+ applyToModel(): number;
2691
+ getBypasses(): any[];
2692
+ getStats(): any;
2693
+ exportSamples(): any[];
2694
+ reset(): void;
2809
2695
  }
2810
2696
 
2811
- export interface ToolSequenceResult {
2812
- allowed: boolean;
2813
- anomalyScore: number;
2814
- probability: number;
2815
- isLearning: boolean;
2816
- reason: string;
2697
+ export declare class MutationEngine {
2698
+ mutate(text: string): Array<{ text: string; strategy: string }>;
2817
2699
  }
2818
2700
 
2819
- export interface ToolSequenceStats {
2820
- totalCalls: number;
2821
- uniqueTools: number;
2822
- transitionCount: number;
2823
- anomalyCount: number;
2824
- isLearning: boolean;
2825
- learningProgress: number;
2826
- toolCounts: Record<string, number>;
2701
+ export declare class AutonomousHardener {
2702
+ constructor(options: { microModel: MicroModel; scanFn?: (text: string) => any; intervalMs?: number; persistPath?: string; maxCorpusGrowth?: number; maxFPRate?: number; fpTestSet?: string[]; seedAttacks?: any[]; onCycleComplete?: (result: any) => void });
2703
+ start(): void;
2704
+ stop(): void;
2705
+ runOnce(): any;
2706
+ getHistory(): any[];
2707
+ getStatus(): { running: boolean; totalCycles: number; totalSamplesAdded: number; currentCorpusSize: number; growthRemaining: number; lastCycle: any | null };
2827
2708
  }
2828
2709
 
2829
- export interface ToolSequenceExportData {
2830
- transitions: Record<string, Record<string, number>>;
2831
- toolCounts: Record<string, number>;
2832
- totalCalls: number;
2833
- anomalyCount: number;
2834
- learningPeriod: number;
2835
- anomalyThreshold: number;
2836
- exportedAt: string;
2837
- }
2710
+ // =========================================================================
2711
+ // v11: Intent Graph
2712
+ // =========================================================================
2838
2713
 
2839
- export interface AgentIntentOptions {
2840
- purpose: string;
2841
- allowedTools?: string[];
2842
- allowedTopics?: string[];
2843
- maxDriftScore?: number;
2844
- onDrift?: (info: any) => void;
2845
- }
2846
-
2847
- export declare class AgentIntent {
2848
- purpose: string;
2849
- allowedTools: string[] | null;
2850
- allowedTopics: string[] | null;
2851
- maxDriftScore: number;
2852
- constructor(config: AgentIntentOptions);
2853
- checkMessage(message: string): MessageCheckResult;
2854
- checkTool(toolName: string, args?: any): ToolCheckResult2;
2855
- getPurposeVector(): Map<string, number>;
2856
- }
2857
-
2858
- export interface GoalDriftDetectorOptions {
2859
- windowSize?: number;
2860
- driftThreshold?: number;
2861
- checkInterval?: number;
2862
- onDrift?: (info: any) => void;
2863
- }
2864
-
2865
- export declare class GoalDriftDetector {
2866
- intent: AgentIntent;
2867
- windowSize: number;
2868
- driftThreshold: number;
2869
- checkInterval: number;
2870
- constructor(intent: AgentIntent, config?: GoalDriftDetectorOptions);
2871
- addMessage(message: string, role?: string): DriftResult;
2872
- getHistory(): number[];
2714
+ export declare class IntentGraph {
2715
+ constructor(options?: { similarityThreshold?: number; maxNodes?: number });
2716
+ setIntent(intentText: string): { nodeId: number; topics: Set<string> };
2717
+ recordToolCall(toolName: string, args: any, reason?: string): { nodeId: number; causalScore: number; suspicious: boolean; violations: any[] };
2718
+ recordToolOutput(toolName: string, output: any): { nodeId: number };
2719
+ getChain(): any[];
2720
+ getAnomalies(): any[];
2721
+ getRiskAssessment(): { riskLevel: string; score: number; anomalyCount: number; chainLength: number };
2873
2722
  reset(): void;
2874
- getStats(): GoalDriftStats;
2875
- }
2876
-
2877
- export interface ToolSequenceModelerOptions {
2878
- learningPeriod?: number;
2879
- anomalyThreshold?: number;
2880
- maxChainLength?: number;
2881
- }
2882
-
2883
- export declare class ToolSequenceModeler {
2884
- learningPeriod: number;
2885
- anomalyThreshold: number;
2886
- maxChainLength: number;
2887
- constructor(config?: ToolSequenceModelerOptions);
2888
- recordToolCall(toolName: string, context?: { args?: any; userId?: string; agentId?: string }): ToolSequenceResult;
2889
- getTransitionMatrix(): Record<string, Record<string, number>>;
2890
- getCommonSequences(topN?: number): Array<{ from: string; to: string; count: number; probability: number }>;
2891
- exportModel(): ToolSequenceExportData;
2892
- importModel(data: ToolSequenceExportData): void;
2893
- getStats(): ToolSequenceStats;
2894
2723
  }
2895
2724
 
2896
2725
  // =========================================================================
2897
- // v8.0 Persistent Learning & Feedback
2726
+ // v11: Semantic Isolation
2898
2727
  // =========================================================================
2899
2728
 
2900
- export interface LearnedPatternMatch {
2901
- patternId: string;
2902
- pattern: string;
2903
- source: string;
2904
- confidence: number;
2905
- categories: string[];
2906
- severity: string;
2907
- }
2908
-
2909
- export interface LearningCheckResult {
2910
- matches: LearnedPatternMatch[];
2911
- count: number;
2912
- }
2729
+ export type Provenance = 'system' | 'user' | 'tool_output' | 'rag_chunk' | 'agent_message' | 'untrusted';
2913
2730
 
2914
- export interface IngestResult {
2915
- candidates: number;
2916
- signatures: string[];
2731
+ export declare class TaggedContent {
2732
+ text: string;
2733
+ provenance: Provenance;
2734
+ trustLevel: number;
2735
+ threats: any[];
2736
+ sanitized: boolean;
2737
+ constructor(text: string, provenance: Provenance, metadata?: any);
2738
+ isTrusted(requiredLevel: number): boolean;
2917
2739
  }
2918
2740
 
2919
- export interface FalsePositiveResult {
2920
- revoked: boolean;
2921
- fpCount: number;
2922
- remaining: number;
2741
+ export declare class IsolationPolicy {
2742
+ constructor(rules?: any);
2743
+ check(content: TaggedContent, action: string): { allowed: boolean; reason: string | null };
2923
2744
  }
2924
2745
 
2925
- export interface LearningExportData {
2926
- version: string;
2927
- timestamp: string;
2928
- patterns: any[];
2929
- candidates: any[];
2930
- stats: any;
2931
- }
2932
-
2933
- export interface LearningStats {
2934
- attacksIngested: number;
2935
- candidatesCreated: number;
2936
- patternsPromoted: number;
2937
- patternsRevoked: number;
2938
- falsePositivesReported: number;
2939
- saves: number;
2940
- loads: number;
2941
- activePatterns: number;
2942
- revokedPatterns: number;
2943
- candidates: number;
2944
- totalPromoted: number;
2945
- }
2946
-
2947
- export interface PersistentLearningLoopOptions {
2948
- persist?: boolean;
2949
- persistPath?: string;
2950
- promotionThreshold?: number;
2951
- maxPatterns?: number;
2952
- decayMs?: number;
2953
- maxFalsePositives?: number;
2954
- }
2955
-
2956
- export declare class PersistentLearningLoop {
2957
- constructor(config?: PersistentLearningLoopOptions);
2958
- ingest(text: string, meta?: { category?: string; source?: string; severity?: string }): IngestResult;
2959
- check(text: string): LearningCheckResult;
2960
- reportFalsePositive(patternId: string): FalsePositiveResult;
2961
- save(): boolean;
2962
- load(): boolean;
2963
- export(): LearningExportData;
2964
- import(data: LearningExportData): number;
2965
- decay(): number;
2966
- getStats(): LearningStats;
2967
- getActivePatterns(): any[];
2968
- }
2969
-
2970
- export interface FeedbackReportResult {
2971
- id: string;
2972
- status: string;
2973
- pendingCount: number;
2746
+ export declare class SemanticIsolationEngine {
2747
+ constructor(options?: { policy?: IsolationPolicy; scanUntrusted?: boolean; stripInstructionsFromUntrusted?: boolean });
2748
+ tag(text: string, provenance: Provenance, metadata?: any): TaggedContent;
2749
+ validateAction(content: TaggedContent, action: string): { allowed: boolean; reason: string | null; threats: any[] };
2750
+ buildContext(): { messages: any[]; blocked: any[] };
2751
+ getStats(): any;
2752
+ reset(): void;
2974
2753
  }
2975
2754
 
2976
- export interface FeedbackProcessResult {
2977
- processed: number;
2978
- patternsAdded: number;
2979
- patternsRevoked: number;
2980
- retrainTriggered: boolean;
2981
- }
2755
+ export declare const ISOLATION_PROVENANCE: Readonly<{ SYSTEM: 'system'; USER: 'user'; TOOL_OUTPUT: 'tool_output'; RAG_CHUNK: 'rag_chunk'; AGENT_MESSAGE: 'agent_message'; UNTRUSTED: 'untrusted' }>;
2756
+ export declare const TRUST_LEVELS: Readonly<Record<string, number>>;
2982
2757
 
2983
- export interface FeedbackStats {
2984
- falsePositives: number;
2985
- falseNegatives: number;
2986
- totalProcessed: number;
2987
- patternsAdded: number;
2988
- patternsRevoked: number;
2989
- retrainCount: number;
2990
- pendingCount: number;
2991
- processedCount: number;
2992
- }
2758
+ // =========================================================================
2759
+ // v11: Intent Binding
2760
+ // =========================================================================
2993
2761
 
2994
- export interface FeedbackCollectorOptions {
2995
- autoRetrain?: boolean;
2996
- maxPending?: number;
2997
- cooldownMs?: number;
2998
- learningLoop?: PersistentLearningLoop;
2762
+ export declare class IntentBinder {
2763
+ constructor(options?: { signingKey?: string; tokenTtlMs?: number; maxActionsPerIntent?: number; singleUseTokens?: boolean });
2764
+ bindIntent(intentText: string, metadata?: any): { intentHash: string; allowedActions: string[] };
2765
+ issueToken(intentHash: string, action: string, scope?: string): { token: IntentToken | null; error: string | null };
2766
+ verify(token: IntentToken): { valid: boolean; reason: string | null };
2767
+ revokeIntent(intentHash: string): boolean;
2768
+ purgeExpired(): void;
2769
+ getStats(): any;
2770
+ getAuditLog(): any[];
2999
2771
  }
3000
2772
 
3001
- export declare class FeedbackCollector {
3002
- constructor(config?: FeedbackCollectorOptions);
3003
- reportFalsePositive(text: string, meta?: { scanId?: string; category?: string; patternId?: string; reason?: string }): FeedbackReportResult;
3004
- reportFalseNegative(text: string, meta?: { expectedCategory?: string; severity?: string; source?: string }): FeedbackReportResult;
3005
- getPending(): any[];
3006
- process(): FeedbackProcessResult;
3007
- getStats(): FeedbackStats;
3008
- export(): any;
2773
+ export declare class IntentToken {
2774
+ intentHash: string;
2775
+ action: string;
2776
+ scope: string;
2777
+ signature: string;
2778
+ createdAt: number;
2779
+ expiresAt: number;
2780
+ used: boolean;
2781
+ isExpired(): boolean;
3009
2782
  }
3010
2783
 
3011
2784
  // =========================================================================
3012
- // v8.0 Cross-Turn Tracking & Adaptive Thresholds
2785
+ // v11: Attack Surface Mapper
3013
2786
  // =========================================================================
3014
2787
 
3015
- export interface CrossTurnAddResult {
3016
- tracked: boolean;
3017
- messageCount: number;
3018
- scanTriggered: boolean;
3019
- threats: Threat[];
3020
- crossTurnDetection: boolean;
2788
+ export declare class AttackSurfaceMapper {
2789
+ constructor(options?: { maxChainDepth?: number });
2790
+ map(config: { tools: any[]; mcpServers?: any[]; systemPrompt?: string; permissions?: any; model?: string }): {
2791
+ summary: { toolCount: number; serverCount: number; capabilityCount: number; attackPathCount: number; criticalPaths: number; overallRiskScore: number; riskLevel: string };
2792
+ capabilities: Record<string, any[]>;
2793
+ attackPaths: any[];
2794
+ promptRisks: any;
2795
+ serverRisks: any[];
2796
+ permissionGaps: any[];
2797
+ recommendations: Array<{ priority: string; action: string }>;
2798
+ };
3021
2799
  }
3022
2800
 
3023
- export interface CrossTurnScanResult {
3024
- threats: Threat[];
3025
- combinedLength: number;
3026
- messageCount: number;
3027
- }
2801
+ export declare const CAPABILITY_RISK: Record<string, number>;
2802
+ export declare const CAPABILITY_PATTERNS: Record<string, RegExp>;
3028
2803
 
3029
- export interface CrossTurnStats {
3030
- totalMessages: number;
3031
- scansTriggered: number;
3032
- crossTurnDetections: number;
3033
- individualDetections: number;
3034
- currentWindowSize: number;
3035
- maxWindowSize: number;
3036
- scanInterval: number;
3037
- }
2804
+ // =========================================================================
2805
+ // v11: Prompt Hardening
2806
+ // =========================================================================
3038
2807
 
3039
- export interface CrossTurnTrackerOptions {
3040
- windowSize?: number;
3041
- scanInterval?: number;
3042
- accumulateAll?: boolean;
3043
- sensitivity?: string;
3044
- onDetection?: (info: { threats: any[]; messages: Array<{ text: string; role: string }>; timestamp: number }) => void;
2808
+ export declare class PromptHardener {
2809
+ constructor(options?: { level?: 'minimal' | 'standard' | 'strong' | 'paranoid'; hardenSystemPrompt?: boolean; wrapUserInput?: boolean; wrapToolOutput?: boolean; wrapRAGChunks?: boolean });
2810
+ hardenSystem(systemPrompt: string): string;
2811
+ wrap(text: string, source?: 'user' | 'tool_output' | 'rag_chunk' | 'agent_message'): string;
2812
+ hardenConversation(messages: Array<{ role: string; content: string; source?: string }>): Array<{ role: string; content: string }>;
2813
+ getStats(): { hardened: number; systemPromptsHardened: number; inputsWrapped: number; toolOutputsWrapped: number };
3045
2814
  }
3046
2815
 
3047
- export declare class CrossTurnTracker {
3048
- windowSize: number;
3049
- scanInterval: number;
3050
- accumulateAll: boolean;
3051
- sensitivity: string;
3052
- constructor(config?: CrossTurnTrackerOptions);
3053
- addMessage(text: string, role?: string): CrossTurnAddResult;
3054
- scanNow(): CrossTurnScanResult;
3055
- getAccumulatedText(): string;
3056
- getMostSuspicious(): { text: string; role: string; confidence: number; threats: Threat[] } | null;
3057
- reset(): void;
3058
- getStats(): CrossTurnStats;
3059
- }
3060
-
3061
- export interface CalibrationRecordResult {
3062
- recorded: boolean;
3063
- isCalibrating: boolean;
3064
- samplesRemaining: number;
3065
- currentThreshold: number;
3066
- }
3067
-
3068
- export interface CalibrationStats {
3069
- totalSamples: number;
3070
- calibrationCount: number;
3071
- isCalibrating: boolean;
3072
- targetFPRate: number;
3073
- categories: Record<string, {
3074
- threshold: number;
3075
- totalSamples: number;
3076
- benignSamples: number;
3077
- injectionSamples: number;
3078
- feedbackSamples: number;
3079
- estimatedFPRate: number;
3080
- }>;
3081
- }
2816
+ export declare const DEFENSIVE_TEMPLATES: Record<string, { prefix: string; suffix: string }>;
2817
+ export declare const SYSTEM_PROMPT_HARDENING: Record<string, string>;
3082
2818
 
3083
- export interface CalibrationExportData {
3084
- version: number;
3085
- totalSamples: number;
3086
- calibrationCount: number;
3087
- calibrationSamples: number;
3088
- adjustInterval: number;
3089
- minConfidence: number;
3090
- maxConfidence: number;
3091
- targetFPRate: number;
3092
- categories: Record<string, { threshold: number; samples: any[] }>;
3093
- exportedAt: number;
3094
- }
3095
-
3096
- export interface AdaptiveThresholdCalibratorOptions {
3097
- calibrationSamples?: number;
3098
- adjustInterval?: number;
3099
- minConfidence?: number;
3100
- maxConfidence?: number;
3101
- targetFPRate?: number;
3102
- }
3103
-
3104
- export declare class AdaptiveThresholdCalibrator {
3105
- calibrationSamples: number;
3106
- adjustInterval: number;
3107
- minConfidence: number;
3108
- maxConfidence: number;
3109
- targetFPRate: number;
3110
- constructor(config?: AdaptiveThresholdCalibratorOptions);
3111
- record(result: { confidence: number; isInjection: boolean; category?: string }, isTruePositive?: boolean): CalibrationRecordResult;
3112
- getThreshold(category?: string): number;
3113
- shouldFlag(confidence: number, category?: string): boolean;
3114
- recalibrate(): { thresholds: Record<string, number>; samplesUsed: number };
3115
- getStats(): CalibrationStats;
3116
- export(): CalibrationExportData;
3117
- import(data: CalibrationExportData): void;
3118
- }
3119
-
3120
- // =========================================================================
3121
- // v8.0 — Adversarial Self-Training
3122
- // =========================================================================
3123
-
3124
- export interface SelfTrainingCycleResult {
3125
- generation: number;
3126
- tested: number;
3127
- detected: number;
3128
- evaded: number;
3129
- detectionRate: number;
3130
- newPatterns: string[];
3131
- evasiveExamples: string[];
3132
- duration: number;
3133
- }
3134
-
3135
- export interface SelfTrainingResult {
3136
- cycles: number;
3137
- totalTested: number;
3138
- totalEvaded: number;
3139
- patternsGenerated: string[];
3140
- improvementCurve: number[];
3141
- duration: number;
3142
- }
3143
-
3144
- export interface SelfTrainerStats {
3145
- cyclesCompleted: number;
3146
- totalTested: number;
3147
- totalDetected: number;
3148
- totalEvaded: number;
3149
- overallDetectionRate: number;
3150
- evasiveAttacksFound: number;
3151
- patternsGenerated: number;
3152
- currentPopulationSize: number;
3153
- config: {
3154
- generations: number;
3155
- populationSize: number;
3156
- mutationRate: number;
3157
- seedAttackCount: number;
3158
- };
3159
- }
2819
+ // =========================================================================
2820
+ // v11: Message Integrity
2821
+ // =========================================================================
3160
2822
 
3161
- export interface SelfTrainerOptions {
3162
- generations?: number;
3163
- populationSize?: number;
3164
- mutationRate?: number;
3165
- seedAttacks?: string[];
3166
- detector?: (text: string) => { detected: boolean; confidence: number };
3167
- onEvasion?: (info: { attack: string; generation: number; cycle: number; confidence: number }) => void;
2823
+ export declare class MessageIntegrityChain {
2824
+ constructor(options?: { signingKey?: string; algorithm?: string });
2825
+ addMessage(role: string, content: string): { index: number; signature: string };
2826
+ verifyChain(): { valid: boolean; tampered: any[] };
2827
+ verifyMessage(index: number): { valid: boolean; reason: string | null };
2828
+ detectRoleViolations(rolePolicy?: any): any[];
2829
+ export(): { chain: any[]; chainLength: number; lastSignature: string | null; exportedAt: number };
2830
+ import(data: any): { valid: boolean; imported: number; tampered: any[] };
2831
+ getStats(): any;
3168
2832
  }
3169
2833
 
3170
- export declare class SelfTrainer {
3171
- generations: number;
3172
- populationSize: number;
3173
- mutationRate: number;
3174
- seedAttacks: string[];
3175
- constructor(config?: SelfTrainerOptions);
3176
- runCycle(): SelfTrainingCycleResult;
3177
- train(cycles?: number): SelfTrainingResult;
3178
- getEvasiveAttacks(): string[];
3179
- getGeneratedPatterns(): string[];
3180
- getStats(): SelfTrainerStats;
3181
- }
2834
+ // =========================================================================
2835
+ // v11: Continuous Security Service
2836
+ // =========================================================================
3182
2837
 
3183
- export declare class MutationEngine {
3184
- mutationRate: number;
3185
- constructor(mutationRate?: number);
3186
- mutate(text: string): string;
3187
- getStrategies(): string[];
2838
+ export declare class ContinuousSecurityService {
2839
+ constructor(options: { guard: MCPGuard; hardener?: AutonomousHardener; postureScanIntervalMs?: number; hardeningIntervalMs?: number; defenseCheckIntervalMs?: number; onPostureChange?: (entry: any) => void; onAlert?: (alert: any) => void });
2840
+ start(): void;
2841
+ stop(): void;
2842
+ getStatus(): any;
2843
+ getReport(): { currentScore: number | null; currentGrade: string | null; scoreHistory: number[]; scoreTrend: string; totalPostureScans: number; totalDefenseChecks: number; totalAlerts: number; timestamp: number };
2844
+ runPostureScan(): any;
2845
+ runDefenseCheck(): any;
3188
2846
  }
3189
2847
 
3190
- export declare const SEED_ATTACKS: string[];
3191
- export declare const MUTATION_STRATEGIES: string[];
2848
+ // =========================================================================
2849
+ // v11: SOTA Benchmark
2850
+ // =========================================================================
2851
+
2852
+ export declare class SOTABenchmark {
2853
+ constructor(options?: { scanFn?: (text: string) => any; microModel?: MicroModel });
2854
+ runAll(): { aggregate: { precision: number; recall: number; f1: number; accuracy: number; fpr: number; tp: number; fp: number; tn: number; fn: number; totalSamples: number }; benchmarks: Record<string, any>; functional: any; comparison: { sentinel_f1: number; sentinel_accuracy: number; agentshield_f1: number; agentshield_accuracy: number; delta_f1: number; delta_accuracy: number }; timestamp: number };
2855
+ runBIPIA(): any;
2856
+ runHackAPrompt(): any;
2857
+ runMCPTox(): any;
2858
+ runMultilingual(): any;
2859
+ runStealth(): any;
2860
+ runFunctional(): any;
2861
+ toMarkdown(results: any): string;
2862
+ }