@elizaos/plugin-trust 1.2.1 → 2.0.0-alpha.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.
Files changed (65) hide show
  1. package/dist/actions/evaluateTrust.d.ts +3 -0
  2. package/dist/actions/evaluateTrust.d.ts.map +1 -0
  3. package/dist/actions/index.d.ts +6 -0
  4. package/dist/actions/index.d.ts.map +1 -0
  5. package/dist/actions/recordTrustInteraction.d.ts +3 -0
  6. package/dist/actions/recordTrustInteraction.d.ts.map +1 -0
  7. package/dist/actions/requestElevation.d.ts +3 -0
  8. package/dist/actions/requestElevation.d.ts.map +1 -0
  9. package/dist/actions/roles.d.ts +13 -0
  10. package/dist/actions/roles.d.ts.map +1 -0
  11. package/dist/actions/settings.d.ts +21 -0
  12. package/dist/actions/settings.d.ts.map +1 -0
  13. package/dist/evaluators/index.d.ts +4 -0
  14. package/dist/evaluators/index.d.ts.map +1 -0
  15. package/dist/evaluators/reflection.d.ts +3 -0
  16. package/dist/evaluators/reflection.d.ts.map +1 -0
  17. package/dist/evaluators/securityEvaluator.d.ts +28 -0
  18. package/dist/evaluators/securityEvaluator.d.ts.map +1 -0
  19. package/dist/evaluators/trustChangeEvaluator.d.ts +3 -0
  20. package/dist/evaluators/trustChangeEvaluator.d.ts.map +1 -0
  21. package/dist/framework/TrustAwarePlugin.d.ts +60 -0
  22. package/dist/framework/TrustAwarePlugin.d.ts.map +1 -0
  23. package/dist/index.d.ts +34 -827
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +4834 -4203
  26. package/dist/index.js.map +33 -1
  27. package/dist/providers/adminTrust.d.ts +3 -0
  28. package/dist/providers/adminTrust.d.ts.map +1 -0
  29. package/dist/providers/index.d.ts +6 -0
  30. package/dist/providers/index.d.ts.map +1 -0
  31. package/dist/providers/roles.d.ts +19 -0
  32. package/dist/providers/roles.d.ts.map +1 -0
  33. package/dist/providers/securityStatus.d.ts +15 -0
  34. package/dist/providers/securityStatus.d.ts.map +1 -0
  35. package/dist/providers/settings.d.ts +7 -0
  36. package/dist/providers/settings.d.ts.map +1 -0
  37. package/dist/providers/trustProfile.d.ts +3 -0
  38. package/dist/providers/trustProfile.d.ts.map +1 -0
  39. package/dist/schema.d.ts +1170 -0
  40. package/dist/schema.d.ts.map +1 -0
  41. package/dist/services/ContextualPermissionSystem.d.ts +40 -0
  42. package/dist/services/ContextualPermissionSystem.d.ts.map +1 -0
  43. package/dist/services/CredentialProtector.d.ts +62 -0
  44. package/dist/services/CredentialProtector.d.ts.map +1 -0
  45. package/dist/services/SecurityModule.d.ts +145 -0
  46. package/dist/services/SecurityModule.d.ts.map +1 -0
  47. package/dist/services/SecurityStore.d.ts +53 -0
  48. package/dist/services/SecurityStore.d.ts.map +1 -0
  49. package/dist/services/TrustEngine.d.ts +81 -0
  50. package/dist/services/TrustEngine.d.ts.map +1 -0
  51. package/dist/services/db.d.ts +12 -0
  52. package/dist/services/db.d.ts.map +1 -0
  53. package/dist/services/index.d.ts +5 -0
  54. package/dist/services/index.d.ts.map +1 -0
  55. package/dist/tests.d.ts +3 -0
  56. package/dist/tests.d.ts.map +1 -0
  57. package/dist/types/permissions.d.ts +185 -0
  58. package/dist/types/permissions.d.ts.map +1 -0
  59. package/dist/types/security.d.ts +114 -0
  60. package/dist/types/security.d.ts.map +1 -0
  61. package/dist/types/trust.d.ts +179 -0
  62. package/dist/types/trust.d.ts.map +1 -0
  63. package/package.json +41 -16
  64. package/LICENSE +0 -21
  65. package/README.md +0 -244
