@elizaos/plugin-trust 1.2.1 → 2.0.0-alpha.1
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 +4 -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/securityEvaluator.d.ts +28 -0
- package/dist/evaluators/securityEvaluator.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 +34 -827
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4925 -4208
- package/dist/index.js.map +33 -1
- package/dist/providers/adminTrust.d.ts +3 -0
- package/dist/providers/adminTrust.d.ts.map +1 -0
- package/dist/providers/index.d.ts +6 -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 +15 -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 +1170 -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 +62 -0
- package/dist/services/CredentialProtector.d.ts.map +1 -0
- package/dist/services/SecurityModule.d.ts +145 -0
- package/dist/services/SecurityModule.d.ts.map +1 -0
- package/dist/services/SecurityStore.d.ts +53 -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 +5 -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 +44 -19
- package/LICENSE +0 -21
- package/README.md +0 -244
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { UUID } from "@elizaos/core";
|
|
2
|
+
import type { PermissionContext } from "./permissions";
|
|
3
|
+
export interface SecurityContext extends PermissionContext {
|
|
4
|
+
entityId?: UUID;
|
|
5
|
+
requestedAction?: string;
|
|
6
|
+
messageHistory?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface SecurityCheck {
|
|
9
|
+
detected: boolean;
|
|
10
|
+
confidence: number;
|
|
11
|
+
type: "prompt_injection" | "social_engineering" | "credential_theft" | "anomaly" | "none";
|
|
12
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
13
|
+
action: "block" | "require_verification" | "allow" | "log_only";
|
|
14
|
+
details?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ThreatAssessment extends SecurityCheck {
|
|
17
|
+
recommendation?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SecurityEvent {
|
|
20
|
+
id?: UUID;
|
|
21
|
+
type: SecurityEventType;
|
|
22
|
+
entityId: UUID;
|
|
23
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
24
|
+
context: PermissionContext;
|
|
25
|
+
details: Record<string, unknown>;
|
|
26
|
+
timestamp?: number;
|
|
27
|
+
handled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare enum SecurityEventType {
|
|
30
|
+
PROMPT_INJECTION_ATTEMPT = "prompt_injection_attempt",
|
|
31
|
+
SOCIAL_ENGINEERING_ATTEMPT = "social_engineering_attempt",
|
|
32
|
+
PRIVILEGE_ESCALATION_ATTEMPT = "privilege_escalation_attempt",
|
|
33
|
+
ANOMALOUS_REQUEST = "anomalous_request",
|
|
34
|
+
TRUST_MANIPULATION = "trust_manipulation",
|
|
35
|
+
IDENTITY_SPOOFING = "identity_spoofing",
|
|
36
|
+
MULTI_ACCOUNT_ABUSE = "multi_account_abuse",
|
|
37
|
+
CREDENTIAL_THEFT_ATTEMPT = "credential_theft_attempt",
|
|
38
|
+
PHISHING_ATTEMPT = "phishing_attempt",
|
|
39
|
+
IMPERSONATION_ATTEMPT = "impersonation_attempt",
|
|
40
|
+
COORDINATED_ATTACK = "coordinated_attack",
|
|
41
|
+
MALICIOUS_LINK_CAMPAIGN = "malicious_link_campaign"
|
|
42
|
+
}
|
|
43
|
+
export interface PatternDetection {
|
|
44
|
+
type: "multi_account" | "phishing" | "impersonation" | "coordination" | "credential_theft";
|
|
45
|
+
confidence: number;
|
|
46
|
+
evidence: string[];
|
|
47
|
+
relatedEntities?: UUID[];
|
|
48
|
+
recommendation: string;
|
|
49
|
+
}
|
|
50
|
+
export interface MultiAccountDetection extends PatternDetection {
|
|
51
|
+
type: "multi_account";
|
|
52
|
+
primaryAccount: UUID;
|
|
53
|
+
linkedAccounts: UUID[];
|
|
54
|
+
linkageEvidence: {
|
|
55
|
+
typingPattern: number;
|
|
56
|
+
timingPattern: number;
|
|
57
|
+
vocabularyPattern: number;
|
|
58
|
+
behaviorPattern: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface PhishingDetection extends PatternDetection {
|
|
62
|
+
type: "phishing";
|
|
63
|
+
maliciousLinks?: string[];
|
|
64
|
+
targetedEntities: UUID[];
|
|
65
|
+
campaignId?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ImpersonationDetection extends PatternDetection {
|
|
68
|
+
type: "impersonation";
|
|
69
|
+
impersonator: string;
|
|
70
|
+
impersonated: string;
|
|
71
|
+
visualSimilarity: number;
|
|
72
|
+
timingCoincidence: number;
|
|
73
|
+
}
|
|
74
|
+
export interface CoordinationDetection extends PatternDetection {
|
|
75
|
+
type: "coordination";
|
|
76
|
+
coordinatedEntities: UUID[];
|
|
77
|
+
timeWindow: number;
|
|
78
|
+
correlationScore: number;
|
|
79
|
+
}
|
|
80
|
+
export interface CredentialTheftDetection extends PatternDetection {
|
|
81
|
+
type: "credential_theft";
|
|
82
|
+
sensitivePatterns: string[];
|
|
83
|
+
attemptedTheft: string[];
|
|
84
|
+
potentialVictims: UUID[];
|
|
85
|
+
}
|
|
86
|
+
export interface BehavioralProfile {
|
|
87
|
+
entityId: UUID;
|
|
88
|
+
typingSpeed: number;
|
|
89
|
+
vocabularyComplexity: number;
|
|
90
|
+
messageLength: {
|
|
91
|
+
mean: number;
|
|
92
|
+
stdDev: number;
|
|
93
|
+
};
|
|
94
|
+
activeHours: number[];
|
|
95
|
+
commonPhrases: string[];
|
|
96
|
+
interactionPatterns: Map<string, number>;
|
|
97
|
+
}
|
|
98
|
+
export interface Message {
|
|
99
|
+
id: UUID;
|
|
100
|
+
entityId: UUID;
|
|
101
|
+
content: string;
|
|
102
|
+
timestamp: number;
|
|
103
|
+
roomId?: UUID;
|
|
104
|
+
replyTo?: UUID;
|
|
105
|
+
}
|
|
106
|
+
export interface Action {
|
|
107
|
+
id: UUID;
|
|
108
|
+
entityId: UUID;
|
|
109
|
+
type: string;
|
|
110
|
+
timestamp: number;
|
|
111
|
+
target?: string;
|
|
112
|
+
result?: "success" | "failure";
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/types/security.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,kBAAkB,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAAC;IAC1F,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,MAAM,EAAE,OAAO,GAAG,sBAAsB,GAAG,OAAO,GAAG,UAAU,CAAC;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,M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ClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { UUID } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Core trust dimensions based on interpersonal trust theory
|
|
4
|
+
*/
|
|
5
|
+
export interface TrustDimensions {
|
|
6
|
+
/** Consistency in behavior and promise keeping (0-100) */
|
|
7
|
+
reliability: number;
|
|
8
|
+
/** Ability to perform tasks and provide value (0-100) */
|
|
9
|
+
competence: number;
|
|
10
|
+
/** Adherence to ethical principles (0-100) */
|
|
11
|
+
integrity: number;
|
|
12
|
+
/** Good intentions towards others (0-100) */
|
|
13
|
+
benevolence: number;
|
|
14
|
+
/** Open and honest communication (0-100) */
|
|
15
|
+
transparency: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Evidence types that impact trust scores
|
|
19
|
+
*/
|
|
20
|
+
export declare enum TrustEvidenceType {
|
|
21
|
+
PROMISE_KEPT = "PROMISE_KEPT",
|
|
22
|
+
HELPFUL_ACTION = "HELPFUL_ACTION",
|
|
23
|
+
CONSISTENT_BEHAVIOR = "CONSISTENT_BEHAVIOR",
|
|
24
|
+
VERIFIED_IDENTITY = "VERIFIED_IDENTITY",
|
|
25
|
+
COMMUNITY_CONTRIBUTION = "COMMUNITY_CONTRIBUTION",
|
|
26
|
+
SUCCESSFUL_TRANSACTION = "SUCCESSFUL_TRANSACTION",
|
|
27
|
+
PROMISE_BROKEN = "PROMISE_BROKEN",
|
|
28
|
+
HARMFUL_ACTION = "HARMFUL_ACTION",
|
|
29
|
+
INCONSISTENT_BEHAVIOR = "INCONSISTENT_BEHAVIOR",
|
|
30
|
+
SUSPICIOUS_ACTIVITY = "SUSPICIOUS_ACTIVITY",
|
|
31
|
+
FAILED_VERIFICATION = "FAILED_VERIFICATION",
|
|
32
|
+
SPAM_BEHAVIOR = "SPAM_BEHAVIOR",
|
|
33
|
+
SECURITY_VIOLATION = "SECURITY_VIOLATION",
|
|
34
|
+
IDENTITY_CHANGE = "IDENTITY_CHANGE",
|
|
35
|
+
ROLE_CHANGE = "ROLE_CHANGE",
|
|
36
|
+
CONTEXT_SWITCH = "CONTEXT_SWITCH"
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A piece of evidence that affects trust
|
|
40
|
+
*/
|
|
41
|
+
export interface TrustEvidence {
|
|
42
|
+
type: TrustEvidenceType;
|
|
43
|
+
timestamp: number;
|
|
44
|
+
/** Impact on trust score (-100 to +100) */
|
|
45
|
+
impact: number;
|
|
46
|
+
/** Weight/importance of this evidence (0-1) */
|
|
47
|
+
weight: number;
|
|
48
|
+
/** Optional description of the evidence */
|
|
49
|
+
description: string;
|
|
50
|
+
/** Entity who reported/created this evidence */
|
|
51
|
+
reportedBy: UUID;
|
|
52
|
+
/** Whether this evidence has been verified */
|
|
53
|
+
verified: boolean;
|
|
54
|
+
/** Context where this evidence occurred */
|
|
55
|
+
context: TrustContext;
|
|
56
|
+
targetEntityId: UUID;
|
|
57
|
+
evaluatorId: UUID;
|
|
58
|
+
metadata?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Trust profile for an entity
|
|
62
|
+
*/
|
|
63
|
+
export interface TrustProfile {
|
|
64
|
+
/** Entity this profile belongs to */
|
|
65
|
+
entityId: UUID;
|
|
66
|
+
/** Core trust dimensions */
|
|
67
|
+
dimensions: TrustDimensions;
|
|
68
|
+
/** Overall trust score (0-100) */
|
|
69
|
+
overallTrust: number;
|
|
70
|
+
/** Confidence in the trust score (0-1) */
|
|
71
|
+
confidence: number;
|
|
72
|
+
/** Number of interactions used to calculate trust */
|
|
73
|
+
interactionCount: number;
|
|
74
|
+
/** Evidence supporting this trust profile */
|
|
75
|
+
evidence: TrustEvidence[];
|
|
76
|
+
/** When this profile was last calculated */
|
|
77
|
+
lastCalculated: number;
|
|
78
|
+
/** Method used to calculate trust */
|
|
79
|
+
calculationMethod: string;
|
|
80
|
+
/** Trust trend over time */
|
|
81
|
+
trend: {
|
|
82
|
+
direction: "increasing" | "decreasing" | "stable";
|
|
83
|
+
changeRate: number;
|
|
84
|
+
lastChangeAt: number;
|
|
85
|
+
};
|
|
86
|
+
evaluatorId: UUID;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Context for trust calculations
|
|
90
|
+
*/
|
|
91
|
+
export interface TrustContext {
|
|
92
|
+
/** Who is evaluating trust */
|
|
93
|
+
evaluatorId: UUID;
|
|
94
|
+
/** Specific context for evaluation */
|
|
95
|
+
worldId?: UUID;
|
|
96
|
+
roomId?: UUID;
|
|
97
|
+
platform?: string;
|
|
98
|
+
/** Type of action being considered */
|
|
99
|
+
action?: string;
|
|
100
|
+
/** Time window for evidence consideration */
|
|
101
|
+
timeWindow?: {
|
|
102
|
+
start: number;
|
|
103
|
+
end: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Result of a trust-based decision
|
|
108
|
+
*/
|
|
109
|
+
export interface TrustDecision {
|
|
110
|
+
allowed: boolean;
|
|
111
|
+
trustScore: number;
|
|
112
|
+
requiredScore: number;
|
|
113
|
+
/** Which dimensions were evaluated */
|
|
114
|
+
dimensionsChecked: Partial<TrustDimensions>;
|
|
115
|
+
/** Reason for the decision */
|
|
116
|
+
reason: string;
|
|
117
|
+
/** Suggestions for building trust if denied */
|
|
118
|
+
suggestions?: string[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Configuration for trust requirements
|
|
122
|
+
*/
|
|
123
|
+
export interface TrustRequirements {
|
|
124
|
+
/** Minimum overall trust score */
|
|
125
|
+
minimumTrust: number;
|
|
126
|
+
/** Required dimension scores */
|
|
127
|
+
dimensions?: {
|
|
128
|
+
reliability?: number;
|
|
129
|
+
competence?: number;
|
|
130
|
+
integrity?: number;
|
|
131
|
+
benevolence?: number;
|
|
132
|
+
transparency?: number;
|
|
133
|
+
};
|
|
134
|
+
/** Required evidence types */
|
|
135
|
+
requiredEvidence?: TrustEvidenceType[];
|
|
136
|
+
/** Minimum interaction count */
|
|
137
|
+
minimumInteractions?: number;
|
|
138
|
+
/** Required confidence level */
|
|
139
|
+
minimumConfidence?: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Trust interaction to be recorded
|
|
143
|
+
*/
|
|
144
|
+
export interface TrustInteraction {
|
|
145
|
+
sourceEntityId: UUID;
|
|
146
|
+
targetEntityId: UUID;
|
|
147
|
+
type: TrustEvidenceType;
|
|
148
|
+
timestamp: number;
|
|
149
|
+
impact: number;
|
|
150
|
+
details?: {
|
|
151
|
+
description?: string;
|
|
152
|
+
messageId?: UUID;
|
|
153
|
+
roomId?: UUID;
|
|
154
|
+
[key: string]: unknown;
|
|
155
|
+
};
|
|
156
|
+
context?: TrustContext;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Trust calculation configuration
|
|
160
|
+
*/
|
|
161
|
+
export interface TrustCalculationConfig {
|
|
162
|
+
/** How much recent evidence is weighted vs old */
|
|
163
|
+
recencyBias: number;
|
|
164
|
+
/** How fast evidence decays over time */
|
|
165
|
+
evidenceDecayRate: number;
|
|
166
|
+
/** Minimum evidence required for confidence */
|
|
167
|
+
minimumEvidenceCount: number;
|
|
168
|
+
/** How much to weight verified vs unverified evidence */
|
|
169
|
+
verificationMultiplier: number;
|
|
170
|
+
/** Dimension weights for overall score */
|
|
171
|
+
dimensionWeights: {
|
|
172
|
+
reliability: number;
|
|
173
|
+
competence: number;
|
|
174
|
+
integrity: number;
|
|
175
|
+
benevolence: number;
|
|
176
|
+
transparency: number;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=trust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../../src/types/trust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,E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U,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-trust",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "Trust and permission management plugin for ElizaOS",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"test:watch": "vitest --watch",
|
|
15
|
-
"test:coverage": "vitest --coverage",
|
|
16
|
-
"lint": "prettier --write src/**/*.ts"
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
17
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@elizaos/core": "
|
|
20
|
-
"@elizaos/plugin-anthropic": "
|
|
19
|
+
"@elizaos/core": "next",
|
|
20
|
+
"@elizaos/plugin-anthropic": "next",
|
|
21
21
|
"dedent": "^1.6.0",
|
|
22
22
|
"drizzle-orm": "^0.44.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^24.0.13",
|
|
26
26
|
"tsup": "^8.2.2",
|
|
27
|
-
"typescript": "^5.3.3"
|
|
27
|
+
"typescript": "^5.3.3",
|
|
28
|
+
"@biomejs/biome": "^2.3.11"
|
|
28
29
|
},
|
|
29
|
-
"files": [
|
|
30
|
-
"dist"
|
|
31
|
-
],
|
|
32
30
|
"publishConfig": {
|
|
33
31
|
"access": "public"
|
|
34
32
|
},
|
|
@@ -40,6 +38,33 @@
|
|
|
40
38
|
"security",
|
|
41
39
|
"rbac"
|
|
42
40
|
],
|
|
41
|
+
"license": "MIT",
|
|
43
42
|
"author": "ElizaOS Contributors",
|
|
44
|
-
"
|
|
45
|
-
|
|
43
|
+
"agentConfig": {
|
|
44
|
+
"pluginParameters": {
|
|
45
|
+
"OWNER_ENTITY_ID": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Entity identifier",
|
|
48
|
+
"required": false,
|
|
49
|
+
"sensitive": false
|
|
50
|
+
},
|
|
51
|
+
"WORLD_ID": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "World identifier",
|
|
54
|
+
"required": false,
|
|
55
|
+
"sensitive": false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "bun run build.ts",
|
|
61
|
+
"dev": "bun run build.ts --watch",
|
|
62
|
+
"test": "vitest run --passWithNoTests",
|
|
63
|
+
"clean": "rm -rf dist .turbo node_modules",
|
|
64
|
+
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
65
|
+
"lint:check": "bunx @biomejs/biome check .",
|
|
66
|
+
"format": "bunx @biomejs/biome format --write .",
|
|
67
|
+
"format:check": "bunx @biomejs/biome format .",
|
|
68
|
+
"typecheck": "tsc --noEmit"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Shaw Walters and elizaOS Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# @elizaos/plugin-trust
|
|
2
|
-
|
|
3
|
-
A comprehensive trust, security, and permission management plugin for ElizaOS, providing multi-dimensional trust scoring, context-aware permissions, and advanced security features.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Multi-dimensional Trust System**: Calculate and track trust scores across multiple dimensions (reliability, competence, integrity, benevolence, transparency)
|
|
8
|
-
- **Context-aware Permission Management**: Dynamic permission system that adapts based on trust levels and context
|
|
9
|
-
- **Security Module**: Advanced threat detection including prompt injection, credential theft, and phishing attempts
|
|
10
|
-
- **Permission Elevation System**: Temporary permission elevation based on trust and justification
|
|
11
|
-
- **Credential Protection**: Automatic detection and prevention of credential theft attempts
|
|
12
|
-
- **LLM-based Evaluation**: AI-powered security threat and trust action evaluation
|
|
13
|
-
- **Role Management**: Hierarchical role system with OWNER, ADMIN, and NONE roles
|
|
14
|
-
- **Settings Management**: Onboarding and configuration system for world/server settings
|
|
15
|
-
- **Trust Interaction Tracking**: Record and analyze trust-affecting behaviors
|
|
16
|
-
- **Security Event Monitoring**: Track and respond to security incidents with trust impact
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
As this is a workspace package, it's installed as part of the ElizaOS monorepo:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
bun install
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Configuration
|
|
27
|
-
|
|
28
|
-
The plugin requires the following environment variables:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# World Configuration (Optional)
|
|
32
|
-
WORLD_ID=your_world_id
|
|
33
|
-
|
|
34
|
-
# Security Settings (Optional)
|
|
35
|
-
TRUST_SCORE_THRESHOLD=60 # Minimum trust score for certain actions
|
|
36
|
-
SECURITY_ALERT_THRESHOLD=0.8 # Threshold for security alerts
|
|
37
|
-
CREDENTIAL_SCAN_ENABLED=true # Enable credential theft scanning
|
|
38
|
-
|
|
39
|
-
# Permission Settings (Optional)
|
|
40
|
-
ELEVATION_DURATION_MINUTES=60 # Default elevation duration
|
|
41
|
-
MAX_ELEVATION_REQUESTS=5 # Max elevation requests per user per day
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Usage
|
|
45
|
-
|
|
46
|
-
```json
|
|
47
|
-
{
|
|
48
|
-
"plugins": [
|
|
49
|
-
...otherPlugins,
|
|
50
|
-
"@elizaos/plugin-trust"
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Available Actions
|
|
56
|
-
|
|
57
|
-
The plugin provides the following actions:
|
|
58
|
-
|
|
59
|
-
1. **UPDATE_ROLE** - Assign roles (Admin, Owner, None) to users in a channel
|
|
60
|
-
- Similes: `CHANGE_ROLE`, `SET_PERMISSIONS`, `ASSIGN_ROLE`, `MAKE_ADMIN`
|
|
61
|
-
|
|
62
|
-
2. **UPDATE_SETTINGS** - Save configuration settings during onboarding
|
|
63
|
-
- Similes: `UPDATE_SETTING`, `SAVE_SETTING`, `SET_CONFIGURATION`, `CONFIGURE`
|
|
64
|
-
|
|
65
|
-
3. **RECORD_TRUST_INTERACTION** - Record trust-affecting interactions between entities
|
|
66
|
-
- Similes: `record trust event`, `log trust interaction`, `track behavior`
|
|
67
|
-
|
|
68
|
-
4. **EVALUATE_TRUST** - Evaluate trust score and profile for an entity
|
|
69
|
-
- Similes: `check trust score`, `trust rating`, `show trust level`
|
|
70
|
-
|
|
71
|
-
5. **REQUEST_ELEVATION** - Request temporary elevation of permissions
|
|
72
|
-
- Similes: `need temporary access`, `request higher privileges`, `elevate my permissions`
|
|
73
|
-
|
|
74
|
-
### Providers
|
|
75
|
-
|
|
76
|
-
The plugin includes four state providers:
|
|
77
|
-
|
|
78
|
-
1. **roleProvider** - Provides role information for entities in a world
|
|
79
|
-
2. **settingsProvider** - Provides current settings and configuration state
|
|
80
|
-
3. **trustProfileProvider** - Provides detailed trust profile information
|
|
81
|
-
4. **securityStatusProvider** - Provides current security status and threat level
|
|
82
|
-
|
|
83
|
-
### Evaluators
|
|
84
|
-
|
|
85
|
-
1. **reflectionEvaluator** - Analyzes interactions for trust-affecting behaviors
|
|
86
|
-
2. **trustChangeEvaluator** - Automatically detects and records trust changes based on behavior patterns
|
|
87
|
-
|
|
88
|
-
### Services
|
|
89
|
-
|
|
90
|
-
The plugin registers five core services:
|
|
91
|
-
|
|
92
|
-
1. **TrustEngine** (`trust-engine`)
|
|
93
|
-
- Multi-dimensional trust scoring and evidence-based evaluation
|
|
94
|
-
- Trust profile calculation and decision making
|
|
95
|
-
- Interaction history tracking
|
|
96
|
-
|
|
97
|
-
2. **SecurityModule** (`security-module`)
|
|
98
|
-
- Threat detection and assessment
|
|
99
|
-
- Prompt injection detection
|
|
100
|
-
- Phishing and impersonation detection
|
|
101
|
-
- Security event logging with trust impact
|
|
102
|
-
|
|
103
|
-
3. **ContextualPermissionSystem** (`contextual-permissions`)
|
|
104
|
-
- Dynamic permission checking based on trust and context
|
|
105
|
-
- Permission elevation request handling
|
|
106
|
-
- Role-based access control integration
|
|
107
|
-
|
|
108
|
-
4. **CredentialProtector** (`credential-protector`)
|
|
109
|
-
- Credential theft detection and prevention
|
|
110
|
-
- Sensitive data protection
|
|
111
|
-
- Victim alerting system
|
|
112
|
-
|
|
113
|
-
5. **LLMEvaluator** (`llm-evaluator`)
|
|
114
|
-
- AI-powered security threat evaluation
|
|
115
|
-
- Behavioral analysis and anomaly detection
|
|
116
|
-
- Trust action evaluation with reasoning
|
|
117
|
-
|
|
118
|
-
## Trust System
|
|
119
|
-
|
|
120
|
-
### Trust Dimensions
|
|
121
|
-
|
|
122
|
-
The trust system evaluates entities across five dimensions:
|
|
123
|
-
- **Reliability**: Consistency in behavior and keeping promises
|
|
124
|
-
- **Competence**: Skill and capability demonstrations
|
|
125
|
-
- **Integrity**: Ethical behavior and honesty
|
|
126
|
-
- **Benevolence**: Positive intentions and helpfulness
|
|
127
|
-
- **Transparency**: Openness and clarity in communication
|
|
128
|
-
|
|
129
|
-
### Trust Evidence Types
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
enum TrustEvidenceType {
|
|
133
|
-
PROMISE_KEPT = 'PROMISE_KEPT',
|
|
134
|
-
PROMISE_BROKEN = 'PROMISE_BROKEN',
|
|
135
|
-
HELPFUL_ACTION = 'HELPFUL_ACTION',
|
|
136
|
-
HARMFUL_ACTION = 'HARMFUL_ACTION',
|
|
137
|
-
VERIFICATION_SUCCESS = 'VERIFICATION_SUCCESS',
|
|
138
|
-
VERIFICATION_FAILURE = 'VERIFICATION_FAILURE',
|
|
139
|
-
COMMUNITY_CONTRIBUTION = 'COMMUNITY_CONTRIBUTION',
|
|
140
|
-
SECURITY_VIOLATION = 'SECURITY_VIOLATION',
|
|
141
|
-
SPAM_BEHAVIOR = 'SPAM_BEHAVIOR',
|
|
142
|
-
SUSPICIOUS_ACTIVITY = 'SUSPICIOUS_ACTIVITY'
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Permission System
|
|
147
|
-
|
|
148
|
-
### Permission Types
|
|
149
|
-
|
|
150
|
-
The system supports various permission actions:
|
|
151
|
-
- `manage_roles`: Ability to change user roles
|
|
152
|
-
- `manage_settings`: Ability to modify world/server settings
|
|
153
|
-
- `moderate_content`: Content moderation capabilities
|
|
154
|
-
- `access_sensitive`: Access to sensitive information
|
|
155
|
-
- `execute_admin`: Execute administrative commands
|
|
156
|
-
|
|
157
|
-
### Permission Elevation
|
|
158
|
-
|
|
159
|
-
Users can request temporary permission elevation based on:
|
|
160
|
-
- Current trust score
|
|
161
|
-
- Justification provided
|
|
162
|
-
- Context of the request
|
|
163
|
-
- Historical behavior
|
|
164
|
-
|
|
165
|
-
## Security Features
|
|
166
|
-
|
|
167
|
-
### Threat Detection
|
|
168
|
-
|
|
169
|
-
The security module detects:
|
|
170
|
-
- Prompt injection attempts
|
|
171
|
-
- Credential theft attempts
|
|
172
|
-
- Phishing messages
|
|
173
|
-
- Impersonation attempts
|
|
174
|
-
- Multi-account abuse patterns
|
|
175
|
-
- Suspicious behavioral patterns
|
|
176
|
-
|
|
177
|
-
### Security Response
|
|
178
|
-
|
|
179
|
-
When threats are detected:
|
|
180
|
-
1. Security event is logged
|
|
181
|
-
2. Trust score is impacted
|
|
182
|
-
3. Potential victims are alerted
|
|
183
|
-
4. Access may be restricted
|
|
184
|
-
|
|
185
|
-
## Testing
|
|
186
|
-
|
|
187
|
-
The plugin includes comprehensive E2E tests accessible via:
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
import { tests } from '@elizaos/plugin-trust';
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Run tests with:
|
|
194
|
-
```bash
|
|
195
|
-
bun test
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Example Usage
|
|
199
|
-
|
|
200
|
-
### Evaluating Trust
|
|
201
|
-
```typescript
|
|
202
|
-
// User: "What is my trust score?"
|
|
203
|
-
// Agent: "Trust Level: Good (65/100) based on 42 interactions"
|
|
204
|
-
|
|
205
|
-
// User: "Show detailed trust profile for Alice"
|
|
206
|
-
// Agent provides detailed breakdown of trust dimensions
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Managing Roles
|
|
210
|
-
```typescript
|
|
211
|
-
// User: "Make @john an ADMIN"
|
|
212
|
-
// Agent: "Updated john's role to ADMIN."
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Requesting Elevation
|
|
216
|
-
```typescript
|
|
217
|
-
// User: "I need permission to manage roles to help moderate spam"
|
|
218
|
-
// Agent evaluates request based on trust and grants/denies
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
## Schema
|
|
222
|
-
|
|
223
|
-
The plugin uses Drizzle ORM with the following main tables:
|
|
224
|
-
- `trustInteractions`: Stores all trust-affecting interactions
|
|
225
|
-
- `trustProfiles`: Caches calculated trust profiles
|
|
226
|
-
- `securityEvents`: Logs security-related events
|
|
227
|
-
- `permissionGrants`: Tracks permission elevations
|
|
228
|
-
|
|
229
|
-
## Notes
|
|
230
|
-
|
|
231
|
-
- Trust scores range from 0-100 and affect available permissions
|
|
232
|
-
- The system maintains a complete audit trail of all trust-affecting actions
|
|
233
|
-
- Permission elevation is temporary and logged for security
|
|
234
|
-
- Trust profiles are recalculated based on recent interactions
|
|
235
|
-
- Security threats immediately impact trust scores
|
|
236
|
-
- The plugin integrates seamlessly with ElizaOS's world and role systems
|
|
237
|
-
- All actions respect the hierarchical role system (OWNER > ADMIN > NONE)
|
|
238
|
-
|
|
239
|
-
## Dependencies
|
|
240
|
-
|
|
241
|
-
- `@elizaos/core`: Core ElizaOS functionality
|
|
242
|
-
- `@elizaos/plugin-anthropic`: LLM evaluation capabilities
|
|
243
|
-
- `drizzle-orm`: Database ORM for trust data persistence
|
|
244
|
-
- `dedent`: String formatting for templates
|