@elizaos/plugin-trust 1.2.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.
@@ -0,0 +1,862 @@
1
+ import { UUID, Role, Service, IAgentRuntime, Action as Action$1, WorldSettings, Provider, Evaluator, Plugin } from '@elizaos/core';
2
+
3
+ /**
4
+ * Core trust dimensions based on interpersonal trust theory
5
+ */
6
+ interface TrustDimensions {
7
+ /** Consistency in behavior and promise keeping (0-100) */
8
+ reliability: number;
9
+ /** Ability to perform tasks and provide value (0-100) */
10
+ competence: number;
11
+ /** Adherence to ethical principles (0-100) */
12
+ integrity: number;
13
+ /** Good intentions towards others (0-100) */
14
+ benevolence: number;
15
+ /** Open and honest communication (0-100) */
16
+ transparency: number;
17
+ }
18
+ /**
19
+ * Evidence types that impact trust scores
20
+ */
21
+ declare enum TrustEvidenceType {
22
+ PROMISE_KEPT = "PROMISE_KEPT",
23
+ HELPFUL_ACTION = "HELPFUL_ACTION",
24
+ CONSISTENT_BEHAVIOR = "CONSISTENT_BEHAVIOR",
25
+ VERIFIED_IDENTITY = "VERIFIED_IDENTITY",
26
+ COMMUNITY_CONTRIBUTION = "COMMUNITY_CONTRIBUTION",
27
+ SUCCESSFUL_TRANSACTION = "SUCCESSFUL_TRANSACTION",
28
+ PROMISE_BROKEN = "PROMISE_BROKEN",
29
+ HARMFUL_ACTION = "HARMFUL_ACTION",
30
+ INCONSISTENT_BEHAVIOR = "INCONSISTENT_BEHAVIOR",
31
+ SUSPICIOUS_ACTIVITY = "SUSPICIOUS_ACTIVITY",
32
+ FAILED_VERIFICATION = "FAILED_VERIFICATION",
33
+ SPAM_BEHAVIOR = "SPAM_BEHAVIOR",
34
+ SECURITY_VIOLATION = "SECURITY_VIOLATION",
35
+ IDENTITY_CHANGE = "IDENTITY_CHANGE",
36
+ ROLE_CHANGE = "ROLE_CHANGE",
37
+ CONTEXT_SWITCH = "CONTEXT_SWITCH"
38
+ }
39
+ /**
40
+ * A piece of evidence that affects trust
41
+ */
42
+ interface TrustEvidence {
43
+ type: TrustEvidenceType;
44
+ timestamp: number;
45
+ /** Impact on trust score (-100 to +100) */
46
+ impact: number;
47
+ /** Weight/importance of this evidence (0-1) */
48
+ weight: number;
49
+ /** Optional description of the evidence */
50
+ description: string;
51
+ /** Entity who reported/created this evidence */
52
+ reportedBy: UUID;
53
+ /** Whether this evidence has been verified */
54
+ verified: boolean;
55
+ /** Context where this evidence occurred */
56
+ context: TrustContext;
57
+ targetEntityId: UUID;
58
+ evaluatorId: UUID;
59
+ metadata?: any;
60
+ }
61
+ /**
62
+ * Trust profile for an entity
63
+ */
64
+ interface TrustProfile {
65
+ /** Entity this profile belongs to */
66
+ entityId: UUID;
67
+ /** Core trust dimensions */
68
+ dimensions: TrustDimensions;
69
+ /** Overall trust score (0-100) */
70
+ overallTrust: number;
71
+ /** Confidence in the trust score (0-1) */
72
+ confidence: number;
73
+ /** Number of interactions used to calculate trust */
74
+ interactionCount: number;
75
+ /** Evidence supporting this trust profile */
76
+ evidence: TrustEvidence[];
77
+ /** When this profile was last calculated */
78
+ lastCalculated: number;
79
+ /** Method used to calculate trust */
80
+ calculationMethod: string;
81
+ /** Trust trend over time */
82
+ trend: {
83
+ direction: 'increasing' | 'decreasing' | 'stable';
84
+ changeRate: number;
85
+ lastChangeAt: number;
86
+ };
87
+ evaluatorId: UUID;
88
+ }
89
+ /**
90
+ * Context for trust calculations
91
+ */
92
+ interface TrustContext {
93
+ /** Who is evaluating trust */
94
+ evaluatorId: UUID;
95
+ /** Specific context for evaluation */
96
+ worldId?: UUID;
97
+ roomId?: UUID;
98
+ platform?: string;
99
+ /** Type of action being considered */
100
+ action?: string;
101
+ /** Time window for evidence consideration */
102
+ timeWindow?: {
103
+ start: number;
104
+ end: number;
105
+ };
106
+ }
107
+ /**
108
+ * Result of a trust-based decision
109
+ */
110
+ interface TrustDecision {
111
+ allowed: boolean;
112
+ trustScore: number;
113
+ requiredScore: number;
114
+ /** Which dimensions were evaluated */
115
+ dimensionsChecked: Partial<TrustDimensions>;
116
+ /** Reason for the decision */
117
+ reason: string;
118
+ /** Suggestions for building trust if denied */
119
+ suggestions?: string[];
120
+ }
121
+ /**
122
+ * Configuration for trust requirements
123
+ */
124
+ interface TrustRequirements {
125
+ /** Minimum overall trust score */
126
+ minimumTrust: number;
127
+ /** Required dimension scores */
128
+ dimensions?: {
129
+ reliability?: number;
130
+ competence?: number;
131
+ integrity?: number;
132
+ benevolence?: number;
133
+ transparency?: number;
134
+ };
135
+ /** Required evidence types */
136
+ requiredEvidence?: TrustEvidenceType[];
137
+ /** Minimum interaction count */
138
+ minimumInteractions?: number;
139
+ /** Required confidence level */
140
+ minimumConfidence?: number;
141
+ }
142
+ /**
143
+ * Trust interaction to be recorded
144
+ */
145
+ interface TrustInteraction {
146
+ sourceEntityId: UUID;
147
+ targetEntityId: UUID;
148
+ type: TrustEvidenceType;
149
+ timestamp: number;
150
+ impact: number;
151
+ details?: {
152
+ description?: string;
153
+ messageId?: UUID;
154
+ roomId?: UUID;
155
+ [key: string]: any;
156
+ };
157
+ context?: TrustContext;
158
+ }
159
+ /**
160
+ * Trust calculation configuration
161
+ */
162
+ interface TrustCalculationConfig {
163
+ /** How much recent evidence is weighted vs old */
164
+ recencyBias: number;
165
+ /** How fast evidence decays over time */
166
+ evidenceDecayRate: number;
167
+ /** Minimum evidence required for confidence */
168
+ minimumEvidenceCount: number;
169
+ /** How much to weight verified vs unverified evidence */
170
+ verificationMultiplier: number;
171
+ /** Dimension weights for overall score */
172
+ dimensionWeights: {
173
+ reliability: number;
174
+ competence: number;
175
+ integrity: number;
176
+ benevolence: number;
177
+ transparency: number;
178
+ };
179
+ }
180
+
181
+ /**
182
+ * Context for permission evaluation
183
+ */
184
+ interface PermissionContext {
185
+ worldId?: UUID;
186
+ roomId?: UUID;
187
+ platform?: string;
188
+ serverId?: string;
189
+ channelId?: string;
190
+ timestamp?: number;
191
+ }
192
+ /**
193
+ * Permission that can be granted
194
+ */
195
+ interface Permission {
196
+ action: string;
197
+ resource: string;
198
+ context?: PermissionContext;
199
+ constraints?: PermissionConstraint[];
200
+ }
201
+ /**
202
+ * Constraint on a permission
203
+ */
204
+ interface PermissionConstraint {
205
+ type: 'time_window' | 'usage_limit' | 'trust_required' | 'role_required' | 'custom';
206
+ value: any;
207
+ description?: string;
208
+ }
209
+ /**
210
+ * Result of a permission check
211
+ */
212
+ interface PermissionDecision {
213
+ allowed: boolean;
214
+ /** How the decision was made */
215
+ method: 'role-based' | 'trust-based' | 'delegated' | 'elevated' | 'denied';
216
+ /** Which role or trust level granted access */
217
+ grantedBy?: {
218
+ type: 'role' | 'trust';
219
+ value: Role | number;
220
+ context?: PermissionContext;
221
+ };
222
+ /** Reason for the decision */
223
+ reason: string;
224
+ /** Suggestions if denied */
225
+ suggestions?: string[];
226
+ /** Conditions that must be met */
227
+ conditions?: string[];
228
+ /** Audit trail */
229
+ auditInfo?: {
230
+ decidedAt: number;
231
+ evaluatorId: UUID;
232
+ evidence?: any[];
233
+ };
234
+ }
235
+ /**
236
+ * Request for elevated permissions
237
+ */
238
+ interface ElevationRequest {
239
+ entityId: UUID;
240
+ requestedPermission: Permission;
241
+ justification: string;
242
+ duration?: number;
243
+ context: PermissionContext;
244
+ }
245
+ /**
246
+ * Result of an elevation request
247
+ */
248
+ interface ElevationResult {
249
+ granted: boolean;
250
+ elevationId?: UUID;
251
+ expiresAt?: number;
252
+ conditions?: string[];
253
+ reason?: string;
254
+ trustDeficit?: number;
255
+ suggestions?: string[];
256
+ }
257
+ /**
258
+ * Access request for evaluation
259
+ */
260
+ interface AccessRequest {
261
+ entityId: UUID;
262
+ action: string;
263
+ resource: string;
264
+ context: PermissionContext;
265
+ metadata?: Record<string, any>;
266
+ }
267
+ /**
268
+ * Complete access decision with all details
269
+ */
270
+ interface AccessDecision extends PermissionDecision {
271
+ request: AccessRequest;
272
+ evaluatedAt: number;
273
+ ttl?: number;
274
+ securityChecks?: {
275
+ promptInjection: boolean;
276
+ socialEngineering: boolean;
277
+ anomalyDetection: boolean;
278
+ };
279
+ }
280
+
281
+ interface SecurityContext extends PermissionContext {
282
+ entityId?: UUID;
283
+ requestedAction?: string;
284
+ messageHistory?: string[];
285
+ }
286
+ interface SecurityCheck {
287
+ detected: boolean;
288
+ confidence: number;
289
+ type: 'prompt_injection' | 'social_engineering' | 'anomaly' | 'none';
290
+ severity: 'low' | 'medium' | 'high' | 'critical';
291
+ action: 'block' | 'require_verification' | 'allow' | 'log_only';
292
+ details?: string;
293
+ }
294
+ interface ThreatAssessment extends SecurityCheck {
295
+ recommendation?: string;
296
+ }
297
+ interface SecurityEvent {
298
+ id?: UUID;
299
+ type: SecurityEventType;
300
+ entityId: UUID;
301
+ severity: 'low' | 'medium' | 'high' | 'critical';
302
+ context: PermissionContext;
303
+ details: any;
304
+ timestamp?: number;
305
+ handled?: boolean;
306
+ }
307
+ declare enum SecurityEventType {
308
+ PROMPT_INJECTION_ATTEMPT = "prompt_injection_attempt",
309
+ SOCIAL_ENGINEERING_ATTEMPT = "social_engineering_attempt",
310
+ PRIVILEGE_ESCALATION_ATTEMPT = "privilege_escalation_attempt",
311
+ ANOMALOUS_REQUEST = "anomalous_request",
312
+ TRUST_MANIPULATION = "trust_manipulation",
313
+ IDENTITY_SPOOFING = "identity_spoofing",
314
+ MULTI_ACCOUNT_ABUSE = "multi_account_abuse",
315
+ CREDENTIAL_THEFT_ATTEMPT = "credential_theft_attempt",
316
+ PHISHING_ATTEMPT = "phishing_attempt",
317
+ IMPERSONATION_ATTEMPT = "impersonation_attempt",
318
+ COORDINATED_ATTACK = "coordinated_attack",
319
+ MALICIOUS_LINK_CAMPAIGN = "malicious_link_campaign"
320
+ }
321
+ interface PatternDetection {
322
+ type: 'multi_account' | 'phishing' | 'impersonation' | 'coordination' | 'credential_theft';
323
+ confidence: number;
324
+ evidence: string[];
325
+ relatedEntities?: UUID[];
326
+ recommendation: string;
327
+ }
328
+ interface MultiAccountDetection extends PatternDetection {
329
+ type: 'multi_account';
330
+ primaryAccount: UUID;
331
+ linkedAccounts: UUID[];
332
+ linkageEvidence: {
333
+ typingPattern: number;
334
+ timingPattern: number;
335
+ vocabularyPattern: number;
336
+ behaviorPattern: number;
337
+ };
338
+ }
339
+ interface PhishingDetection extends PatternDetection {
340
+ type: 'phishing';
341
+ maliciousLinks?: string[];
342
+ targetedEntities: UUID[];
343
+ campaignId?: string;
344
+ }
345
+ interface ImpersonationDetection extends PatternDetection {
346
+ type: 'impersonation';
347
+ impersonator: string;
348
+ impersonated: string;
349
+ visualSimilarity: number;
350
+ timingCoincidence: number;
351
+ }
352
+ interface CoordinationDetection extends PatternDetection {
353
+ type: 'coordination';
354
+ coordinatedEntities: UUID[];
355
+ timeWindow: number;
356
+ correlationScore: number;
357
+ }
358
+ interface CredentialTheftDetection extends PatternDetection {
359
+ type: 'credential_theft';
360
+ sensitivePatterns: string[];
361
+ attemptedTheft: string[];
362
+ potentialVictims: UUID[];
363
+ }
364
+ interface BehavioralProfile {
365
+ entityId: UUID;
366
+ typingSpeed: number;
367
+ vocabularyComplexity: number;
368
+ messageLength: {
369
+ mean: number;
370
+ stdDev: number;
371
+ };
372
+ activeHours: number[];
373
+ commonPhrases: string[];
374
+ interactionPatterns: Map<string, number>;
375
+ }
376
+ interface Message {
377
+ id: UUID;
378
+ entityId: UUID;
379
+ content: string;
380
+ timestamp: number;
381
+ roomId?: UUID;
382
+ replyTo?: UUID;
383
+ }
384
+ interface Action {
385
+ id: UUID;
386
+ entityId: UUID;
387
+ type: string;
388
+ timestamp: number;
389
+ target?: string;
390
+ result?: 'success' | 'failure';
391
+ }
392
+
393
+ interface CredentialThreatDetection {
394
+ detected: boolean;
395
+ confidence: number;
396
+ threatType: 'credential_request' | 'phishing' | 'social_engineering' | 'none';
397
+ sensitiveData: string[];
398
+ recommendation: string;
399
+ }
400
+ declare class CredentialProtector extends Service {
401
+ static serviceType: "credential-protector";
402
+ capabilityDescription: string;
403
+ private securityModule;
404
+ private readonly SENSITIVE_PATTERNS;
405
+ private readonly THEFT_REQUEST_PATTERNS;
406
+ private readonly LEGITIMATE_CONTEXTS;
407
+ constructor();
408
+ initialize(runtime: IAgentRuntime, securityModule: any): Promise<void>;
409
+ stop(): Promise<void>;
410
+ static start(runtime: IAgentRuntime): Promise<Service>;
411
+ /**
412
+ * Scan message for credential theft attempts
413
+ */
414
+ scanForCredentialTheft(message: string, entityId: UUID, context: SecurityContext): Promise<CredentialThreatDetection>;
415
+ /**
416
+ * Protect sensitive data by redacting it
417
+ */
418
+ protectSensitiveData(content: string): Promise<string>;
419
+ /**
420
+ * Alert potential victims of credential theft
421
+ */
422
+ alertPotentialVictims(threatActor: UUID, victims: UUID[], threatDetails: CredentialThreatDetection): Promise<void>;
423
+ /**
424
+ * Analyze a conversation for credential theft patterns
425
+ */
426
+ analyzeConversation(messages: Array<{
427
+ entityId: UUID;
428
+ content: string;
429
+ timestamp: number;
430
+ }>, context: SecurityContext): Promise<{
431
+ overallThreat: number;
432
+ suspiciousEntities: UUID[];
433
+ recommendations: string[];
434
+ }>;
435
+ /**
436
+ * Private helper methods
437
+ */
438
+ private detectSensitiveData;
439
+ private isLegitimateContext;
440
+ private hasPhishingIndicators;
441
+ private logThreatEvent;
442
+ }
443
+
444
+ declare class TrustEngine extends Service {
445
+ static serviceType: "trust-engine";
446
+ capabilityDescription: string;
447
+ private trustConfig;
448
+ private profileCache;
449
+ private cacheTimeout;
450
+ private trustProfiles;
451
+ private interactions;
452
+ constructor(config?: Partial<TrustCalculationConfig>);
453
+ initialize(runtime: IAgentRuntime): Promise<void>;
454
+ stop(): Promise<void>;
455
+ static start(runtime: IAgentRuntime): Promise<Service>;
456
+ /**
457
+ * Calculate trust profile for an entity
458
+ */
459
+ calculateTrust(subjectId: UUID, context: TrustContext): Promise<TrustProfile>;
460
+ /**
461
+ * Records a trust interaction
462
+ */
463
+ recordInteraction(interaction: TrustInteraction): Promise<void>;
464
+ /**
465
+ * Evaluate if an action is allowed based on trust
466
+ */
467
+ evaluateTrustDecision(entityId: UUID, requirements: TrustRequirements, context: TrustContext): Promise<TrustDecision>;
468
+ /**
469
+ * Calculate trust dimensions from evidence
470
+ */
471
+ private calculateDimensions;
472
+ /**
473
+ * Calculate overall trust score from dimensions
474
+ */
475
+ private calculateOverallTrust;
476
+ /**
477
+ * Calculate confidence based on evidence quantity and consistency
478
+ */
479
+ private calculateConfidence;
480
+ /**
481
+ * Calculate age weight for evidence based on recency
482
+ */
483
+ private calculateAgeWeight;
484
+ /**
485
+ * Analyze trust trend over time
486
+ */
487
+ private analyzeTrend;
488
+ /**
489
+ * Load evidence from storage
490
+ */
491
+ private loadEvidence;
492
+ /**
493
+ * Save trust profile to storage
494
+ */
495
+ private saveTrustProfile;
496
+ /**
497
+ * Save evidence to storage
498
+ */
499
+ private saveEvidence;
500
+ /**
501
+ * Clear cache for an entity
502
+ */
503
+ private clearCacheForEntity;
504
+ /**
505
+ * Generate suggestions for building trust
506
+ */
507
+ private generateTrustBuildingSuggestions;
508
+ /**
509
+ * Generate suggestions for improving specific dimensions
510
+ */
511
+ private generateDimensionSuggestions;
512
+ /**
513
+ * Evaluates trust for an entity (simplified API for actions)
514
+ */
515
+ evaluateTrust(entityId: UUID, evaluatorId: UUID, context?: Partial<TrustContext>): Promise<TrustProfile>;
516
+ /**
517
+ * Get recent trust interactions for an entity
518
+ */
519
+ getRecentInteractions(entityId: UUID, limit?: number): Promise<TrustInteraction[]>;
520
+ /**
521
+ * Gets recent security incidents for a room
522
+ */
523
+ getRecentSecurityIncidents(roomId: UUID, hours?: number): Promise<any[]>;
524
+ /**
525
+ * Assesses the current threat level for a room
526
+ */
527
+ assessThreatLevel(roomId: UUID): Promise<number>;
528
+ /**
529
+ * Analyzes a message for security concerns
530
+ */
531
+ analyzeMessage(text: string, entityId: UUID, context: any): Promise<any>;
532
+ /**
533
+ * Gets security recommendations based on threat level
534
+ */
535
+ getSecurityRecommendations(threatLevel: number): string[];
536
+ }
537
+
538
+ declare class SecurityModule {
539
+ private runtime;
540
+ private trustEngine;
541
+ private behavioralProfiles;
542
+ private messageHistory;
543
+ private actionHistory;
544
+ private readonly INJECTION_PATTERNS;
545
+ private readonly URGENCY_KEYWORDS;
546
+ private readonly AUTHORITY_KEYWORDS;
547
+ private readonly INTIMIDATION_KEYWORDS;
548
+ private readonly CREDENTIAL_PATTERNS;
549
+ private readonly PHISHING_INDICATORS;
550
+ constructor();
551
+ /**
552
+ * Initialize the security module
553
+ */
554
+ initialize(runtime: IAgentRuntime, trustEngine: any): Promise<void>;
555
+ /**
556
+ * Detect prompt injection attempts
557
+ */
558
+ detectPromptInjection(message: string, context: SecurityContext): Promise<SecurityCheck>;
559
+ /**
560
+ * Detect social engineering attempts
561
+ */
562
+ detectSocialEngineering(message: string, context: SecurityContext): Promise<SecurityCheck>;
563
+ /**
564
+ * Assess overall threat level
565
+ */
566
+ assessThreatLevel(context: SecurityContext): Promise<ThreatAssessment>;
567
+ /**
568
+ * Get recent security incidents
569
+ */
570
+ getRecentSecurityIncidents(roomId?: UUID, hours?: number): Promise<SecurityEvent[]>;
571
+ /**
572
+ * Log security event (now public)
573
+ */
574
+ logSecurityEvent(event: Omit<SecurityEvent, 'id' | 'timestamp' | 'handled'>): Promise<void>;
575
+ /**
576
+ * Analyze social engineering factors
577
+ */
578
+ private analyzeSocialEngineeringFactors;
579
+ /**
580
+ * Calculate keyword score
581
+ */
582
+ private calculateKeywordScore;
583
+ /**
584
+ * Detect liking manipulation
585
+ */
586
+ private detectLikingManipulation;
587
+ /**
588
+ * Detect reciprocity manipulation
589
+ */
590
+ private detectReciprocityManipulation;
591
+ /**
592
+ * Detect commitment manipulation
593
+ */
594
+ private detectCommitmentManipulation;
595
+ /**
596
+ * Detect social proof manipulation
597
+ */
598
+ private detectSocialProofManipulation;
599
+ /**
600
+ * Detect scarcity manipulation
601
+ */
602
+ private detectScarcityManipulation;
603
+ /**
604
+ * Calculate overall social engineering risk
605
+ */
606
+ private calculateSocialEngineeringRisk;
607
+ /**
608
+ * Analyze semantic patterns
609
+ */
610
+ private analyzeSemantics;
611
+ /**
612
+ * Log trust impact from security events
613
+ */
614
+ logTrustImpact(entityId: UUID, event: SecurityEventType, impact: number, context?: {
615
+ worldId?: UUID;
616
+ }): Promise<void>;
617
+ /**
618
+ * Maps security events to trust evidence types
619
+ */
620
+ private mapSecurityEventToTrustEvidence;
621
+ /**
622
+ * Enhanced pattern detection capabilities
623
+ */
624
+ /**
625
+ * Detect multi-account manipulation
626
+ */
627
+ detectMultiAccountPattern(entities: UUID[], timeWindow?: number): Promise<MultiAccountDetection | null>;
628
+ /**
629
+ * Detect credential theft attempts
630
+ */
631
+ detectCredentialTheft(message: string, entityId: UUID, context: SecurityContext): Promise<CredentialTheftDetection | null>;
632
+ /**
633
+ * Detect phishing campaigns
634
+ */
635
+ detectPhishing(messages: Message[], entityId: UUID): Promise<PhishingDetection | null>;
636
+ /**
637
+ * Detect impersonation attempts
638
+ */
639
+ detectImpersonation(username: string, existingUsers: string[]): Promise<ImpersonationDetection | null>;
640
+ /**
641
+ * Detect coordinated activity
642
+ */
643
+ detectCoordinatedActivity(entities: UUID[], timeWindow?: number): Promise<CoordinationDetection | null>;
644
+ /**
645
+ * Helper methods for pattern detection
646
+ */
647
+ private getBehavioralProfiles;
648
+ private buildBehavioralProfile;
649
+ private calculateProfileSimilarities;
650
+ private calculateVariance;
651
+ private checkSynchronizedActions;
652
+ private getRecentActions;
653
+ private detectSuspiciousLinks;
654
+ private extractLinks;
655
+ private calculateStringSimilarity;
656
+ private calculateVisualSimilarity;
657
+ private levenshteinDistance;
658
+ /**
659
+ * Store message for analysis
660
+ */
661
+ storeMessage(message: Message): Promise<void>;
662
+ /**
663
+ * Store action for analysis
664
+ */
665
+ storeAction(action: Action): Promise<void>;
666
+ }
667
+
668
+ declare class ContextualPermissionSystem {
669
+ private runtime;
670
+ private trustEngine;
671
+ private securityModule;
672
+ private permissionCache;
673
+ private contextualRoles;
674
+ private delegations;
675
+ private elevations;
676
+ constructor();
677
+ initialize(runtime: IAgentRuntime, trustEngine: TrustEngine, securityModule: SecurityModule): Promise<void>;
678
+ hasPermission(entityId: UUID, permission: Permission, context: PermissionContext): Promise<boolean>;
679
+ checkAccess(request: AccessRequest): Promise<AccessDecision>;
680
+ private checkRolePermissions;
681
+ private checkTrustPermissions;
682
+ private checkDelegatedPermissions;
683
+ requestElevation(request: ElevationRequest): Promise<AccessDecision>;
684
+ private createDecision;
685
+ private roleHasPermission;
686
+ private getEntityRoles;
687
+ private generateDenialReason;
688
+ }
689
+
690
+ declare class LLMEvaluator extends Service {
691
+ static serviceType: "llm-evaluator";
692
+ capabilityDescription: string;
693
+ initialize(runtime: IAgentRuntime): Promise<void>;
694
+ stop(): Promise<void>;
695
+ /**
696
+ * Evaluate potential security threats using LLM
697
+ */
698
+ evaluateSecurityThreat(message: string, context: SecurityContext, history?: string[]): Promise<SecurityCheck>;
699
+ /**
700
+ * Evaluate trust-related decisions using LLM
701
+ */
702
+ evaluateTrustAction(action: string, actor: UUID, context: TrustContext, trustScore: number): Promise<{
703
+ allowed: boolean;
704
+ confidence: number;
705
+ reasoning: string;
706
+ suggestions?: string[];
707
+ }>;
708
+ /**
709
+ * Analyze behavioral patterns using LLM
710
+ */
711
+ analyzeBehavior(messages: string[], actions: any[], entityId: UUID): Promise<{
712
+ patterns: string[];
713
+ anomalies: string[];
714
+ riskScore: number;
715
+ personality: string;
716
+ }>;
717
+ private determineAction;
718
+ static start(runtime: IAgentRuntime): Promise<Service>;
719
+ }
720
+
721
+ /**
722
+ * Represents an action to update the role of a user within a server.
723
+ * @typedef {Object} Action
724
+ * @property {string} name - The name of the action.
725
+ * @property {string[]} similes - The similar actions that can be performed.
726
+ * @property {string} description - A description of the action and its purpose.
727
+ * @property {Function} validate - A function to validate the action before execution.
728
+ * @property {Function} handler - A function to handle the execution of the action.
729
+ * @property {ActionExample[][]} examples - Examples demonstrating how the action can be used.
730
+ */
731
+ declare const updateRoleAction: Action$1;
732
+
733
+ /**
734
+ * Gets settings state from world metadata
735
+ */
736
+ /**
737
+ * Retrieves the settings for a specific world from the database.
738
+ * @param {IAgentRuntime} runtime - The Agent Runtime instance.
739
+ * @param {string} serverId - The ID of the server.
740
+ * @returns {Promise<WorldSettings | null>} The settings of the world, or null if not found.
741
+ */
742
+ declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Promise<WorldSettings | null>;
743
+ /**
744
+ * Updates settings state in world metadata
745
+ */
746
+ declare function updateWorldSettings(runtime: IAgentRuntime, serverId: string, worldSettings: WorldSettings): Promise<boolean>;
747
+ /**
748
+ * Enhanced settings action with improved state management and logging
749
+ * Updated to use world metadata instead of cache
750
+ */
751
+ declare const updateSettingsAction: Action$1;
752
+
753
+ declare const recordTrustInteractionAction: Action$1;
754
+
755
+ declare const evaluateTrustAction: Action$1;
756
+
757
+ declare const requestElevationAction: Action$1;
758
+
759
+ /**
760
+ * Role provider that retrieves roles in the server based on the provided runtime, message, and state.
761
+ * * @type { Provider }
762
+ * @property { string } name - The name of the role provider.
763
+ * @property { string } description - A brief description of the role provider.
764
+ * @property { Function } get - Asynchronous function that retrieves and processes roles in the server.
765
+ * @param { IAgentRuntime } runtime - The agent runtime object.
766
+ * @param { Memory } message - The message memory object.
767
+ * @param { State } state - The state object.
768
+ * @returns {Promise<ProviderResult>} The result containing roles data, values, and text.
769
+ */
770
+ /**
771
+ * A provider for retrieving and formatting the role hierarchy in a server.
772
+ * @type {Provider}
773
+ */
774
+ declare const roleProvider: Provider;
775
+
776
+ /**
777
+ * Creates an settings provider with the given configuration
778
+ * Updated to use world metadata instead of cache
779
+ */
780
+ declare const settingsProvider: Provider;
781
+
782
+ declare const trustProfileProvider: Provider;
783
+
784
+ declare const securityStatusProvider: Provider;
785
+
786
+ declare const reflectionEvaluator: Evaluator;
787
+
788
+ declare const trustChangeEvaluator: Evaluator;
789
+
790
+ type TrustEngineService = InstanceType<typeof TrustEngine>;
791
+ type SecurityModuleService = InstanceType<typeof SecurityModule>;
792
+ type ContextualPermissionSystemService = InstanceType<typeof ContextualPermissionSystem>;
793
+ type CredentialProtectorService = InstanceType<typeof CredentialProtector>;
794
+ type LLMEvaluatorService = InstanceType<typeof LLMEvaluator>;
795
+
796
+ declare class TrustEngineServiceWrapper extends Service {
797
+ static readonly serviceType = "trust-engine";
798
+ readonly capabilityDescription = "Multi-dimensional trust scoring and evidence-based trust evaluation";
799
+ trustEngine: TrustEngine;
800
+ static start(runtime: IAgentRuntime): Promise<Service>;
801
+ stop(): Promise<void>;
802
+ calculateTrust(entityId: UUID, context: TrustContext): Promise<TrustProfile>;
803
+ getRecentInteractions(entityId: UUID, limit?: number): Promise<TrustInteraction[]>;
804
+ evaluateTrustDecision(entityId: UUID, requirements: TrustRequirements, context: TrustContext): Promise<TrustDecision>;
805
+ }
806
+ declare class SecurityModuleServiceWrapper extends Service {
807
+ static readonly serviceType = "security-module";
808
+ readonly capabilityDescription = "Security threat detection and trust-based security analysis";
809
+ securityModule: SecurityModule;
810
+ static start(runtime: IAgentRuntime): Promise<Service>;
811
+ stop(): Promise<void>;
812
+ detectPromptInjection(content: string, context: SecurityContext): Promise<SecurityCheck>;
813
+ assessThreatLevel(context: SecurityContext): Promise<ThreatAssessment>;
814
+ logTrustImpact(entityId: UUID, event: SecurityEventType, impact: number, context?: Partial<TrustContext>): Promise<void>;
815
+ storeMessage(message: any): Promise<void>;
816
+ storeAction(action: any): Promise<void>;
817
+ detectMultiAccountPattern(entities: UUID[], timeWindow?: number): Promise<any>;
818
+ detectImpersonation(username: string, existingUsers: string[]): Promise<any>;
819
+ detectPhishing(messages: any[], entityId: UUID): Promise<any>;
820
+ }
821
+ declare class CredentialProtectorServiceWrapper extends Service {
822
+ static readonly serviceType = "credential-protector";
823
+ readonly capabilityDescription = "Detects and prevents credential theft attempts, protects sensitive data";
824
+ credentialProtector: CredentialProtector;
825
+ static start(runtime: IAgentRuntime): Promise<Service>;
826
+ stop(): Promise<void>;
827
+ scanForCredentialTheft(message: string, entityId: UUID, context: SecurityContext): Promise<CredentialThreatDetection>;
828
+ protectSensitiveData(content: string): Promise<string>;
829
+ alertPotentialVictims(threatActor: UUID, victims: UUID[], threatDetails: any): Promise<void>;
830
+ }
831
+ declare class ContextualPermissionSystemServiceWrapper extends Service {
832
+ static readonly serviceType = "contextual-permissions";
833
+ readonly capabilityDescription = "Context-aware permission management with trust-based access control";
834
+ permissionSystem: ContextualPermissionSystem;
835
+ static start(runtime: IAgentRuntime): Promise<Service>;
836
+ stop(): Promise<void>;
837
+ checkAccess(request: AccessRequest): Promise<AccessDecision>;
838
+ hasPermission(entityId: UUID, permission: Permission, context: PermissionContext): Promise<boolean>;
839
+ }
840
+ declare class LLMEvaluatorServiceWrapper extends Service {
841
+ static readonly serviceType = "llm-evaluator";
842
+ readonly capabilityDescription = "LLM-based evaluation for trust and security decisions";
843
+ llmEvaluator: LLMEvaluator;
844
+ static start(runtime: IAgentRuntime): Promise<Service>;
845
+ stop(): Promise<void>;
846
+ evaluateSecurityThreat(message: string, context: SecurityContext, history?: string[]): Promise<SecurityCheck>;
847
+ evaluateTrustAction(action: string, actor: UUID, context: TrustContext, trustScore: number): Promise<{
848
+ allowed: boolean;
849
+ confidence: number;
850
+ reasoning: string;
851
+ suggestions?: string[];
852
+ }>;
853
+ analyzeBehavior(messages: string[], actions: any[], entityId: UUID): Promise<{
854
+ patterns: string[];
855
+ anomalies: string[];
856
+ riskScore: number;
857
+ personality: string;
858
+ }>;
859
+ }
860
+ declare const trustPlugin: Plugin;
861
+
862
+ export { type AccessDecision, type AccessRequest, type Action, type BehavioralProfile, ContextualPermissionSystem, type ContextualPermissionSystemService, ContextualPermissionSystemServiceWrapper, type CoordinationDetection, CredentialProtector, type CredentialProtectorService, CredentialProtectorServiceWrapper, type CredentialTheftDetection, type ElevationRequest, type ElevationResult, type ImpersonationDetection, LLMEvaluator, type LLMEvaluatorService, LLMEvaluatorServiceWrapper, type Message, type MultiAccountDetection, type PatternDetection, type Permission, type PermissionContext, type PermissionDecision, type PhishingDetection, type SecurityCheck, type SecurityContext, type SecurityEvent, SecurityEventType, SecurityModule, type SecurityModuleService, SecurityModuleServiceWrapper, type ThreatAssessment, type TrustCalculationConfig, type TrustContext, type TrustDecision, type TrustDimensions, TrustEngine, type TrustEngineService, TrustEngineServiceWrapper, type TrustEvidence, TrustEvidenceType, type TrustInteraction, type TrustProfile, type TrustRequirements, trustPlugin as default, evaluateTrustAction, getWorldSettings, recordTrustInteractionAction, reflectionEvaluator, requestElevationAction, roleProvider, securityStatusProvider, settingsProvider, trustChangeEvaluator, trustProfileProvider, updateRoleAction, updateSettingsAction, updateWorldSettings };