@jhinresh/elizaos-plugin 0.1.1 → 0.1.2

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/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @jhinresh/elizaos-plugin
2
+
3
+ > Maiat Trust Score plugin for ElizaOS — verify trust before your agent swaps or transacts.
4
+
5
+ Adds trust-checking actions and evaluators to any ElizaOS agent so it can **refuse to interact with low-trust addresses** before executing swaps, transfers, or on-chain actions.
6
+
7
+ Powered by [Maiat Protocol](https://maiat-protocol.vercel.app) — on-chain verified trust scores for tokens, DeFi protocols, and AI agents on Base.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @jhinresh/elizaos-plugin
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { maiatPlugin } from "@jhinresh/elizaos-plugin";
19
+
20
+ const agent = new ElizaAgent({
21
+ plugins: [
22
+ maiatPlugin({
23
+ minScore: 3.0, // reject addresses with score < 3.0/10
24
+ chain: "base",
25
+ }),
26
+ ],
27
+ });
28
+ ```
29
+
30
+ ## What it does
31
+
32
+ | Component | Type | Behaviour |
33
+ |-----------|------|-----------|
34
+ | `CHECK_TRUST` | Action | Agent can ask "is 0x... safe?" and get a trust score |
35
+ | `TRUST_GATE` | Evaluator | Runs before any swap/transfer — rejects low-trust addresses |
36
+ | `TRUST_DATA` | Provider | Injects trust context into agent's world state |
37
+
38
+ ## Trust Score Scale
39
+
40
+ | Score | Risk | Action |
41
+ |-------|------|--------|
42
+ | 7–10 | 🟢 Low | Allow |
43
+ | 4–6.9 | 🟡 Medium | Warn |
44
+ | 0–3.9 | 🔴 High | **Block** |
45
+
46
+ ## Config
47
+
48
+ ```typescript
49
+ maiatPlugin({
50
+ apiUrl: "https://maiat-protocol.vercel.app", // default
51
+ apiKey: "your-key", // optional — free tier: 100 req/day
52
+ minScore: 3.0, // 0–10 scale
53
+ chain: "base", // base | bnb | solana
54
+ })
55
+ ```
56
+
57
+ ## Links
58
+
59
+ - 🌐 [Live app](https://maiat-protocol.vercel.app)
60
+ - 📖 [API docs](https://maiat-protocol.vercel.app/docs)
61
+ - 🔗 [GitHub](https://github.com/JhiNResH/maiat-protocol)
62
+ - 📦 [npm](https://www.npmjs.com/package/@jhinresh/elizaos-plugin)
63
+
64
+ ## License
65
+
66
+ MIT
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @maiat/elizaos-plugin
3
+ *
4
+ * Maiat Trust Score plugin for ElizaOS (ai16z agent framework).
5
+ *
6
+ * Adds trust checking capabilities to any ElizaOS agent:
7
+ * - "Is this address safe?" → trust score lookup
8
+ * - Auto-gate transactions before execution
9
+ * - Report transaction outcomes back to Maiat
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { maiatPlugin } from "@maiat/elizaos-plugin";
14
+ *
15
+ * const agent = new ElizaAgent({
16
+ * plugins: [maiatPlugin({ minScore: 3.0 })],
17
+ * });
18
+ * ```
19
+ */
20
+ export interface MaiatElizaConfig {
21
+ apiUrl?: string;
22
+ apiKey?: string;
23
+ chain?: string;
24
+ minScore?: number;
25
+ }
26
+ interface TrustResult {
27
+ address: string;
28
+ score: number;
29
+ risk: string;
30
+ type: string;
31
+ flags: string[];
32
+ safe: boolean;
33
+ }
34
+ /**
35
+ * ElizaOS plugin definition following the standard plugin interface.
36
+ *
37
+ * Registers:
38
+ * - Action: CHECK_TRUST — responds to "is 0x... safe?" type queries
39
+ * - Evaluator: TRUST_GATE — evaluates if an address should be interacted with
40
+ * - Provider: TRUST_DATA — provides trust context for agent reasoning
41
+ */
42
+ export declare function maiatPlugin(config?: MaiatElizaConfig): {
43
+ name: string;
44
+ description: string;
45
+ actions: {
46
+ name: string;
47
+ description: string;
48
+ examples: string[];
49
+ validate: (message: string) => Promise<boolean>;
50
+ handler: (message: string) => Promise<{
51
+ text: string;
52
+ data?: undefined;
53
+ } | {
54
+ text: string;
55
+ data: TrustResult;
56
+ }>;
57
+ }[];
58
+ evaluators: {
59
+ name: string;
60
+ description: string;
61
+ handler: (context: {
62
+ address?: string;
63
+ }) => Promise<{
64
+ pass: boolean;
65
+ reason: string;
66
+ score?: undefined;
67
+ risk?: undefined;
68
+ } | {
69
+ pass: boolean;
70
+ score: number;
71
+ risk: string;
72
+ reason: string;
73
+ }>;
74
+ }[];
75
+ providers: {
76
+ name: string;
77
+ description: string;
78
+ handler: () => Promise<{
79
+ text: string;
80
+ }>;
81
+ }[];
82
+ };
83
+ export default maiatPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,130 @@
1
+ /**
2
+ * @maiat/elizaos-plugin
3
+ *
4
+ * Maiat Trust Score plugin for ElizaOS (ai16z agent framework).
5
+ *
6
+ * Adds trust checking capabilities to any ElizaOS agent:
7
+ * - "Is this address safe?" → trust score lookup
8
+ * - Auto-gate transactions before execution
9
+ * - Report transaction outcomes back to Maiat
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { maiatPlugin } from "@maiat/elizaos-plugin";
14
+ *
15
+ * const agent = new ElizaAgent({
16
+ * plugins: [maiatPlugin({ minScore: 3.0 })],
17
+ * });
18
+ * ```
19
+ */
20
+ // ═══════════════════════════════════════════
21
+ // API Client (lightweight)
22
+ // ═══════════════════════════════════════════
23
+ async function queryMaiat(address, config) {
24
+ const apiUrl = config.apiUrl || "https://maiat-protocol.vercel.app";
25
+ const chain = config.chain || "base";
26
+ const minScore = config.minScore ?? 3.0;
27
+ const headers = {
28
+ "User-Agent": "maiat-elizaos-plugin/0.1.0",
29
+ };
30
+ if (config.apiKey)
31
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
32
+ const res = await fetch(`${apiUrl}/api/v1/score/${address}?chain=${chain}`, { headers });
33
+ if (!res.ok) {
34
+ throw new Error(`Maiat API error: ${res.status}`);
35
+ }
36
+ const data = await res.json();
37
+ return {
38
+ address: data.address,
39
+ score: data.score,
40
+ risk: data.risk,
41
+ type: data.type,
42
+ flags: data.flags || [],
43
+ safe: data.score >= minScore,
44
+ };
45
+ }
46
+ // ═══════════════════════════════════════════
47
+ // ElizaOS Plugin
48
+ // ═══════════════════════════════════════════
49
+ /**
50
+ * ElizaOS plugin definition following the standard plugin interface.
51
+ *
52
+ * Registers:
53
+ * - Action: CHECK_TRUST — responds to "is 0x... safe?" type queries
54
+ * - Evaluator: TRUST_GATE — evaluates if an address should be interacted with
55
+ * - Provider: TRUST_DATA — provides trust context for agent reasoning
56
+ */
57
+ export function maiatPlugin(config = {}) {
58
+ return {
59
+ name: "maiat-trust",
60
+ description: "Trust scoring for on-chain addresses via Maiat Protocol",
61
+ actions: [
62
+ {
63
+ name: "CHECK_TRUST",
64
+ description: "Check the trust score of an on-chain address",
65
+ examples: [
66
+ "Is 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24 safe?",
67
+ "Check trust score for 0x1234...",
68
+ "Should I interact with this address: 0xabcd...?",
69
+ ],
70
+ validate: async (message) => {
71
+ return /0x[a-fA-F0-9]{40}/.test(message);
72
+ },
73
+ handler: async (message) => {
74
+ const match = message.match(/0x[a-fA-F0-9]{40}/);
75
+ if (!match)
76
+ return { text: "Please provide a valid Ethereum address (0x...)" };
77
+ try {
78
+ const result = await queryMaiat(match[0], config);
79
+ const emoji = result.safe ? "🟢" : result.risk === "CRITICAL" ? "🔴" : "🟡";
80
+ return {
81
+ text: `${emoji} **Trust Score: ${result.score}/10** (${result.risk} risk)\n\nAddress: \`${result.address}\`\nType: ${result.type}\nFlags: ${result.flags.join(", ") || "None"}\n\n${result.safe ? "✅ Safe to interact." : "⚠️ Exercise caution — low trust score."}`,
82
+ data: result,
83
+ };
84
+ }
85
+ catch (error) {
86
+ return {
87
+ text: `❌ Could not check trust score: ${error instanceof Error ? error.message : "Unknown error"}`,
88
+ };
89
+ }
90
+ },
91
+ },
92
+ ],
93
+ evaluators: [
94
+ {
95
+ name: "TRUST_GATE",
96
+ description: "Evaluates if a target address meets minimum trust requirements",
97
+ handler: async (context) => {
98
+ if (!context.address)
99
+ return { pass: true, reason: "No address to check" };
100
+ try {
101
+ const result = await queryMaiat(context.address, config);
102
+ return {
103
+ pass: result.safe,
104
+ score: result.score,
105
+ risk: result.risk,
106
+ reason: result.safe
107
+ ? `Address trusted (${result.score}/10)`
108
+ : `Address untrusted (${result.score}/10, ${result.risk} risk)`,
109
+ };
110
+ }
111
+ catch {
112
+ return { pass: false, reason: "Trust check failed — blocking by default" };
113
+ }
114
+ },
115
+ },
116
+ ],
117
+ providers: [
118
+ {
119
+ name: "TRUST_DATA",
120
+ description: "Provides trust scoring context for agent reasoning",
121
+ handler: async () => {
122
+ return {
123
+ text: "You have access to Maiat trust scoring. Before interacting with any unknown on-chain address, use CHECK_TRUST to verify it's safe. Addresses scoring below 3.0/10 should be avoided.",
124
+ };
125
+ },
126
+ },
127
+ ],
128
+ };
129
+ }
130
+ export default maiatPlugin;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jhinresh/elizaos-plugin",
3
- "version": "0.1.1",
4
- "description": "Maiat Trust Score plugin for ElizaOS — trust-gated agent interactions",
3
+ "version": "0.1.2",
4
+ "description": "Maiat Trust Score plugin for ElizaOS — verify trust before your agent swaps or transacts",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -10,14 +10,23 @@
10
10
  "build": "tsc",
11
11
  "dev": "tsc --watch"
12
12
  },
13
- "devDependencies": {
14
- "typescript": "^5.5.0"
15
- },
16
13
  "keywords": [
17
14
  "maiat",
18
15
  "elizaos",
16
+ "eliza",
19
17
  "ai16z",
20
18
  "trust-score",
21
- "ai-agent"
22
- ]
19
+ "ai-agent",
20
+ "web3",
21
+ "defi",
22
+ "base"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/JhiNResH/elizaos-plugin-maiat.git"
27
+ },
28
+ "homepage": "https://maiat-protocol.vercel.app",
29
+ "devDependencies": {
30
+ "typescript": "^5.5.0"
31
+ }
23
32
  }