@jhinresh/elizaos-plugin 0.2.1 → 0.7.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/index.d.ts CHANGED
@@ -1,43 +1,11 @@
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
1
  export interface MaiatElizaConfig {
21
2
  apiUrl?: string;
22
3
  apiKey?: string;
23
4
  chain?: string;
24
5
  minScore?: number;
25
6
  }
26
- interface TrustResult {
27
- address: string;
28
- score: number;
29
- risk: string;
30
- type: string;
31
- flags: string[];
32
- safe: boolean;
33
- }
34
7
  /**
35
8
  * 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
9
  */
42
10
  export declare function maiatPlugin(config?: MaiatElizaConfig): {
43
11
  name: string;
@@ -52,7 +20,7 @@ export declare function maiatPlugin(config?: MaiatElizaConfig): {
52
20
  data?: undefined;
53
21
  } | {
54
22
  text: string;
55
- data: TrustResult;
23
+ data: import("maiat-sdk").AgentTrustResult;
56
24
  }>;
57
25
  }[];
58
26
  evaluators: {
@@ -64,11 +32,11 @@ export declare function maiatPlugin(config?: MaiatElizaConfig): {
64
32
  pass: boolean;
65
33
  reason: string;
66
34
  score?: undefined;
67
- risk?: undefined;
35
+ verdict?: undefined;
68
36
  } | {
69
37
  pass: boolean;
70
38
  score: number;
71
- risk: string;
39
+ verdict: "proceed" | "caution" | "avoid";
72
40
  reason: string;
73
41
  }>;
74
42
  }[];
package/dist/index.js CHANGED
@@ -1,60 +1,15 @@
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://app.maiat.io";
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
- // ═══════════════════════════════════════════
1
+ import { Maiat } from "maiat-sdk";
49
2
  /**
50
3
  * 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
4
  */
57
5
  export function maiatPlugin(config = {}) {
6
+ const sdk = new Maiat({
7
+ baseUrl: config.apiUrl,
8
+ apiKey: config.apiKey,
9
+ framework: "elizaos",
10
+ clientId: "elizaos-plugin-standard"
11
+ });
12
+ const minScore = config.minScore ?? 60; // SDK uses 0-100 scale
58
13
  return {
59
14
  name: "maiat-trust",
60
15
  description: "Trust scoring for on-chain addresses via Maiat Protocol",
@@ -75,10 +30,11 @@ export function maiatPlugin(config = {}) {
75
30
  if (!match)
76
31
  return { text: "Please provide a valid Ethereum address (0x...)" };
77
32
  try {
78
- const result = await queryMaiat(match[0], config);
79
- const emoji = result.safe ? "🟢" : result.risk === "CRITICAL" ? "🔴" : "🟡";
33
+ const result = await sdk.agentTrust(match[0]);
34
+ const safe = result.trustScore >= minScore;
35
+ const emoji = safe ? "🟢" : result.verdict === "avoid" ? "🔴" : "🟡";
80
36
  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."}`,
37
+ text: `${emoji} **Trust Score: ${result.trustScore}/100** (${result.verdict} verdict)\n\nAddress: \`${result.address}\`\nSource: ${result.dataSource}\nJobs: ${result.breakdown.totalJobs}\n\n${safe ? "✅ Safe to interact." : "⚠️ Exercise caution — score below threshold."}`,
82
38
  data: result,
83
39
  };
84
40
  }
@@ -98,14 +54,15 @@ export function maiatPlugin(config = {}) {
98
54
  if (!context.address)
99
55
  return { pass: true, reason: "No address to check" };
100
56
  try {
101
- const result = await queryMaiat(context.address, config);
57
+ const result = await sdk.agentTrust(context.address);
58
+ const safe = result.trustScore >= minScore;
102
59
  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)`,
60
+ pass: safe,
61
+ score: result.trustScore,
62
+ verdict: result.verdict,
63
+ reason: safe
64
+ ? `Address trusted (${result.trustScore}/100)`
65
+ : `Address untrusted (${result.trustScore}/100, ${result.verdict} verdict)`,
109
66
  };
110
67
  }
111
68
  catch {
@@ -120,7 +77,7 @@ export function maiatPlugin(config = {}) {
120
77
  description: "Provides trust scoring context for agent reasoning",
121
78
  handler: async () => {
122
79
  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.",
80
+ 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 ${minScore}/100 should be avoided.`,
124
81
  };
125
82
  },
126
83
  },
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@jhinresh/elizaos-plugin",
3
- "version": "0.2.1",
3
+ "version": "0.7.3",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Maiat Trust Score plugin for ElizaOS — verify trust before your agent swaps or transacts",
5
8
  "license": "MIT",
6
9
  "type": "module",
@@ -10,6 +13,9 @@
10
13
  "build": "tsc",
11
14
  "dev": "tsc --watch"
12
15
  },
16
+ "dependencies": {
17
+ "@jhinresh/maiat-sdk": "^0.7.3"
18
+ },
13
19
  "keywords": [
14
20
  "maiat",
15
21
  "elizaos",
@@ -29,4 +35,4 @@
29
35
  "devDependencies": {
30
36
  "typescript": "^5.5.0"
31
37
  }
32
- }
38
+ }
package/src/index.ts CHANGED
@@ -1,26 +1,4 @@
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
- // ═══════════════════════════════════════════
22
- // Types
23
- // ═══════════════════════════════════════════
1
+ import { Maiat } from "@jhinresh/maiat-sdk";
24
2
 
