@elizaos/plugin-trust 1.2.1 → 2.0.0-alpha.3
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/dist/actions/evaluateTrust.d.ts +3 -0
- package/dist/actions/evaluateTrust.d.ts.map +1 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/recordTrustInteraction.d.ts +3 -0
- package/dist/actions/recordTrustInteraction.d.ts.map +1 -0
- package/dist/actions/requestElevation.d.ts +3 -0
- package/dist/actions/requestElevation.d.ts.map +1 -0
- package/dist/actions/roles.d.ts +13 -0
- package/dist/actions/roles.d.ts.map +1 -0
- package/dist/actions/settings.d.ts +21 -0
- package/dist/actions/settings.d.ts.map +1 -0
- package/dist/evaluators/index.d.ts +3 -0
- package/dist/evaluators/index.d.ts.map +1 -0
- package/dist/evaluators/reflection.d.ts +3 -0
- package/dist/evaluators/reflection.d.ts.map +1 -0
- package/dist/evaluators/trustChangeEvaluator.d.ts +3 -0
- package/dist/evaluators/trustChangeEvaluator.d.ts.map +1 -0
- package/dist/framework/TrustAwarePlugin.d.ts +60 -0
- package/dist/framework/TrustAwarePlugin.d.ts.map +1 -0
- package/dist/index.d.ts +42 -809
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18128 -4475
- package/dist/index.js.map +103 -1
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/roles.d.ts +19 -0
- package/dist/providers/roles.d.ts.map +1 -0
- package/dist/providers/securityStatus.d.ts +3 -0
- package/dist/providers/securityStatus.d.ts.map +1 -0
- package/dist/providers/settings.d.ts +7 -0
- package/dist/providers/settings.d.ts.map +1 -0
- package/dist/providers/trustProfile.d.ts +3 -0
- package/dist/providers/trustProfile.d.ts.map +1 -0
- package/dist/schema.d.ts +1169 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/services/ContextualPermissionSystem.d.ts +40 -0
- package/dist/services/ContextualPermissionSystem.d.ts.map +1 -0
- package/dist/services/CredentialProtector.d.ts +53 -0
- package/dist/services/CredentialProtector.d.ts.map +1 -0
- package/dist/services/LLMEvaluator.d.ts +44 -0
- package/dist/services/LLMEvaluator.d.ts.map +1 -0
- package/dist/services/SecurityModule.d.ts +137 -0
- package/dist/services/SecurityModule.d.ts.map +1 -0
- package/dist/services/SecurityStore.d.ts +48 -0
- package/dist/services/SecurityStore.d.ts.map +1 -0
- package/dist/services/TrustEngine.d.ts +81 -0
- package/dist/services/TrustEngine.d.ts.map +1 -0
- package/dist/services/db.d.ts +12 -0
- package/dist/services/db.d.ts.map +1 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/tests.d.ts +3 -0
- package/dist/tests.d.ts.map +1 -0
- package/dist/types/permissions.d.ts +185 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/security.d.ts +114 -0
- package/dist/types/security.d.ts.map +1 -0
- package/dist/types/trust.d.ts +179 -0
- package/dist/types/trust.d.ts.map +1 -0
- package/package.json +26 -17
- package/LICENSE +0 -21
- package/README.md +0 -244
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO/B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type IAgentRuntime, type UUID } from "@elizaos/core";
|
|
2
|
+
import type { AccessDecision, AccessRequest, ElevationRequest, ElevationResult, Permission, PermissionContext, PermissionDelegation } from "../types/permissions";
|
|
3
|
+
import type { SecurityModule } from "./SecurityModule";
|
|
4
|
+
import type { TrustEngine } from "./TrustEngine";
|
|
5
|
+
export declare class ContextualPermissionSystem {
|
|
6
|
+
private runtime;
|
|
7
|
+
private trustEngine;
|
|
8
|
+
private securityModule;
|
|
9
|
+
private permissionCache;
|
|
10
|
+
private elevations;
|
|
11
|
+
private delegations;
|
|
12
|
+
private static readonly ROLE_PERMISSIONS;
|
|
13
|
+
private static readonly TRUST_ACTION_THRESHOLDS;
|
|
14
|
+
private static readonly TRUST_ONLY_ACTIONS;
|
|
15
|
+
private static readonly ADMIN_ONLY_ACTIONS;
|
|
16
|
+
initialize(runtime: IAgentRuntime, trustEngine: TrustEngine, securityModule: SecurityModule): Promise<void>;
|
|
17
|
+
hasPermission(entityId: UUID, permission: Permission, context: PermissionContext): Promise<boolean>;
|
|
18
|
+
checkAccess(request: AccessRequest): Promise<AccessDecision>;
|
|
19
|
+
private checkRolePermissions;
|
|
20
|
+
private checkTrustPermissions;
|
|
21
|
+
private checkDelegatedPermissions;
|
|
22
|
+
requestElevation(request: ElevationRequest): Promise<ElevationResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Check if the entity has an active (non-expired) elevation grant for the requested action.
|
|
25
|
+
*/
|
|
26
|
+
private checkActiveElevations;
|
|
27
|
+
/**
|
|
28
|
+
* Create a delegation granting another entity specific permissions.
|
|
29
|
+
*/
|
|
30
|
+
addDelegation(delegation: PermissionDelegation): void;
|
|
31
|
+
/**
|
|
32
|
+
* Revoke a delegation by ID.
|
|
33
|
+
*/
|
|
34
|
+
revokeDelegation(delegationId: UUID, revokedBy: UUID): boolean;
|
|
35
|
+
private createDecision;
|
|
36
|
+
private roleHasPermission;
|
|
37
|
+
private getEntityRoles;
|
|
38
|
+
private generateDenialReason;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ContextualPermissionSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextualPermissionSystem.d.ts","sourceRoot":"","sources":["../../src/services/ContextualPermissionSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAIlB,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EAEf,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,qBAAa,0BAA0B;IACrC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,cAAc,CAAkB;IAExC,OAAO,CAAC,eAAe,CAGnB;IACJ,OAAO,CAAC,UAAU,CAGd;IACJ,OAAO,CAAC,WAAW,CAA2C;IAE9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAYtC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAM7C;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAGvC;IAEH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAGvC;IAEG,UAAU,CACd,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,IAAI,CAAC;IAMV,aAAa,CACjB,QAAQ,EAAE,IAAI,EACd,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,OAAO,CAAC;IAUb,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;YA6DpD,oBAAoB;YAoBpB,qBAAqB;YA6CrB,yBAAyB;IA8BjC,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAqD3E;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAqB7B;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAUrD;;OAEG;IACH,gBAAgB,CAAC,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO;IAa9D,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,iBAAiB;YAUX,cAAc;IAe5B,OAAO,CAAC,oBAAoB;CAO7B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service, type UUID } from "@elizaos/core";
|
|
2
|
+
import { type SecurityContext } from "../types/security";
|
|
3
|
+
import type { SecurityModule } from "./SecurityModule";
|
|
4
|
+
export interface CredentialThreatDetection {
|
|
5
|
+
detected: boolean;
|
|
6
|
+
confidence: number;
|
|
7
|
+
threatType: "credential_request" | "phishing" | "social_engineering" | "none";
|
|
8
|
+
sensitiveData: string[];
|
|
9
|
+
recommendation: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class CredentialProtector extends Service {
|
|
12
|
+
static serviceType: "credential-protector";
|
|
13
|
+
capabilityDescription: string;
|
|
14
|
+
private securityModule;
|
|
15
|
+
private readonly SENSITIVE_PATTERNS;
|
|
16
|
+
private readonly THEFT_REQUEST_PATTERNS;
|
|
17
|
+
private readonly LEGITIMATE_CONTEXTS;
|
|
18
|
+
initialize(_runtime: IAgentRuntime, securityModule: SecurityModule): Promise<void>;
|
|
19
|
+
stop(): Promise<void>;
|
|
20
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
21
|
+
/**
|
|
22
|
+
* Scan message for credential theft attempts
|
|
23
|
+
*/
|
|
24
|
+
scanForCredentialTheft(message: string, entityId: UUID, context: SecurityContext): Promise<CredentialThreatDetection>;
|
|
25
|
+
/**
|
|
26
|
+
* Protect sensitive data by redacting it
|
|
27
|
+
*/
|
|
28
|
+
protectSensitiveData(content: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Alert potential victims of credential theft
|
|
31
|
+
*/
|
|
32
|
+
alertPotentialVictims(threatActor: UUID, victims: UUID[], threatDetails: CredentialThreatDetection): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Analyze a conversation for credential theft patterns
|
|
35
|
+
*/
|
|
36
|
+
analyzeConversation(messages: Array<{
|
|
37
|
+
entityId: UUID;
|
|
38
|
+
content: string;
|
|
39
|
+
timestamp: number;
|
|
40
|
+
}>, context: SecurityContext): Promise<{
|
|
41
|
+
overallThreat: number;
|
|
42
|
+
suspiciousEntities: UUID[];
|
|
43
|
+
recommendations: string[];
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Private helper methods
|
|
47
|
+
*/
|
|
48
|
+
private detectSensitiveData;
|
|
49
|
+
private isLegitimateContext;
|
|
50
|
+
private hasPhishingIndicators;
|
|
51
|
+
private logThreatEvent;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=CredentialProtector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialProtector.d.ts","sourceRoot":"","sources":["../../src/services/CredentialProtector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,O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AE,MAAM,CAAC;QACtB,kBAAkB,EAAE,IAAI,EAAE,CAAC;QAC3B,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IA8DF;;OAEG;IAEH,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,qBAAqB;YAcf,cAAc;CAqB7B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IAgentRuntime, UUID } from "@elizaos/core";
|
|
2
|
+
import { Service } from "@elizaos/core";
|
|
3
|
+
import type { SecurityCheck, SecurityContext } from "../types/security";
|
|
4
|
+
import type { TrustContext } from "../types/trust";
|
|
5
|
+
export interface EvaluationPrompt {
|
|
6
|
+
system: string;
|
|
7
|
+
user: string;
|
|
8
|
+
context: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export declare class LLMEvaluator extends Service {
|
|
11
|
+
static serviceType: "llm-evaluator";
|
|
12
|
+
capabilityDescription: string;
|
|
13
|
+
initialize(runtime: IAgentRuntime): Promise<void>;
|
|
14
|
+
stop(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate potential security threats using LLM
|
|
17
|
+
*/
|
|
18
|
+
evaluateSecurityThreat(message: string, context: SecurityContext, history?: string[]): Promise<SecurityCheck>;
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate trust-related decisions using LLM
|
|
21
|
+
*/
|
|
22
|
+
evaluateTrustAction(action: string, actor: UUID, context: TrustContext, trustScore: number): Promise<{
|
|
23
|
+
allowed: boolean;
|
|
24
|
+
confidence: number;
|
|
25
|
+
reasoning: string;
|
|
26
|
+
suggestions?: string[];
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Analyze behavioral patterns using LLM
|
|
30
|
+
*/
|
|
31
|
+
analyzeBehavior(messages: string[], actions: Array<{
|
|
32
|
+
type: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
result?: string;
|
|
35
|
+
}>, entityId: UUID): Promise<{
|
|
36
|
+
patterns: string[];
|
|
37
|
+
anomalies: string[];
|
|
38
|
+
riskScore: number;
|
|
39
|
+
personality: string;
|
|
40
|
+
}>;
|
|
41
|
+
private determineAction;
|
|
42
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=LLMEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMEvaluator.d.ts","sourceRoot":"","sources":["../../src/services/LLMEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAIL,OAAO,EACR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,qBAAa,YAAa,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,EAAG,eAAe,CAAU;IAE9C,qBAAqB,SACqC;IAEpD,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;OAEG;IACG,sBAAsB,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC;IAoEzB;;OAEG;IACG,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;IA8DF;;OAEG;IACG,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EACpE,QAAQ,EAAE,IAAI,GACb,OAAO,CAAC;QACT,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IA8EF,OAAO,CAAC,eAAe;WAmBV,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAK7D"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type IAgentRuntime, type UUID } from "@elizaos/core";
|
|
2
|
+
import { type Action, type CoordinationDetection, type CredentialTheftDetection, type ImpersonationDetection, type Message, type MultiAccountDetection, type PhishingDetection, type SecurityCheck, type SecurityContext, type SecurityEvent, SecurityEventType, type ThreatAssessment } from "../types/security";
|
|
3
|
+
import type { TrustEngine } from "./TrustEngine";
|
|
4
|
+
export interface RiskScore {
|
|
5
|
+
score: number;
|
|
6
|
+
factors: Record<string, number>;
|
|
7
|
+
recommendation: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SocialEngineeringFactors {
|
|
10
|
+
urgency: number;
|
|
11
|
+
authority: number;
|
|
12
|
+
intimidation: number;
|
|
13
|
+
liking: number;
|
|
14
|
+
reciprocity: number;
|
|
15
|
+
commitment: number;
|
|
16
|
+
socialProof: number;
|
|
17
|
+
scarcity: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class SecurityModule {
|
|
20
|
+
private runtime;
|
|
21
|
+
private trustEngine;
|
|
22
|
+
private behavioralProfiles;
|
|
23
|
+
private messageHistory;
|
|
24
|
+
private actionHistory;
|
|
25
|
+
private readonly INJECTION_PATTERNS;
|
|
26
|
+
private readonly URGENCY_KEYWORDS;
|
|
27
|
+
private readonly AUTHORITY_KEYWORDS;
|
|
28
|
+
private readonly INTIMIDATION_KEYWORDS;
|
|
29
|
+
private readonly CREDENTIAL_PATTERNS;
|
|
30
|
+
private readonly PHISHING_INDICATORS;
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the security module
|
|
33
|
+
*/
|
|
34
|
+
initialize(runtime: IAgentRuntime, trustEngine: TrustEngine): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Detect prompt injection attempts
|
|
37
|
+
*/
|
|
38
|
+
detectPromptInjection(message: string, context: SecurityContext): Promise<SecurityCheck>;
|
|
39
|
+
/**
|
|
40
|
+
* Detect social engineering attempts
|
|
41
|
+
*/
|
|
42
|
+
detectSocialEngineering(message: string, context: SecurityContext): Promise<SecurityCheck>;
|
|
43
|
+
/**
|
|
44
|
+
* Analyze a message for security threats
|
|
45
|
+
*/
|
|
46
|
+
analyzeMessage(message: string, entityId: UUID, context: SecurityContext): Promise<SecurityCheck>;
|
|
47
|
+
/**
|
|
48
|
+
* Assess overall threat level
|
|
49
|
+
*/
|
|
50
|
+
assessThreatLevel(context: SecurityContext): Promise<ThreatAssessment>;
|
|
51
|
+
/**
|
|
52
|
+
* Get recent security incidents
|
|
53
|
+
*/
|
|
54
|
+
getRecentSecurityIncidents(_roomId?: UUID, hours?: number): Promise<SecurityEvent[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Get security recommendations based on threat level
|
|
57
|
+
*/
|
|
58
|
+
getSecurityRecommendations(threatLevel: number): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Log security event (now public)
|
|
61
|
+
*/
|
|
62
|
+
logSecurityEvent(event: Omit<SecurityEvent, "id" | "timestamp" | "handled">): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Analyze social engineering factors
|
|
65
|
+
*/
|
|
66
|
+
private analyzeSocialEngineeringFactors;
|
|
67
|
+
/**
|
|
68
|
+
* Calculate keyword score
|
|
69
|
+
*/
|
|
70
|
+
private calculateKeywordScore;
|
|
71
|
+
private static readonly SE_FACTOR_PHRASES;
|
|
72
|
+
private detectFactorScore;
|
|
73
|
+
/**
|
|
74
|
+
* Calculate overall social engineering risk
|
|
75
|
+
*/
|
|
76
|
+
private calculateSocialEngineeringRisk;
|
|
77
|
+
/**
|
|
78
|
+
* Analyze semantic patterns
|
|
79
|
+
*/
|
|
80
|
+
private analyzeSemantics;
|
|
81
|
+
/**
|
|
82
|
+
* Log trust impact from security events
|
|
83
|
+
*/
|
|
84
|
+
logTrustImpact(entityId: UUID, event: SecurityEventType, impact: number, context?: {
|
|
85
|
+
worldId?: UUID;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Maps security events to trust evidence types
|
|
89
|
+
*/
|
|
90
|
+
private mapSecurityEventToTrustEvidence;
|
|
91
|
+
/**
|
|
92
|
+
* Enhanced pattern detection capabilities
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* Detect multi-account manipulation
|
|
96
|
+
*/
|
|
97
|
+
detectMultiAccountPattern(entities: UUID[], timeWindow?: number): Promise<MultiAccountDetection | null>;
|
|
98
|
+
/**
|
|
99
|
+
* Detect credential theft attempts
|
|
100
|
+
*/
|
|
101
|
+
detectCredentialTheft(message: string, entityId: UUID, context: SecurityContext): Promise<CredentialTheftDetection | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Detect phishing campaigns
|
|
104
|
+
*/
|
|
105
|
+
detectPhishing(messages: Message[], entityId: UUID): Promise<PhishingDetection | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Detect impersonation attempts
|
|
108
|
+
*/
|
|
109
|
+
detectImpersonation(username: string, existingUsers: string[]): Promise<ImpersonationDetection | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Detect coordinated activity
|
|
112
|
+
*/
|
|
113
|
+
detectCoordinatedActivity(entities: UUID[], timeWindow?: number): Promise<CoordinationDetection | null>;
|
|
114
|
+
/**
|
|
115
|
+
* Helper methods for pattern detection
|
|
116
|
+
*/
|
|
117
|
+
private getBehavioralProfiles;
|
|
118
|
+
private buildBehavioralProfile;
|
|
119
|
+
private calculateProfileSimilarities;
|
|
120
|
+
private calculateVariance;
|
|
121
|
+
private checkSynchronizedActions;
|
|
122
|
+
private getRecentActions;
|
|
123
|
+
private detectSuspiciousLinks;
|
|
124
|
+
private extractLinks;
|
|
125
|
+
private calculateStringSimilarity;
|
|
126
|
+
private calculateVisualSimilarity;
|
|
127
|
+
private levenshteinDistance;
|
|
128
|
+
/**
|
|
129
|
+
* Store message for analysis
|
|
130
|
+
*/
|
|
131
|
+
storeMessage(message: Message): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Store action for analysis
|
|
134
|
+
*/
|
|
135
|
+
storeAction(action: Action): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=SecurityModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecurityModule.d.ts","sourceRoot":"","sources":["../../src/services/SecurityModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,iBAAiB,EACjB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAajD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE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AEG;IACG,cAAc,CAClB,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,IAAI,GACb,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IA8CpC;;OAEG;IACG,mBAAmB,CACvB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAkDzC;;OAEG;IACG,yBAAyB,CAC7B,QAAQ,EAAE,IAAI,EAAE,EAChB,UAAU,GAAE,MAAe,GAC1B,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAqDxC;;OAEG;YAEW,qBAAqB;YAiBrB,sBAAsB;IA2DpC,OAAO,CAAC,4BAA4B;IA6BpC,OAAO,CAAC,iBAAiB;YAKX,wBAAwB;YAqCxB,gBAAgB;IAe9B,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,yBAAyB;IA+DjC,OAAO,CAAC,mBAAmB;IA4B3B;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAanD;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAYjD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { UUID } from "@elizaos/core";
|
|
2
|
+
import type { DrizzleDB } from "./db";
|
|
3
|
+
export interface InsertSecurityIncident {
|
|
4
|
+
entityId: UUID;
|
|
5
|
+
type: string;
|
|
6
|
+
severity: string;
|
|
7
|
+
context?: Record<string, unknown>;
|
|
8
|
+
details?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export declare function insertSecurityIncident(db: DrizzleDB, incident: InsertSecurityIncident): Promise<void>;
|
|
11
|
+
export declare function getRecentIncidents(db: DrizzleDB, roomId?: UUID, hours?: number): Promise<Array<Record<string, unknown>>>;
|
|
12
|
+
export interface InsertTrustEvidence {
|
|
13
|
+
targetEntityId: UUID;
|
|
14
|
+
sourceEntityId: UUID;
|
|
15
|
+
evaluatorId: UUID;
|
|
16
|
+
type: string;
|
|
17
|
+
impact: number;
|
|
18
|
+
weight?: number;
|
|
19
|
+
description?: string;
|
|
20
|
+
verified?: boolean;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export declare function insertTrustEvidence(db: DrizzleDB, evidence: InsertTrustEvidence): Promise<void>;
|
|
24
|
+
export declare function getTrustEvidence(db: DrizzleDB, entityId: UUID, evaluatorId?: UUID): Promise<Array<Record<string, unknown>>>;
|
|
25
|
+
export interface UpsertBehavioralProfile {
|
|
26
|
+
entityId: UUID;
|
|
27
|
+
typingSpeed?: number;
|
|
28
|
+
vocabularyComplexity?: number;
|
|
29
|
+
messageLengthMean?: number;
|
|
30
|
+
messageLengthStdDev?: number;
|
|
31
|
+
activeHours?: number[];
|
|
32
|
+
commonPhrases?: string[];
|
|
33
|
+
interactionPatterns?: Record<string, number>;
|
|
34
|
+
}
|
|
35
|
+
export declare function upsertBehavioralProfile(db: DrizzleDB, profile: UpsertBehavioralProfile): Promise<void>;
|
|
36
|
+
export declare function getBehavioralProfile(db: DrizzleDB, entityId: UUID): Promise<Record<string, unknown> | null>;
|
|
37
|
+
export declare function insertIdentityLink(db: DrizzleDB, link: {
|
|
38
|
+
entityIdA: UUID;
|
|
39
|
+
entityIdB: UUID;
|
|
40
|
+
confidence: number;
|
|
41
|
+
evidence?: string[];
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
export declare function getIdentityLinks(db: DrizzleDB, entityId: UUID): Promise<Array<Record<string, unknown>>>;
|
|
44
|
+
export declare function insertWhistleblowerReport(db: DrizzleDB, report: {
|
|
45
|
+
reportedEntityId: UUID;
|
|
46
|
+
evidence: Record<string, unknown>;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
//# sourceMappingURL=SecurityStore.d.ts.map
|
|
@@ -0,0 +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AS,EACb,MAAM,EAAE;IAAE,gBAAgB,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACpE,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service, type UUID } from "@elizaos/core";
|
|
2
|
+
import { type TrustCalculationConfig, type TrustContext, type TrustDecision, type TrustInteraction, type TrustProfile, type TrustRequirements } from "../types/trust";
|
|
3
|
+
export declare class TrustEngine extends Service {
|
|
4
|
+
static serviceType: "trust-engine";
|
|
5
|
+
capabilityDescription: string;
|
|
6
|
+
private static readonly ACTION_CONTEXT_WEIGHTS;
|
|
7
|
+
private trustConfig;
|
|
8
|
+
private profileCache;
|
|
9
|
+
private readonly cacheTimeout;
|
|
10
|
+
private readonly maxInteractionsInMemory;
|
|
11
|
+
private interactions;
|
|
12
|
+
private rateLimits;
|
|
13
|
+
private readonly maxEvidencePerHour;
|
|
14
|
+
constructor(config?: Partial<TrustCalculationConfig>);
|
|
15
|
+
initialize(runtime: IAgentRuntime): Promise<void>;
|
|
16
|
+
stop(): Promise<void>;
|
|
17
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate trust profile for an entity
|
|
20
|
+
*/
|
|
21
|
+
calculateTrust(subjectId: UUID, context: TrustContext): Promise<TrustProfile>;
|
|
22
|
+
/**
|
|
23
|
+
* Records a trust interaction
|
|
24
|
+
*/
|
|
25
|
+
recordInteraction(interaction: TrustInteraction): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Evaluate if an action is allowed based on trust
|
|
28
|
+
*/
|
|
29
|
+
evaluateTrustDecision(entityId: UUID, requirements: TrustRequirements, context: TrustContext): Promise<TrustDecision>;
|
|
30
|
+
/**
|
|
31
|
+
* Check rate limiting for evidence recording
|
|
32
|
+
*/
|
|
33
|
+
private static readonly DIMINISHING_WEIGHTS;
|
|
34
|
+
private checkRateLimit;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate trust dimensions from evidence
|
|
37
|
+
*/
|
|
38
|
+
private calculateDimensions;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate overall trust score from dimensions
|
|
41
|
+
*/
|
|
42
|
+
private calculateOverallTrust;
|
|
43
|
+
/**
|
|
44
|
+
* Calculate confidence based on evidence quantity and consistency
|
|
45
|
+
*/
|
|
46
|
+
private calculateConfidence;
|
|
47
|
+
/**
|
|
48
|
+
* Calculate age weight for evidence based on recency
|
|
49
|
+
*/
|
|
50
|
+
private calculateAgeWeight;
|
|
51
|
+
/**
|
|
52
|
+
* Analyze trust trend over time
|
|
53
|
+
*/
|
|
54
|
+
private analyzeTrend;
|
|
55
|
+
/**
|
|
56
|
+
* Load evidence from storage
|
|
57
|
+
*/
|
|
58
|
+
private loadEvidence;
|
|
59
|
+
/**
|
|
60
|
+
* Save trust profile to storage
|
|
61
|
+
*/
|
|
62
|
+
private saveTrustProfile;
|
|
63
|
+
/**
|
|
64
|
+
* Generate suggestions for building trust
|
|
65
|
+
*/
|
|
66
|
+
private generateTrustBuildingSuggestions;
|
|
67
|
+
/**
|
|
68
|
+
* Generate suggestions for improving specific dimensions
|
|
69
|
+
*/
|
|
70
|
+
private generateDimensionSuggestions;
|
|
71
|
+
/**
|
|
72
|
+
* Evaluates trust for an entity (simplified API for actions)
|
|
73
|
+
*/
|
|
74
|
+
evaluateTrust(entityId: UUID, evaluatorId: UUID, context?: Partial<TrustContext>): Promise<TrustProfile>;
|
|
75
|
+
/**
|
|
76
|
+
* Get recent trust interactions for an entity
|
|
77
|
+
* @param daysBack Number of days to look back (default: 10)
|
|
78
|
+
*/
|
|
79
|
+
getRecentInteractions(entityId: UUID, daysBack?: number): Promise<TrustInteraction[]>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=TrustEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrustEngine.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EAAE,YAAY,GACpB,OAAO,CAAC,aAAa,CAAC;IAgFzB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAmC;IAE9E,OAAO,CAAC,cAAc;IAwCtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAsC3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;YACW,YAAY;IAqD1B;;OAEG;YACW,YAAY;IAoE1B;;OAEG;YACW,gBAAgB;IA8C9B;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAiCxC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAsCpC;;OAEG;IACG,aAAa,CACjB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,IAAI,EACjB,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC9B,OAAO,CAAC,YAAY,CAAC;IAQxB;;;OAGG;IACG,qBAAqB,CACzB,QAAQ,EAAE,IAAI,EACd,QAAQ,SAAK,GACZ,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAS/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal Drizzle-compatible DB interface.
|
|
4
|
+
* Uses a chainable query builder pattern matching drizzle-orm.
|
|
5
|
+
*/
|
|
6
|
+
export type DrizzleDB = Record<string, (...args: any[]) => any>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the Drizzle database instance from the runtime.
|
|
9
|
+
* @throws if the database is unavailable.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDb(runtime: IAgentRuntime): DrizzleDB;
|
|
12
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/services/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AAGH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAIvD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ContextualPermissionSystem } from "./ContextualPermissionSystem";
|
|
2
|
+
export { CredentialProtector } from "./CredentialProtector";
|
|
3
|
+
export { LLMEvaluator } from "./LLMEvaluator";
|
|
4
|
+
export { SecurityModule } from "./SecurityModule";
|
|
5
|
+
export { TrustEngine } from "./TrustEngine";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/tests.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../src/tests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,QAAQ,EAET,MAAM,eAAe,CAAC;AAiGvB,eAAO,MAAM,KAAK,EAAE,QAAQ,EAs3B3B,CAAC"}
|