@x402janus/elizaos-plugin 0.1.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 +52 -0
- package/dist/actions/check-approvals.d.ts +41 -0
- package/dist/actions/check-approvals.d.ts.map +1 -0
- package/dist/actions/check-approvals.js +98 -0
- package/dist/actions/check-approvals.js.map +1 -0
- package/dist/actions/scan-wallet.d.ts +47 -0
- package/dist/actions/scan-wallet.d.ts.map +1 -0
- package/dist/actions/scan-wallet.js +159 -0
- package/dist/actions/scan-wallet.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +83 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +33 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @x402janus/elizaos-plugin
|
|
2
|
+
|
|
3
|
+
ElizaOS plugin for x402janus wallet security scans. Adds `SCAN_WALLET` and `CHECK_APPROVALS` actions to your ElizaOS agent.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @x402janus/elizaos-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { janusPlugin } from "@x402janus/elizaos-plugin";
|
|
15
|
+
|
|
16
|
+
const agent = new Agent({
|
|
17
|
+
plugins: [janusPlugin],
|
|
18
|
+
settings: {
|
|
19
|
+
PRIVATE_KEY: process.env.PRIVATE_KEY, // Agent wallet for x402 payments
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Your agent can now respond to:
|
|
25
|
+
- "Scan wallet 0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18"
|
|
26
|
+
- "Is 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 safe?"
|
|
27
|
+
- "Check approvals for 0x..."
|
|
28
|
+
- "Do a deep security check on 0x..."
|
|
29
|
+
|
|
30
|
+
## Actions
|
|
31
|
+
|
|
32
|
+
### SCAN_WALLET
|
|
33
|
+
|
|
34
|
+
Scans a wallet for security risks. Returns risk score, findings, and pre-built revoke transactions.
|
|
35
|
+
|
|
36
|
+
**Triggers:** "scan wallet", "check security", "is this safe", "analyze wallet"
|
|
37
|
+
|
|
38
|
+
### CHECK_APPROVALS
|
|
39
|
+
|
|
40
|
+
Lists active token approvals with risk assessment.
|
|
41
|
+
|
|
42
|
+
**Triggers:** "check approvals", "list approvals", "token approvals", "show allowances"
|
|
43
|
+
|
|
44
|
+
## Payment
|
|
45
|
+
|
|
46
|
+
All scans pay via x402 micropayment (USDC on Base). Your agent wallet needs:
|
|
47
|
+
- USDC on Base ($0.01–$0.25 per scan)
|
|
48
|
+
- No ETH required (facilitator pays gas)
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/check-approvals
|
|
3
|
+
* CHECK_APPROVALS action for ElizaOS.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* CHECK_APPROVALS action — lists token approvals for a wallet.
|
|
7
|
+
*/
|
|
8
|
+
export declare const checkApprovalsAction: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
similes: string[];
|
|
12
|
+
validate: (_runtime: unknown, message: {
|
|
13
|
+
content: {
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
}) => Promise<boolean>;
|
|
17
|
+
handler: (runtime: {
|
|
18
|
+
getSetting: (key: string) => string | undefined;
|
|
19
|
+
}, message: {
|
|
20
|
+
content: {
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
}, _state: unknown, _options: unknown, callback: (response: {
|
|
24
|
+
text: string;
|
|
25
|
+
action?: string;
|
|
26
|
+
}) => void) => Promise<boolean>;
|
|
27
|
+
examples: ({
|
|
28
|
+
user: string;
|
|
29
|
+
content: {
|
|
30
|
+
text: string;
|
|
31
|
+
action?: undefined;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
user: string;
|
|
35
|
+
content: {
|
|
36
|
+
text: string;
|
|
37
|
+
action: string;
|
|
38
|
+
};
|
|
39
|
+
})[][];
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=check-approvals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-approvals.d.ts","sourceRoot":"","sources":["../../src/actions/check-approvals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8CH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;yBAWJ,OAAO,WAAW;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAG,OAAO,CAAC,OAAO,CAAC;uBAKlF;QAAE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;KAAE,WACnD;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,UAC9B,OAAO,YACL,OAAO,YACP,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,KAC9D,OAAO,CAAC,OAAO,CAAC;;;;;;;;;;;;;;CA0CpB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/check-approvals
|
|
3
|
+
* CHECK_APPROVALS action for ElizaOS.
|
|
4
|
+
*/
|
|
5
|
+
import { JanusClient } from "@x402janus/sdk";
|
|
6
|
+
/** Ethereum address pattern */
|
|
7
|
+
const ETH_ADDRESS_RE = /0x[a-fA-F0-9]{40}/;
|
|
8
|
+
function extractAddress(text) {
|
|
9
|
+
const match = ETH_ADDRESS_RE.exec(text);
|
|
10
|
+
return match ? match[0] : null;
|
|
11
|
+
}
|
|
12
|
+
function formatApprovals(result) {
|
|
13
|
+
let output = `🔑 **Token Approvals for ${result.wallet.slice(0, 6)}...${result.wallet.slice(-4)}**\n\n`;
|
|
14
|
+
if (result.approvals.length === 0) {
|
|
15
|
+
output += "No active token approvals found. ✅\n";
|
|
16
|
+
return output;
|
|
17
|
+
}
|
|
18
|
+
output += `Found ${result.approvals.length} approval(s):\n\n`;
|
|
19
|
+
const riskCount = result.riskCount;
|
|
20
|
+
if (riskCount.critical > 0)
|
|
21
|
+
output += `🔴 Critical: ${riskCount.critical}\n`;
|
|
22
|
+
if (riskCount.high > 0)
|
|
23
|
+
output += `🟠 High: ${riskCount.high}\n`;
|
|
24
|
+
if (riskCount.medium > 0)
|
|
25
|
+
output += `🟡 Medium: ${riskCount.medium}\n`;
|
|
26
|
+
if (riskCount.low > 0)
|
|
27
|
+
output += `🟢 Low: ${riskCount.low}\n`;
|
|
28
|
+
output += "\n";
|
|
29
|
+
for (const approval of result.approvals.slice(0, 10)) {
|
|
30
|
+
const riskEmoji = approval.risk === "critical" ? "🔴" :
|
|
31
|
+
approval.risk === "high" ? "🟠" :
|
|
32
|
+
approval.risk === "medium" ? "🟡" : "🟢";
|
|
33
|
+
const symbol = approval.tokenSymbol ?? approval.token.slice(0, 8);
|
|
34
|
+
output += `${riskEmoji} **${symbol}** → ${approval.spender.slice(0, 8)}... (${approval.allowance})\n`;
|
|
35
|
+
if (approval.details)
|
|
36
|
+
output += ` ${approval.details}\n`;
|
|
37
|
+
}
|
|
38
|
+
if (result.approvals.length > 10) {
|
|
39
|
+
output += `\n...and ${result.approvals.length - 10} more.\n`;
|
|
40
|
+
}
|
|
41
|
+
return output;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* CHECK_APPROVALS action — lists token approvals for a wallet.
|
|
45
|
+
*/
|
|
46
|
+
export const checkApprovalsAction = {
|
|
47
|
+
name: "CHECK_APPROVALS",
|
|
48
|
+
description: "List active token approvals for a wallet with risk assessment",
|
|
49
|
+
similes: [
|
|
50
|
+
"check approvals",
|
|
51
|
+
"list approvals",
|
|
52
|
+
"token approvals",
|
|
53
|
+
"what approvals does this wallet have",
|
|
54
|
+
"show allowances",
|
|
55
|
+
],
|
|
56
|
+
validate: async (_runtime, message) => {
|
|
57
|
+
return ETH_ADDRESS_RE.test(message.content.text);
|
|
58
|
+
},
|
|
59
|
+
handler: async (runtime, message, _state, _options, callback) => {
|
|
60
|
+
const address = extractAddress(message.content.text);
|
|
61
|
+
if (!address) {
|
|
62
|
+
callback({ text: "I need a wallet address. Please provide an Ethereum address (0x...)." });
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const privateKey = runtime.getSetting("PRIVATE_KEY") ?? process.env.PRIVATE_KEY;
|
|
66
|
+
if (!privateKey) {
|
|
67
|
+
callback({ text: "⚠️ Agent wallet not configured. Set PRIVATE_KEY for x402 payments." });
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const baseUrl = runtime.getSetting("JANUS_API_URL") ?? process.env.JANUS_API_URL ?? "https://x402janus.com";
|
|
71
|
+
try {
|
|
72
|
+
const client = new JanusClient({ privateKey, baseUrl });
|
|
73
|
+
const result = await client.approvals(address);
|
|
74
|
+
callback({ text: formatApprovals(result), action: "CHECK_APPROVALS" });
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
callback({ text: `❌ Failed to check approvals: ${err instanceof Error ? err.message : String(err)}` });
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
examples: [
|
|
83
|
+
[
|
|
84
|
+
{
|
|
85
|
+
user: "{{user1}}",
|
|
86
|
+
content: { text: "What approvals does 0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18 have?" },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
user: "{{agent}}",
|
|
90
|
+
content: {
|
|
91
|
+
text: "🔑 **Token Approvals for 0x742d...bD18**\n\nFound 3 approval(s):\n🟡 Medium: 2\n🟢 Low: 1",
|
|
92
|
+
action: "CHECK_APPROVALS",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=check-approvals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-approvals.js","sourceRoot":"","sources":["../../src/actions/check-approvals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAC;AAEnE,+BAA+B;AAC/B,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAE3C,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,SAAS,eAAe,CAAC,MAAuB;IAC9C,IAAI,MAAM,GAAG,4BAA4B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAExG,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,sCAAsC,CAAC;QACjD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,SAAS,MAAM,CAAC,SAAS,CAAC,MAAM,mBAAmB,CAAC;IAE9D,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACnC,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC;QAAE,MAAM,IAAI,gBAAgB,SAAS,CAAC,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AQ,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACvE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,QAAQ,CAAC,EAAE,IAAI,EAAE,gCAAgC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YACvG,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,QAAQ,EAAE;QACR;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,sEAAsE,EAAE;aAC1F;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,2FAA2F;oBACjG,MAAM,EAAE,iBAAiB;iBAC1B;aACF;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/scan-wallet
|
|
3
|
+
* SCAN_WALLET action for ElizaOS.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SCAN_WALLET action — scans a wallet for security risks.
|
|
7
|
+
*
|
|
8
|
+
* Triggers on messages like:
|
|
9
|
+
* - "scan wallet 0x..."
|
|
10
|
+
* - "check security of 0x..."
|
|
11
|
+
* - "is 0x... safe?"
|
|
12
|
+
* - "analyze wallet 0x..."
|
|
13
|
+
*/
|
|
14
|
+
export declare const scanWalletAction: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
similes: string[];
|
|
18
|
+
validate: (_runtime: unknown, message: {
|
|
19
|
+
content: {
|
|
20
|
+
text: string;
|
|
21
|
+
};
|
|
22
|
+
}) => Promise<boolean>;
|
|
23
|
+
handler: (runtime: {
|
|
24
|
+
getSetting: (key: string) => string | undefined;
|
|
25
|
+
}, message: {
|
|
26
|
+
content: {
|
|
27
|
+
text: string;
|
|
28
|
+
};
|
|
29
|
+
}, _state: unknown, _options: unknown, callback: (response: {
|
|
30
|
+
text: string;
|
|
31
|
+
action?: string;
|
|
32
|
+
}) => void) => Promise<boolean>;
|
|
33
|
+
examples: ({
|
|
34
|
+
user: string;
|
|
35
|
+
content: {
|
|
36
|
+
text: string;
|
|
37
|
+
action?: undefined;
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
user: string;
|
|
41
|
+
content: {
|
|
42
|
+
text: string;
|
|
43
|
+
action: string;
|
|
44
|
+
};
|
|
45
|
+
})[][];
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=scan-wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-wallet.d.ts","sourceRoot":"","sources":["../../src/actions/scan-wallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4DH;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB;;;;yBAcA,OAAO,WAAW;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAG,OAAO,CAAC,OAAO,CAAC;uBAMlF;QAAE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;KAAE,WACnD;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,UAC9B,OAAO,YACL,OAAO,YACP,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,KAC9D,OAAO,CAAC,OAAO,CAAC;;;;;;;;;;;;;;CAuFpB,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions/scan-wallet
|
|
3
|
+
* SCAN_WALLET action for ElizaOS.
|
|
4
|
+
*/
|
|
5
|
+
import { JanusClient } from "@x402janus/sdk";
|
|
6
|
+
/** Ethereum address pattern */
|
|
7
|
+
const ETH_ADDRESS_RE = /0x[a-fA-F0-9]{40}/;
|
|
8
|
+
/**
|
|
9
|
+
* Extract an Ethereum address from a message.
|
|
10
|
+
*/
|
|
11
|
+
function extractAddress(text) {
|
|
12
|
+
const match = ETH_ADDRESS_RE.exec(text);
|
|
13
|
+
return match ? match[0] : null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extract scan tier from message text.
|
|
17
|
+
*/
|
|
18
|
+
function extractTier(text) {
|
|
19
|
+
const lower = text.toLowerCase();
|
|
20
|
+
if (lower.includes("deep") || lower.includes("forensic") || lower.includes("thorough")) {
|
|
21
|
+
return "deep";
|
|
22
|
+
}
|
|
23
|
+
if (lower.includes("standard") || lower.includes("full")) {
|
|
24
|
+
return "standard";
|
|
25
|
+
}
|
|
26
|
+
return "quick";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Format scan results for human-readable output.
|
|
30
|
+
*/
|
|
31
|
+
function formatResults(result) {
|
|
32
|
+
const riskEmoji = result.risk >= 75 ? "🔴" : result.risk >= 50 ? "🟠" : result.risk >= 25 ? "🟡" : "🟢";
|
|
33
|
+
let output = `${riskEmoji} **Wallet Security Scan**\n\n`;
|
|
34
|
+
output += `**Status:** ${result.safe ? "✅ Safe" : "⚠️ Risks detected"}\n`;
|
|
35
|
+
output += `**Risk Score:** ${result.risk}/100\n\n`;
|
|
36
|
+
if (result.findings.length > 0) {
|
|
37
|
+
output += `**Findings (${result.findings.length}):**\n`;
|
|
38
|
+
for (const finding of result.findings) {
|
|
39
|
+
const sev = finding.severity === "critical" ? "🔴" :
|
|
40
|
+
finding.severity === "high" ? "🟠" :
|
|
41
|
+
finding.severity === "medium" ? "🟡" : "🟢";
|
|
42
|
+
output += `${sev} [${finding.severity.toUpperCase()}] ${finding.description}\n`;
|
|
43
|
+
}
|
|
44
|
+
output += "\n";
|
|
45
|
+
}
|
|
46
|
+
if (result.revokeTxs.length > 0) {
|
|
47
|
+
output += `**Revoke Transactions (${result.revokeTxs.length}):**\n`;
|
|
48
|
+
for (const tx of result.revokeTxs) {
|
|
49
|
+
output += `• ${tx.description}\n`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return output;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* SCAN_WALLET action — scans a wallet for security risks.
|
|
56
|
+
*
|
|
57
|
+
* Triggers on messages like:
|
|
58
|
+
* - "scan wallet 0x..."
|
|
59
|
+
* - "check security of 0x..."
|
|
60
|
+
* - "is 0x... safe?"
|
|
61
|
+
* - "analyze wallet 0x..."
|
|
62
|
+
*/
|
|
63
|
+
export const scanWalletAction = {
|
|
64
|
+
name: "SCAN_WALLET",
|
|
65
|
+
description: "Scan a wallet for security risks using x402janus forensic analysis",
|
|
66
|
+
similes: [
|
|
67
|
+
"scan wallet",
|
|
68
|
+
"check wallet security",
|
|
69
|
+
"is this wallet safe",
|
|
70
|
+
"analyze wallet",
|
|
71
|
+
"wallet security scan",
|
|
72
|
+
"check approvals",
|
|
73
|
+
"scan address",
|
|
74
|
+
"security check",
|
|
75
|
+
],
|
|
76
|
+
validate: async (_runtime, message) => {
|
|
77
|
+
const text = message.content.text;
|
|
78
|
+
return ETH_ADDRESS_RE.test(text);
|
|
79
|
+
},
|
|
80
|
+
handler: async (runtime, message, _state, _options, callback) => {
|
|
81
|
+
const text = message.content.text;
|
|
82
|
+
const address = extractAddress(text);
|
|
83
|
+
if (!address) {
|
|
84
|
+
callback({
|
|
85
|
+
text: "I need a wallet address to scan. Please provide an Ethereum address (0x...).",
|
|
86
|
+
});
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const tier = extractTier(text);
|
|
90
|
+
const privateKey = runtime.getSetting("PRIVATE_KEY") ?? process.env.PRIVATE_KEY;
|
|
91
|
+
if (!privateKey) {
|
|
92
|
+
callback({
|
|
93
|
+
text: "⚠️ Agent wallet not configured. Set PRIVATE_KEY to enable x402 payments for security scans.",
|
|
94
|
+
});
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const baseUrl = runtime.getSetting("JANUS_API_URL") ?? process.env.JANUS_API_URL ?? "https://x402janus.com";
|
|
98
|
+
try {
|
|
99
|
+
callback({
|
|
100
|
+
text: `🔲 Scanning ${address.slice(0, 6)}...${address.slice(-4)} (${tier} tier)...`,
|
|
101
|
+
});
|
|
102
|
+
const client = new JanusClient({
|
|
103
|
+
privateKey,
|
|
104
|
+
baseUrl,
|
|
105
|
+
defaultTier: tier,
|
|
106
|
+
});
|
|
107
|
+
const result = await client.scan(address, { tier });
|
|
108
|
+
const formatted = formatResults(result);
|
|
109
|
+
callback({
|
|
110
|
+
text: formatted,
|
|
111
|
+
action: "SCAN_WALLET",
|
|
112
|
+
});
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
117
|
+
if (msg.includes("USDC") || msg.includes("payment") || msg.includes("balance")) {
|
|
118
|
+
callback({
|
|
119
|
+
text: `⚠️ Agent wallet needs USDC on Base to pay for scans. Fund the wallet, then try again.`,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
callback({
|
|
124
|
+
text: `❌ Scan failed: ${msg}`,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
examples: [
|
|
131
|
+
[
|
|
132
|
+
{
|
|
133
|
+
user: "{{user1}}",
|
|
134
|
+
content: { text: "Can you scan this wallet? 0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18" },
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
user: "{{agent}}",
|
|
138
|
+
content: {
|
|
139
|
+
text: "🟢 **Wallet Security Scan**\n\n**Status:** ✅ Safe\n**Risk Score:** 12/100",
|
|
140
|
+
action: "SCAN_WALLET",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
{
|
|
146
|
+
user: "{{user1}}",
|
|
147
|
+
content: { text: "Do a deep security check on 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" },
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
user: "{{agent}}",
|
|
151
|
+
content: {
|
|
152
|
+
text: "🟡 **Wallet Security Scan**\n\n**Status:** ⚠️ Risks detected\n**Risk Score:** 35/100\n\n**Findings (2):**\n🟡 [MEDIUM] Unlimited approval to unknown spender",
|
|
153
|
+
action: "SCAN_WALLET",
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=scan-wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-wallet.js","sourceRoot":"","sources":["../../src/actions/scan-wallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAkC,MAAM,gBAAgB,CAAC;AAE7E,+BAA+B;AAC/B,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAE3C;;GAEG;AACH,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACvF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IA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,IAAI,EAAE,uFAAuF;iBAC9F,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC;oBACP,IAAI,EAAE,kBAAkB,GAAG,EAAE;iBAC9B,CAAC,CAAC;YACL,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,QAAQ,EAAE;QACR;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,sEAAsE,EAAE;aAC1F;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,2EAA2E;oBACjF,MAAM,EAAE,aAAa;iBACtB;aACF;SACF;QACD;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,wEAAwE,EAAE;aAC5F;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,8JAA8J;oBACpK,MAAM,EAAE,aAAa;iBACtB;aACF;SACF;KACF;CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @x402janus/elizaos-plugin
|
|
3
|
+
*
|
|
4
|
+
* ElizaOS plugin for x402janus wallet security scans.
|
|
5
|
+
* Adds SCAN_WALLET and CHECK_APPROVALS actions to any ElizaOS agent.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { janusPlugin } from "@x402janus/elizaos-plugin";
|
|
10
|
+
*
|
|
11
|
+
* const agent = new Agent({
|
|
12
|
+
* plugins: [janusPlugin],
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export { janusPlugin, janusPlugin as default } from "./plugin.js";
|
|
17
|
+
export { scanWalletAction } from "./actions/scan-wallet.js";
|
|
18
|
+
export { checkApprovalsAction } from "./actions/check-approvals.js";
|
|
19
|
+
export type { JanusPluginConfig } from "./plugin.js";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @x402janus/elizaos-plugin
|
|
3
|
+
*
|
|
4
|
+
* ElizaOS plugin for x402janus wallet security scans.
|
|
5
|
+
* Adds SCAN_WALLET and CHECK_APPROVALS actions to any ElizaOS agent.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { janusPlugin } from "@x402janus/elizaos-plugin";
|
|
10
|
+
*
|
|
11
|
+
* const agent = new Agent({
|
|
12
|
+
* plugins: [janusPlugin],
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export { janusPlugin, janusPlugin as default } from "./plugin.js";
|
|
17
|
+
export { scanWalletAction } from "./actions/scan-wallet.js";
|
|
18
|
+
export { checkApprovalsAction } from "./actions/check-approvals.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module plugin
|
|
3
|
+
* ElizaOS plugin definition for x402janus.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for the x402janus plugin.
|
|
7
|
+
*/
|
|
8
|
+
export interface JanusPluginConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Agent wallet private key for signing x402 micropayments.
|
|
11
|
+
* Falls back to `process.env.PRIVATE_KEY`.
|
|
12
|
+
*/
|
|
13
|
+
privateKey?: string;
|
|
14
|
+
/**
|
|
15
|
+
* x402janus API base URL.
|
|
16
|
+
* @default "https://x402janus.com"
|
|
17
|
+
*/
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Default scan tier.
|
|
21
|
+
* @default "quick"
|
|
22
|
+
*/
|
|
23
|
+
defaultTier?: "quick" | "standard" | "deep";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* x402janus ElizaOS plugin.
|
|
27
|
+
*
|
|
28
|
+
* Adds wallet security scanning actions to your ElizaOS agent.
|
|
29
|
+
* All scans are paid via x402 micropayment (USDC on Base).
|
|
30
|
+
*
|
|
31
|
+
* Actions added:
|
|
32
|
+
* - `SCAN_WALLET` — Scan a wallet for security risks
|
|
33
|
+
* - `CHECK_APPROVALS` — List active token approvals with risk assessment
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { janusPlugin } from "@x402janus/elizaos-plugin";
|
|
38
|
+
*
|
|
39
|
+
* const agent = new Agent({
|
|
40
|
+
* plugins: [janusPlugin],
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const janusPlugin: {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
actions: {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
similes: string[];
|
|
51
|
+
validate: (_runtime: unknown, message: {
|
|
52
|
+
content: {
|
|
53
|
+
text: string;
|
|
54
|
+
};
|
|
55
|
+
}) => Promise<boolean>;
|
|
56
|
+
handler: (runtime: {
|
|
57
|
+
getSetting: (key: string) => string | undefined;
|
|
58
|
+
}, message: {
|
|
59
|
+
content: {
|
|
60
|
+
text: string;
|
|
61
|
+
};
|
|
62
|
+
}, _state: unknown, _options: unknown, callback: (response: {
|
|
63
|
+
text: string;
|
|
64
|
+
action?: string;
|
|
65
|
+
}) => void) => Promise<boolean>;
|
|
66
|
+
examples: ({
|
|
67
|
+
user: string;
|
|
68
|
+
content: {
|
|
69
|
+
text: string;
|
|
70
|
+
action?: undefined;
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
user: string;
|
|
74
|
+
content: {
|
|
75
|
+
text: string;
|
|
76
|
+
action: string;
|
|
77
|
+
};
|
|
78
|
+
})[][];
|
|
79
|
+
}[];
|
|
80
|
+
evaluators: never[];
|
|
81
|
+
providers: never[];
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;kBAOm6C,CAAC;;;;;;;;;;;;;;;;;;CAD37C,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module plugin
|
|
3
|
+
* ElizaOS plugin definition for x402janus.
|
|
4
|
+
*/
|
|
5
|
+
import { scanWalletAction } from "./actions/scan-wallet.js";
|
|
6
|
+
import { checkApprovalsAction } from "./actions/check-approvals.js";
|
|
7
|
+
/**
|
|
8
|
+
* x402janus ElizaOS plugin.
|
|
9
|
+
*
|
|
10
|
+
* Adds wallet security scanning actions to your ElizaOS agent.
|
|
11
|
+
* All scans are paid via x402 micropayment (USDC on Base).
|
|
12
|
+
*
|
|
13
|
+
* Actions added:
|
|
14
|
+
* - `SCAN_WALLET` — Scan a wallet for security risks
|
|
15
|
+
* - `CHECK_APPROVALS` — List active token approvals with risk assessment
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { janusPlugin } from "@x402janus/elizaos-plugin";
|
|
20
|
+
*
|
|
21
|
+
* const agent = new Agent({
|
|
22
|
+
* plugins: [janusPlugin],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export const janusPlugin = {
|
|
27
|
+
name: "x402janus",
|
|
28
|
+
description: "Wallet security scanning for AI agents via x402 micropayment",
|
|
29
|
+
actions: [scanWalletAction, checkApprovalsAction],
|
|
30
|
+
evaluators: [],
|
|
31
|
+
providers: [],
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,8DAA8D;IAC3E,OAAO,EAAE,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IACjD,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;CACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x402janus/elizaos-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ElizaOS plugin for x402janus wallet security scans with x402 micropayment",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"type-check": "tsc --noEmit",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@x402janus/sdk": "file:../x402janus-sdk"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@elizaos/core": ">=0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"elizaos",
|
|
35
|
+
"plugin",
|
|
36
|
+
"x402janus",
|
|
37
|
+
"wallet",
|
|
38
|
+
"security",
|
|
39
|
+
"scan",
|
|
40
|
+
"x402",
|
|
41
|
+
"base"
|
|
42
|
+
],
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/x402janus/elizaos-plugin"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"typescript": "^5.9.3"
|
|
50
|
+
}
|
|
51
|
+
}
|