25
3
  export interface MaiatElizaConfig {
26
4
  apiUrl?: string;
@@ -29,62 +7,19 @@ export interface MaiatElizaConfig {
29
7
  minScore?: number;
30
8
  }
31
9
 
32
- interface TrustResult {
33
- address: string;
34
- score: number;
35
- risk: string;
36
- type: string;
37
- flags: string[];
38
- safe: boolean;
39
- }
40
-
41
- // ═══════════════════════════════════════════
42
- // API Client (lightweight)
43
- // ═══════════════════════════════════════════
44
-
45
- async function queryMaiat(
46
- address: string,
47
- config: MaiatElizaConfig
48
- ): Promise<TrustResult> {
49
- const apiUrl = config.apiUrl || "https://app.maiat.io";
50
- const chain = config.chain || "base";
51
- const minScore = config.minScore ?? 3.0;
52
-
53
- const headers: Record<string, string> = {
54
- "User-Agent": "maiat-elizaos-plugin/0.1.0",
55
- };
56
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
57
-
58
- const res = await fetch(`${apiUrl}/api/v1/score/${address}?chain=${chain}`, { headers });
59
-
60
- if (!res.ok) {
61
- throw new Error(`Maiat API error: ${res.status}`);
62
- }
63
-
64
- const data = await res.json();
65
- return {
66
- address: data.address,
67
- score: data.score,
68
- risk: data.risk,
69
- type: data.type,
70
- flags: data.flags || [],
71
- safe: data.score >= minScore,
72
- };
73
- }
74
-
75
- // ═══════════════════════════════════════════
76
- // ElizaOS Plugin
77
- // ═══════════════════════════════════════════
78
-
79
10
  /**
80
11
  * ElizaOS plugin definition following the standard plugin interface.
81
- *
82
- * Registers:
83
- * - Action: CHECK_TRUST — responds to "is 0x... safe?" type queries
84
- * - Evaluator: TRUST_GATE — evaluates if an address should be interacted with
85
- * - Provider: TRUST_DATA — provides trust context for agent reasoning
86
12
  */
87
13
  export function maiatPlugin(config: MaiatElizaConfig = {}) {
14
+ const sdk = new Maiat({
15
+ baseUrl: config.apiUrl,
16
+ apiKey: config.apiKey,
17
+ framework: "elizaos",
18
+ clientId: "elizaos-plugin-standard"
19
+ });
20
+
21
+ const minScore = config.minScore ?? 60; // SDK uses 0-100 scale
22
+
88
23
  return {
89
24
  name: "maiat-trust",
90
25
  description: "Trust scoring for on-chain addresses via Maiat Protocol",
@@ -106,11 +41,12 @@ export function maiatPlugin(config: MaiatElizaConfig = {}) {
106
41
  if (!match) return { text: "Please provide a valid Ethereum address (0x...)" };
107
42
 
108
43
  try {
109
- const result = await queryMaiat(match[0], config);
110
- const emoji = result.safe ? "🟢" : result.risk === "CRITICAL" ? "🔴" : "🟡";
44
+ const result = await sdk.agentTrust(match[0]);
45
+ const safe = result.trustScore >= minScore;
46
+ const emoji = safe ? "🟢" : result.verdict === "avoid" ? "🔴" : "🟡";
111
47
 
112
48
  return {
113
- 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."}`,
49
+ text: `${emoji} **Trust Score: ${result.trustScore}/100** (${result.verdict} verdict)\n\nAddress: \`${result.address}\`\nSource: ${result.dataSource}\nJobs: ${result.breakdown.totalJobs}\n\n${safe ? "✅ Safe to interact." : "⚠️ Exercise caution — score below threshold."}`,
114
50
  data: result,
115
51
  };
116
52
  } catch (error) {
@@ -130,14 +66,15 @@ export function maiatPlugin(config: MaiatElizaConfig = {}) {
130
66
  if (!context.address) return { pass: true, reason: "No address to check" };
131
67
 
132
68
  try {
133
- const result = await queryMaiat(context.address, config);
69
+ const result = await sdk.agentTrust(context.address);
70
+ const safe = result.trustScore >= minScore;
134
71
  return {
135
- pass: result.safe,
136
- score: result.score,
137
- risk: result.risk,
138
- reason: result.safe
139
- ? `Address trusted (${result.score}/10)`
140
- : `Address untrusted (${result.score}/10, ${result.risk} risk)`,
72
+ pass: safe,
73
+ score: result.trustScore,
74
+ verdict: result.verdict,
75
+ reason: safe
76
+ ? `Address trusted (${result.trustScore}/100)`
77
+ : `Address untrusted (${result.trustScore}/100, ${result.verdict} verdict)`,
141
78
  };
142
79
  } catch {
143
80
  return { pass: false, reason: "Trust check failed — blocking by default" };
@@ -152,7 +89,7 @@ export function maiatPlugin(config: MaiatElizaConfig = {}) {
152
89
  description: "Provides trust scoring context for agent reasoning",
153
90
  handler: async () => {
154
91
  return {
155
- 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.",
92
+ 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 ${minScore}/100 should be avoided.`,
156
93
  };
157
94
  },
158
95
  },