@@ -0,0 +1,3 @@
1
+ import { type Action } from "@elizaos/core";
2
+ export declare const evaluateTrustAction: Action;
3
+ //# sourceMappingURL=evaluateTrust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluateTrust.d.ts","sourceRoot":"","sources":["../../src/actions/evaluateTrust.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAOZ,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,mBAAmB,EAAE,MAyQjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./evaluateTrust";
2
+ export * from "./recordTrustInteraction";
3
+ export * from "./requestElevation";
4
+ export * from "./roles";
5
+ export * from "./settings";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Action } from "@elizaos/core";
2
+ export declare const recordTrustInteractionAction: Action;
3
+ //# sourceMappingURL=recordTrustInteraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordTrustInteraction.d.ts","sourceRoot":"","sources":["../../src/actions/recordTrustInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,4BAA4B,EAAE,MA6N1C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Action } from "@elizaos/core";
2
+ export declare const requestElevationAction: Action;
3
+ //# sourceMappingURL=requestElevation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestElevation.d.ts","sourceRoot":"","sources":["../../src/actions/requestElevation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAKZ,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,sBAAsB,EAAE,MAwMpC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Action } from "@elizaos/core";
2
+ /**
3
+ * Represents an action to update the role of a user within a server.
4
+ * @typedef {Object} Action
5
+ * @property {string} name - The name of the action.
6
+ * @property {string[]} similes - The similar actions that can be performed.
7
+ * @property {string} description - A description of the action and its purpose.
8
+ * @property {Function} validate - A function to validate the action before execution.
9
+ * @property {Function} handler - A function to handle the execution of the action.
10
+ * @property {ActionExample[][]} examples - Examples demonstrating how the action can be used.
11
+ */
12
+ export declare const updateRoleAction: Action;
13
+ //# sourceMappingURL=roles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/actions/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAcZ,MAAM,eAAe,CAAC;AAiFvB;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAkT9B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type Action, type IAgentRuntime, type WorldSettings } from "@elizaos/core";
2
+ /**
3
+ * Gets settings state from world metadata
4
+ */
5
+ /**
6
+ * Retrieves the settings for a specific world from the database.
7
+ * @param {IAgentRuntime} runtime - The Agent Runtime instance.
8
+ * @param {string} serverId - The ID of the server.
9
+ * @returns {Promise<WorldSettings | null>} The settings of the world, or null if not found.
10
+ */
11
+ export declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Promise<WorldSettings | null>;
12
+ /**
13
+ * Updates settings state in world metadata
14
+ */
15
+ export declare function updateWorldSettings(runtime: IAgentRuntime, serverId: string, worldSettings: WorldSettings): Promise<boolean>;
16
+ /**
17
+ * Enhanced settings action with improved state management and logging
18
+ * Updated to use world metadata instead of cache
19
+ */
20
+ export declare const updateSettingsAction: Action;
21
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/actions/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAUX,KAAK,aAAa,EAOlB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAsNvB;;GAEG;AACH;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAc/B;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,OAAO,CAAC,CA0BlB;AAiZD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MA+ZlC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./reflection";
2
+ export * from "./securityEvaluator";
3
+ export * from "./trustChangeEvaluator";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluators/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Evaluator } from "@elizaos/core";
2
+ export declare const reflectionEvaluator: Evaluator;
3
+ //# sourceMappingURL=reflection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflection.d.ts","sourceRoot":"","sources":["../../src/evaluators/reflection.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAUf,MAAM,eAAe,CAAC;AAkRvB,eAAO,MAAM,mBAAmB,EAAE,SA+LjC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Security pre-evaluator — runs as middleware BEFORE memory storage.
3
+ *
4
+ * Uses ONLY fast heuristic checks to detect adversarial inputs. No LLM calls.
5
+ * The pre-evaluator is a gate — it blocks obvious threats based on pattern
6
+ * matching and structural analysis. Nuanced cases that need LLM understanding
7
+ * go through the normal agent pipeline (trustChangeEvaluator handles those).
8
+ *
9
+ * Heuristic signals:
10
+ * - Encoded content (Base64, hex)
11
+ * - Unusual spacing / zero-width characters / leet-speak
12
+ * - Structural injection (ChatML tokens, JSON/XML role payloads)
13
+ * - Multi-language injection keywords (8 languages)
14
+ * - Classic injection / social engineering / credential request keywords
15
+ * - Negation awareness (warnings about credentials are not requests)
16
+ *
17
+ * When high-confidence signals fire, the message is blocked immediately —
18
+ * no memory storage, no response generation, no action execution.
19
+ *
20
+ * Low-confidence signals (encoding, leet-speak without keywords) are logged
21
+ * but the message passes through for the agent to handle normally.
22
+ *
23
+ * The evaluator trusts the agent's owner — if the sender is the owner
24
+ * entity the message is always allowed through.
25
+ */
26
+ import { type Evaluator } from "@elizaos/core";
27
+ export declare const securityEvaluator: Evaluator;
28
+ //# sourceMappingURL=securityEvaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityEvaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/securityEvaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,eAAe,CAAC;AAwNvB,eAAO,MAAM,iBAAiB,EAAE,SA4G/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Evaluator } from "@elizaos/core";
2
+ export declare const trustChangeEvaluator: Evaluator;
3
+ //# sourceMappingURL=trustChangeEvaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trustChangeEvaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/trustChangeEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAuD,MAAM,eAAe,CAAC;AAQpG,eAAO,MAAM,oBAAoB,EAAE,SAoOlC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { type Action, type Evaluator, type IAgentRuntime, type Memory, type Plugin, type Provider, type ServiceClass, type UUID } from "@elizaos/core";
2
+ import type { ContextualPermissionSystem } from "../services/ContextualPermissionSystem";
3
+ import type { SecurityModule } from "../services/SecurityModule";
4
+ import type { TrustEngine } from "../services/TrustEngine";
5
+ import { type ActionPermission } from "../types/permissions";
6
+ /**
7
+ * Base class for trust-aware plugins
8
+ * Provides automatic trust checking and permission management
9
+ */
10
+ export declare abstract class TrustAwarePlugin implements Plugin {
11
+ protected trustEngine: TrustEngine | null;
12
+ protected permissionSystem: ContextualPermissionSystem | null;
13
+ protected securityModule: SecurityModule | null;
14
+ /**
15
+ * Define required trust levels for actions
16
+ * Override in subclasses
17
+ */
18
+ protected abstract trustRequirements: Record<string, number>;
19
+ /**
20
+ * Define required permissions for actions
21
+ * Override in subclasses
22
+ */
23
+ protected abstract permissions: Record<string, ActionPermission>;
24
+ /**
25
+ * Initialize trust-aware services
26
+ */
27
+ init(_config: Record<string, string>, runtime: IAgentRuntime): Promise<void>;
28
+ /**
29
+ * Wrap an action with trust and permission checking
30
+ */
31
+ protected wrapAction(action: Action): Action;
32
+ /**
33
+ * Check if user has permission to execute action
34
+ */
35
+ protected checkPermission(runtime: IAgentRuntime, message: Memory, permission: ActionPermission): Promise<boolean>;
36
+ /**
37
+ * Get trust level for a user
38
+ */
39
+ protected getTrustLevel(runtime: IAgentRuntime, userId: UUID): Promise<number>;
40
+ /**
41
+ * Check if user is trusted (>= 80 trust score)
42
+ */
43
+ protected isTrusted(runtime: IAgentRuntime, userId: UUID): Promise<boolean>;
44
+ /**
45
+ * Check if user is admin
46
+ */
47
+ protected isAdmin(_userId: UUID): boolean;
48
+ /**
49
+ * Check if user is system/agent
50
+ */
51
+ protected isSystem(_userId: UUID): boolean;
52
+ abstract name: string;
53
+ abstract description: string;
54
+ abstract actions?: Action[];
55
+ abstract providers?: Provider[];
56
+ abstract evaluators?: Evaluator[];
57
+ abstract services?: ServiceClass[];
58
+ }
59
+ export declare const exampleTrustAwarePlugin: Plugin;
60
+ //# sourceMappingURL=TrustAwarePlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrustAwarePlugin.d.ts","sourceRoot":"","sources":["../../src/framework/TrustAwarePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,SAAS,EACd,KAAK,aAAa,EAElB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,YAAY,EAEjB,KAAK,I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