@zakyirsyaad/monagent-plugin 0.1.0 → 0.1.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/commands/monad/identity/get.d.ts +19 -0
- package/dist/commands/monad/identity/get.js +113 -0
- package/dist/commands/monad/identity/register.d.ts +16 -0
- package/dist/commands/monad/identity/register.js +122 -0
- package/dist/commands/monad/jobs/complete.d.ts +15 -0
- package/dist/commands/monad/jobs/complete.js +63 -0
- package/dist/commands/{jobs → monad/jobs}/create.d.ts +5 -2
- package/dist/commands/monad/jobs/create.js +88 -0
- package/dist/commands/monad/jobs/refund.d.ts +14 -0
- package/dist/commands/monad/jobs/refund.js +56 -0
- package/dist/commands/{pay.d.ts → monad/pay.d.ts} +5 -2
- package/dist/commands/monad/pay.js +123 -0
- package/dist/commands/monad/reputation/check.d.ts +18 -0
- package/dist/commands/monad/reputation/check.js +103 -0
- package/dist/commands/monad/reputation/give.d.ts +15 -0
- package/dist/commands/monad/reputation/give.js +99 -0
- package/dist/commands/monad/x402/pay.d.ts +21 -0
- package/dist/commands/monad/x402/pay.js +224 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +10 -7
- package/dist/monad.d.ts +424 -0
- package/dist/monad.js +186 -0
- package/dist/sdk.d.ts +62 -39
- package/dist/sdk.js +95 -8
- package/oclif.manifest.json +1304 -24
- package/package.json +47 -11
- package/dist/commands/identity/get.d.ts +0 -13
- package/dist/commands/identity/get.js +0 -59
- package/dist/commands/identity/register.d.ts +0 -12
- package/dist/commands/identity/register.js +0 -39
- package/dist/commands/jobs/create.js +0 -38
- package/dist/commands/pay.js +0 -33
- package/dist/commands/reputation/check.d.ts +0 -12
- package/dist/commands/reputation/check.js +0 -46
- package/dist/commands/reputation/give.d.ts +0 -12
- package/dist/commands/reputation/give.js +0 -45
- package/dist/commands/x402/pay.d.ts +0 -13
- package/dist/commands/x402/pay.js +0 -67
- package/dist/commands.test.d.ts +0 -1
- package/dist/commands.test.js +0 -141
package/dist/commands.test.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { MonadPayCommand } from "./commands/pay.js";
|
|
4
|
-
import { MonadIdentityRegisterCommand } from "./commands/identity/register.js";
|
|
5
|
-
import { MonadIdentityGetCommand } from "./commands/identity/get.js";
|
|
6
|
-
import { MonadReputationCheckCommand } from "./commands/reputation/check.js";
|
|
7
|
-
import { MonadReputationGiveCommand } from "./commands/reputation/give.js";
|
|
8
|
-
import { MonadJobsCreateCommand } from "./commands/jobs/create.js";
|
|
9
|
-
function createMockIO(inputs) {
|
|
10
|
-
const logs = [];
|
|
11
|
-
return {
|
|
12
|
-
logs,
|
|
13
|
-
resolveInputs: async () => inputs,
|
|
14
|
-
log: (msg) => logs.push(msg),
|
|
15
|
-
error: (msg) => logs.push(`[ERROR] ${msg}`),
|
|
16
|
-
warn: (msg) => logs.push(`[WARN] ${msg}`),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function createMockContext(overrides) {
|
|
20
|
-
const executorResult = overrides?.executorResult ?? {
|
|
21
|
-
status: "success",
|
|
22
|
-
hash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
|
23
|
-
};
|
|
24
|
-
const mockPublicClient = {
|
|
25
|
-
readContract: async ({ functionName }) => {
|
|
26
|
-
if (functionName === "ownerOf")
|
|
27
|
-
return "0x9999999999999999999999999999999999999999";
|
|
28
|
-
if (functionName === "getAgentWallet")
|
|
29
|
-
return "0x8888888888888888888888888888888888888888";
|
|
30
|
-
if (functionName === "tokenURI") {
|
|
31
|
-
const cardJson = JSON.stringify({
|
|
32
|
-
name: "MonadArbitrageAgent",
|
|
33
|
-
description: "High speed trader",
|
|
34
|
-
endpoints: ["https://trader.monad.xyz"],
|
|
35
|
-
walletAddress: "0x8888888888888888888888888888888888888888",
|
|
36
|
-
supportedProtocols: ["mcp"],
|
|
37
|
-
active: true,
|
|
38
|
-
});
|
|
39
|
-
return `data:application/json;utf8,${encodeURIComponent(cardJson)}`;
|
|
40
|
-
}
|
|
41
|
-
if (functionName === "getSummary") {
|
|
42
|
-
return [BigInt(10), BigInt(950), 0]; // 10 feedback, score 950 sum, 0 decimals -> 95 avg
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
publicClient: () => mockPublicClient,
|
|
49
|
-
walletExecutor: () => async (_req) => executorResult,
|
|
50
|
-
logger: {
|
|
51
|
-
info: () => { },
|
|
52
|
-
error: () => { },
|
|
53
|
-
warn: () => { },
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
describe("MetaMask Agent Wallet Plugin for Monad", () => {
|
|
58
|
-
it("executes monad:pay successfully with walletExecutor", async () => {
|
|
59
|
-
const cmd = new MonadPayCommand();
|
|
60
|
-
const ctx = createMockContext();
|
|
61
|
-
cmd.setContext(ctx);
|
|
62
|
-
const io = createMockIO({
|
|
63
|
-
to: "0x1111111111111111111111111111111111111111",
|
|
64
|
-
amount: "2.5",
|
|
65
|
-
token: "MON",
|
|
66
|
-
memo: "Data fee",
|
|
67
|
-
});
|
|
68
|
-
const result = await cmd.execute(io);
|
|
69
|
-
assert.equal(result.amount, "2.5");
|
|
70
|
-
assert.equal(result.to, "0x1111111111111111111111111111111111111111");
|
|
71
|
-
assert.ok(result.transactionHash.startsWith("0x"));
|
|
72
|
-
});
|
|
73
|
-
it("registers agent identity on Monad ERC-8004", async () => {
|
|
74
|
-
const cmd = new MonadIdentityRegisterCommand();
|
|
75
|
-
const ctx = createMockContext();
|
|
76
|
-
cmd.setContext(ctx);
|
|
77
|
-
const io = createMockIO({
|
|
78
|
-
name: "MonadAlphaAgent",
|
|
79
|
-
description: "Subcontractor for Monad DeFi",
|
|
80
|
-
endpoints: ["https://alpha.example.com"],
|
|
81
|
-
walletAddress: "0x2222222222222222222222222222222222222222",
|
|
82
|
-
supportedProtocols: ["mcp", "x402"],
|
|
83
|
-
active: true,
|
|
84
|
-
});
|
|
85
|
-
const result = await cmd.execute(io);
|
|
86
|
-
assert.equal(result.agentCard.name, "MonadAlphaAgent");
|
|
87
|
-
assert.ok(result.transactionHash.startsWith("0x"));
|
|
88
|
-
});
|
|
89
|
-
it("fetches agent identity and parses agent card metadata", async () => {
|
|
90
|
-
const cmd = new MonadIdentityGetCommand();
|
|
91
|
-
const ctx = createMockContext();
|
|
92
|
-
cmd.setContext(ctx);
|
|
93
|
-
const io = createMockIO({ agentId: "101" });
|
|
94
|
-
const result = await cmd.execute(io);
|
|
95
|
-
assert.equal(result.agentId, "101");
|
|
96
|
-
assert.equal(result.card?.name, "MonadArbitrageAgent");
|
|
97
|
-
assert.equal(result.walletAddress, "0x8888888888888888888888888888888888888888");
|
|
98
|
-
});
|
|
99
|
-
it("checks reputation on Monad and computes trustTier", async () => {
|
|
100
|
-
const cmd = new MonadReputationCheckCommand();
|
|
101
|
-
const ctx = createMockContext();
|
|
102
|
-
cmd.setContext(ctx);
|
|
103
|
-
const io = createMockIO({ agentId: "101", tag1: "speed", tag2: "defi" });
|
|
104
|
-
const result = await cmd.execute(io);
|
|
105
|
-
assert.equal(result.agentId, "101");
|
|
106
|
-
assert.equal(result.feedbackCount, 10);
|
|
107
|
-
assert.equal(result.averageScore, 95);
|
|
108
|
-
assert.equal(result.trustTier, "HIGH");
|
|
109
|
-
});
|
|
110
|
-
it("submits peer feedback to Monad Reputation Registry", async () => {
|
|
111
|
-
const cmd = new MonadReputationGiveCommand();
|
|
112
|
-
const ctx = createMockContext();
|
|
113
|
-
cmd.setContext(ctx);
|
|
114
|
-
const io = createMockIO({
|
|
115
|
-
agentId: "101",
|
|
116
|
-
value: 100,
|
|
117
|
-
decimals: 0,
|
|
118
|
-
tag1: "accuracy",
|
|
119
|
-
tag2: "execution",
|
|
120
|
-
endpoint: "https://agent.example.com",
|
|
121
|
-
feedbackURI: "https://agent.example.com/proof",
|
|
122
|
-
});
|
|
123
|
-
const result = await cmd.execute(io);
|
|
124
|
-
assert.equal(result.feedback.agentId, "101");
|
|
125
|
-
assert.equal(result.feedback.value, 100);
|
|
126
|
-
});
|
|
127
|
-
it("creates and funds an A2A task escrow on Monad", async () => {
|
|
128
|
-
const cmd = new MonadJobsCreateCommand();
|
|
129
|
-
const ctx = createMockContext();
|
|
130
|
-
cmd.setContext(ctx);
|
|
131
|
-
const io = createMockIO({
|
|
132
|
-
workerAddress: "0x3333333333333333333333333333333333333333",
|
|
133
|
-
bountyMon: "0.5",
|
|
134
|
-
taskDescription: "Compute optimal routing across Monad DEX pools",
|
|
135
|
-
deadlineHours: 12,
|
|
136
|
-
});
|
|
137
|
-
const result = await cmd.execute(io);
|
|
138
|
-
assert.equal(result.bountyMon, "0.5");
|
|
139
|
-
assert.ok(result.jobId.startsWith("job_"));
|
|
140
|
-
});
|
|
141
|
-
});
|