@diogenesgateway/eliza-plugin-diogenes 0.0.0-stage → 1.0.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.
- package/README.md +64 -2
- package/package.json +30 -3
- package/src/index.ts +184 -0
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Diogenes Plugin for ElizaOS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A drop-in **ElizaOS** plugin equipping autonomous Solana agents with:
|
|
4
|
+
- **SPL Token Risk Audits**: Verify freeze authority, mint authority, and honeypot transfer taxes before executing token swaps.
|
|
5
|
+
- **Smart Contract Honeypot Audits**: Audit Anchor and Solana Rust programs before signing transactions.
|
|
6
|
+
- **Pre-Execution Guardrails**: Evaluate user prompts and agent thoughts for prompt injection, key exfiltration, and wallet drains.
|
|
7
|
+
- **x402 Micropayments & Zero-Fee Demo Mode**: Instant testing with `demoMode: true`.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🚀 Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Add to your ElizaOS project
|
|
15
|
+
npm install @diogenes/elizaos-plugin
|
|
16
|
+
# or link locally from integrations/elizaos
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🛠️ Usage in ElizaOS Character
|
|
22
|
+
|
|
23
|
+
Add `diogenesPlugin` to your character's `plugins` array:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { diogenesPlugin } from "@diogenes/elizaos-plugin";
|
|
27
|
+
|
|
28
|
+
export const character = {
|
|
29
|
+
name: "SolanaSecurityAgent",
|
|
30
|
+
plugins: [diogenesPlugin],
|
|
31
|
+
system: "You are an autonomous on-chain trader that verifies SPL token safety and audits contracts before executing transactions.",
|
|
32
|
+
// ...
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## ⚡ Actions Available
|
|
39
|
+
|
|
40
|
+
### 1. `CHECK_SPL_TOKEN_RISK`
|
|
41
|
+
Analyzes any SPL token mint address in real time:
|
|
42
|
+
```text
|
|
43
|
+
User: "Is mint 7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr safe to buy?"
|
|
44
|
+
Agent: "Auditing SPL token with Diogenes Risk Oracle...
|
|
45
|
+
Verdict: SAFE
|
|
46
|
+
Freeze Authority: Disabled (Safe)
|
|
47
|
+
Mint Authority: Revoked (Safe)"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. `AUDIT_SMART_CONTRACT`
|
|
51
|
+
Audits Anchor / Rust / Solidity code for backdoors and reentrancy bugs:
|
|
52
|
+
```text
|
|
53
|
+
User: "Can you review this Anchor program instruction for vulnerabilities?"
|
|
54
|
+
Agent: "Running contract audit... 0 critical vulnerabilities found."
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 3. `ENFORCE_GUARDRAIL`
|
|
58
|
+
Pre-execution security barrier verifying that agent commands and prompts are free of prompt injection or destructive terminal instructions.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🌐 Endpoints & Edge Infrastructure
|
|
63
|
+
- **Live Gateway**: [https://diogenes-micro-gateway.corinth.workers.dev](https://diogenes-micro-gateway.corinth.workers.dev)
|
|
64
|
+
- **MCP Catalog**: [https://diogenes-micro-gateway.corinth.workers.dev/.well-known/mcp.json](https://diogenes-micro-gateway.corinth.workers.dev/.well-known/mcp.json)
|
|
65
|
+
- **Solana x402 Treasury**: `3vuU9jvaohMG6oPY7NVrUggcSJ4CuhcByxoQk68EC6hj`
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diogenesgateway/eliza-plugin-diogenes",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ElizaOS plugin for Diogenes edge microservices, Solana token risk audits, and x402 micropayments",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "node --test"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"elizaos",
|
|
14
|
+
"solana",
|
|
15
|
+
"ai-agent",
|
|
16
|
+
"x402",
|
|
17
|
+
"mcp",
|
|
18
|
+
"microservices",
|
|
19
|
+
"guardrails"
|
|
20
|
+
],
|
|
21
|
+
"author": "Diogenes Gateway",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@elizaos/core": ">=0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.4.0"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/stand-out-of-my-sun/eliza-plugin-diogenes.git"
|
|
32
|
+
}
|
|
6
33
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diogenes Plugin for ElizaOS
|
|
3
|
+
* Provides autonomous Solana agents with real-time SPL token risk inspection,
|
|
4
|
+
* smart contract honeypot audits, pre-execution safety guardrails, and x402 micropayments.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface DiogenesPluginConfig {
|
|
8
|
+
gatewayUrl?: string;
|
|
9
|
+
demoMode?: boolean;
|
|
10
|
+
solanaKeypairBase58?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const DEFAULT_GATEWAY_URL = "https://diogenes-micro-gateway.corinth.workers.dev";
|
|
14
|
+
const SOLANA_X402_WALLET = "3vuU9jvaohMG6oPY7NVrUggcSJ4CuhcByxoQk68EC6hj";
|
|
15
|
+
|
|
16
|
+
export class DiogenesClient {
|
|
17
|
+
private gatewayUrl: string;
|
|
18
|
+
private demoMode: boolean;
|
|
19
|
+
private keypairBase58?: string;
|
|
20
|
+
|
|
21
|
+
constructor(config: DiogenesPluginConfig = {}) {
|
|
22
|
+
this.gatewayUrl = (config.gatewayUrl || DEFAULT_GATEWAY_URL).replace(/\/$/, "");
|
|
23
|
+
this.demoMode = config.demoMode ?? true; // Default to demo mode for safety
|
|
24
|
+
this.keypairBase58 = config.solanaKeypairBase58;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async callEndpoint(endpoint: string, payload: Record<string, unknown>): Promise<any> {
|
|
28
|
+
let url = `${this.gatewayUrl}${endpoint}`;
|
|
29
|
+
if (this.demoMode && !url.includes("?demo=true")) {
|
|
30
|
+
url += "?demo=true";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const headers: Record<string, string> = {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
"User-Agent": "ElizaOS-DiogenesPlugin/1.0",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const res = await fetch(url, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers,
|
|
41
|
+
body: JSON.stringify(payload),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (res.status === 402 && !this.demoMode && this.keypairBase58) {
|
|
45
|
+
// In production x402 mode, client can sign transaction or pass signature
|
|
46
|
+
const challenge = await res.json();
|
|
47
|
+
throw new Error(`Payment Required: ${JSON.stringify(challenge)}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return await res.json();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Evaluates SPL token mint address for active freeze authority, mint authority,
|
|
55
|
+
* honeypot transfer taxes, and binary should_transact verdict.
|
|
56
|
+
*/
|
|
57
|
+
async checkSplTokenRisk(mintAddress: string): Promise<any> {
|
|
58
|
+
return this.callEndpoint("/api/v1/crypto/solana-risk", {
|
|
59
|
+
mint_address: mintAddress,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Audits Anchor or Rust smart contract code before deployment or invocation.
|
|
65
|
+
*/
|
|
66
|
+
async auditSolanaProgram(code: string): Promise<any> {
|
|
67
|
+
return this.callEndpoint("/api/v1/agent/contract-audit", {
|
|
68
|
+
contract_code: code,
|
|
69
|
+
language: "rust_anchor",
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Evaluates prompt or action text for prompt injection, key theft, or destructive commands.
|
|
75
|
+
*/
|
|
76
|
+
async verifyGuardrail(input: string, context: string = ""): Promise<any> {
|
|
77
|
+
return this.callEndpoint("/api/v1/agent/guardrail-verify", {
|
|
78
|
+
input,
|
|
79
|
+
context,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* ElizaOS Plugin Definition
|
|
86
|
+
*/
|
|
87
|
+
export const diogenesPlugin = {
|
|
88
|
+
name: "diogenes",
|
|
89
|
+
description: "Diogenes Autonomous Edge Microservices & Solana Security Plugin",
|
|
90
|
+
|
|
91
|
+
actions: [
|
|
92
|
+
{
|
|
93
|
+
name: "CHECK_SPL_TOKEN_RISK",
|
|
94
|
+
description: "Inspect a Solana SPL token mint address for freeze authority, honeypot tax, and security risks before trading",
|
|
95
|
+
examples: [
|
|
96
|
+
[
|
|
97
|
+
{
|
|
98
|
+
user: "user",
|
|
99
|
+
content: { text: "Can you check if token mint 7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr is safe to buy?" },
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
user: "agent",
|
|
103
|
+
content: {
|
|
104
|
+
text: "I am auditing the Solana SPL token mint with Diogenes Risk Oracle...",
|
|
105
|
+
action: "CHECK_SPL_TOKEN_RISK",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
],
|
|
110
|
+
validate: async () => true,
|
|
111
|
+
handler: async (runtime: any, message: any, state: any, options: any, callback: any) => {
|
|
112
|
+
const client = new DiogenesClient({ demoMode: true });
|
|
113
|
+
const mint = message.content?.mintAddress || message.content?.text?.match(/[1-9A-HJ-NP-za-km-z]{32,44}/)?.[0];
|
|
114
|
+
|
|
115
|
+
if (!mint) {
|
|
116
|
+
callback?.({ text: "Please provide a valid Solana SPL token mint address to inspect." });
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
const result = await client.checkSplTokenRisk(mint);
|
|
122
|
+
callback?.({
|
|
123
|
+
text: `Token Audit for ${mint}:\nVerdict: ${result.preview?.should_transact ? "SAFE" : "CAUTION"}\nRisk Score: ${result.preview?.risk_score ?? "Low"}\nFreeze Authority: ${result.preview?.has_freeze_authority ? "ACTIVE (Risk)" : "Disabled (Safe)"}`,
|
|
124
|
+
content: result,
|
|
125
|
+
});
|
|
126
|
+
return true;
|
|
127
|
+
} catch (err: any) {
|
|
128
|
+
callback?.({ text: `Failed to inspect token: ${err.message}` });
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "AUDIT_SMART_CONTRACT",
|
|
135
|
+
description: "Audit Solana Anchor or EVM smart contract code for honeypot logic and reentrancy bugs",
|
|
136
|
+
examples: [
|
|
137
|
+
[
|
|
138
|
+
{
|
|
139
|
+
user: "user",
|
|
140
|
+
content: { text: "Can you audit this Solana program code for vulnerabilities?" },
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
user: "agent",
|
|
144
|
+
content: {
|
|
145
|
+
text: "Auditing program code with Diogenes Contract Audit Oracle...",
|
|
146
|
+
action: "AUDIT_SMART_CONTRACT",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
],
|
|
151
|
+
validate: async () => true,
|
|
152
|
+
handler: async (runtime: any, message: any, state: any, options: any, callback: any) => {
|
|
153
|
+
const client = new DiogenesClient({ demoMode: true });
|
|
154
|
+
const code = message.content?.code || message.content?.text;
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
const result = await client.auditSolanaProgram(code);
|
|
158
|
+
callback?.({
|
|
159
|
+
text: `Smart Contract Audit Result:\nVerdict: ${result.preview?.audit_passed ? "PASS" : "WARN"}\nVulnerabilities Found: ${result.preview?.vulnerabilities?.length ?? 0}`,
|
|
160
|
+
content: result,
|
|
161
|
+
});
|
|
162
|
+
return true;
|
|
163
|
+
} catch (err: any) {
|
|
164
|
+
callback?.({ text: `Audit error: ${err.message}` });
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "ENFORCE_GUARDRAIL",
|
|
171
|
+
description: "Pre-execution security gate to prevent prompt injection and destructive shell commands",
|
|
172
|
+
validate: async () => true,
|
|
173
|
+
handler: async (runtime: any, message: any, state: any, options: any, callback: any) => {
|
|
174
|
+
const client = new DiogenesClient({ demoMode: true });
|
|
175
|
+
const input = message.content?.text || "";
|
|
176
|
+
const result = await client.verifyGuardrail(input);
|
|
177
|
+
callback?.({ text: `Guardrail evaluated: ${result.preview?.verdict || "OK"}`, content: result });
|
|
178
|
+
return true;
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export default diogenesPlugin;
|