agentpay-mcp 1.2.0 → 3.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/.env.example +37 -0
- package/LICENSE +21 -0
- package/README.md +380 -31
- package/claude_desktop_config.json +17 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/dist/session/manager.d.ts +90 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +262 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/types.d.ts +113 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +16 -0
- package/dist/session/types.js.map +1 -0
- package/dist/tools/deploy.d.ts +49 -0
- package/dist/tools/deploy.d.ts.map +1 -0
- package/dist/tools/deploy.js +123 -0
- package/dist/tools/deploy.js.map +1 -0
- package/dist/tools/history.d.ts +59 -0
- package/dist/tools/history.d.ts.map +1 -0
- package/dist/tools/history.js +202 -0
- package/dist/tools/history.js.map +1 -0
- package/dist/tools/payments.d.ts +71 -0
- package/dist/tools/payments.d.ts.map +1 -0
- package/dist/tools/payments.js +158 -0
- package/dist/tools/payments.js.map +1 -0
- package/dist/tools/session.d.ts +240 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +678 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/wallet.d.ts +107 -0
- package/dist/tools/wallet.d.ts.map +1 -0
- package/dist/tools/wallet.js +271 -0
- package/dist/tools/wallet.js.map +1 -0
- package/dist/tools/x402.d.ts +90 -0
- package/dist/tools/x402.d.ts.map +1 -0
- package/dist/tools/x402.js +268 -0
- package/dist/tools/x402.js.map +1 -0
- package/dist/utils/client.d.ts +46 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +123 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/format.d.ts +59 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +161 -0
- package/dist/utils/format.js.map +1 -0
- package/package.json +58 -12
- package/index.d.ts +0 -1
- package/index.js +0 -13
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* session/types.ts — Type definitions for x402 V2 session management.
|
|
4
|
+
*
|
|
5
|
+
* x402 V2 introduced the concept of "wallet-based access & reusable sessions":
|
|
6
|
+
* agents pay once to establish a session, then skip on-chain payment on every
|
|
7
|
+
* subsequent call within that session. This module defines the data structures
|
|
8
|
+
* that AgentPay MCP uses to implement this pattern non-custodially.
|
|
9
|
+
*
|
|
10
|
+
* Reference: https://www.x402.org/writing/x402-v2-launch
|
|
11
|
+
* "V2 protocol now includes the logic to support wallet-controlled sessions,
|
|
12
|
+
* allowing clients to skip the full payment flow for repeated access if the
|
|
13
|
+
* resource was previously purchased."
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deploy_wallet tool — Deploy a new AgentAccountV2 wallet via the factory.
|
|
3
|
+
* Requires FACTORY_ADDRESS and NFT_CONTRACT_ADDRESS env vars.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const DeployWalletSchema: z.ZodObject<{
|
|
7
|
+
token_id: z.ZodString;
|
|
8
|
+
nft_contract_address: z.ZodOptional<z.ZodString>;
|
|
9
|
+
factory_address: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
token_id: string;
|
|
12
|
+
nft_contract_address?: string | undefined;
|
|
13
|
+
factory_address?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
token_id: string;
|
|
16
|
+
nft_contract_address?: string | undefined;
|
|
17
|
+
factory_address?: string | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export type DeployWalletInput = z.infer<typeof DeployWalletSchema>;
|
|
20
|
+
export declare const deployWalletTool: {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: "object";
|
|
25
|
+
properties: {
|
|
26
|
+
token_id: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
nft_contract_address: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
factory_address: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
required: string[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export declare function handleDeployWallet(input: DeployWalletInput): Promise<{
|
|
43
|
+
content: Array<{
|
|
44
|
+
type: 'text';
|
|
45
|
+
text: string;
|
|
46
|
+
}>;
|
|
47
|
+
isError?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/tools/deploy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAkB7B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAInE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;CAyB5B,CAAC;AAIF,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA6EhF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployWalletTool = exports.DeployWalletSchema = void 0;
|
|
4
|
+
exports.handleDeployWallet = handleDeployWallet;
|
|
5
|
+
/**
|
|
6
|
+
* deploy_wallet tool — Deploy a new AgentAccountV2 wallet via the factory.
|
|
7
|
+
* Requires FACTORY_ADDRESS and NFT_CONTRACT_ADDRESS env vars.
|
|
8
|
+
*/
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const viem_1 = require("viem");
|
|
11
|
+
const accounts_1 = require("viem/accounts");
|
|
12
|
+
const chains_1 = require("viem/chains");
|
|
13
|
+
const agentwallet_sdk_1 = require("agentwallet-sdk");
|
|
14
|
+
const client_js_1 = require("../utils/client.js");
|
|
15
|
+
const format_js_1 = require("../utils/format.js");
|
|
16
|
+
// ─── Schema ────────────────────────────────────────────────────────────────
|
|
17
|
+
exports.DeployWalletSchema = zod_1.z.object({
|
|
18
|
+
token_id: zod_1.z
|
|
19
|
+
.string()
|
|
20
|
+
.describe('NFT token ID that will own the deployed wallet (e.g. "1")'),
|
|
21
|
+
nft_contract_address: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('NFT contract address that owns this wallet. ' +
|
|
25
|
+
'Defaults to NFT_CONTRACT_ADDRESS env var.'),
|
|
26
|
+
factory_address: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('AgentAccountFactoryV2 address. ' +
|
|
30
|
+
'Defaults to FACTORY_ADDRESS env var.'),
|
|
31
|
+
});
|
|
32
|
+
// ─── Tool definition ───────────────────────────────────────────────────────
|
|
33
|
+
exports.deployWalletTool = {
|
|
34
|
+
name: 'deploy_wallet',
|
|
35
|
+
description: 'Deploy a new AgentAccountV2 wallet via the factory contract. ' +
|
|
36
|
+
'The wallet is deterministically addressed (CREATE2) and owned by an NFT. ' +
|
|
37
|
+
'Returns the wallet address and deployment transaction hash. ' +
|
|
38
|
+
'Requires FACTORY_ADDRESS and NFT_CONTRACT_ADDRESS env vars (or pass them as arguments).',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
token_id: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'NFT token ID that will own this wallet (e.g. "1")',
|
|
45
|
+
},
|
|
46
|
+
nft_contract_address: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'NFT contract address. Defaults to NFT_CONTRACT_ADDRESS env var.',
|
|
49
|
+
},
|
|
50
|
+
factory_address: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'Factory contract address. Defaults to FACTORY_ADDRESS env var.',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: ['token_id'],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
// ─── Handler ───────────────────────────────────────────────────────────────
|
|
59
|
+
async function handleDeployWallet(input) {
|
|
60
|
+
try {
|
|
61
|
+
const config = (0, client_js_1.getConfig)();
|
|
62
|
+
const factoryAddress = (input.factory_address ?? config.factoryAddress);
|
|
63
|
+
if (!factoryAddress) {
|
|
64
|
+
throw new Error('Factory address required. Pass factory_address argument or set FACTORY_ADDRESS env var.');
|
|
65
|
+
}
|
|
66
|
+
const nftContractAddress = (input.nft_contract_address ?? config.nftContractAddress);
|
|
67
|
+
if (!nftContractAddress) {
|
|
68
|
+
throw new Error('NFT contract address required. Pass nft_contract_address argument or set NFT_CONTRACT_ADDRESS env var.');
|
|
69
|
+
}
|
|
70
|
+
const tokenId = BigInt(input.token_id);
|
|
71
|
+
const chainMap = {
|
|
72
|
+
8453: chains_1.base,
|
|
73
|
+
84532: chains_1.baseSepolia,
|
|
74
|
+
};
|
|
75
|
+
const chainNameMap = {
|
|
76
|
+
8453: 'base',
|
|
77
|
+
84532: 'base-sepolia',
|
|
78
|
+
};
|
|
79
|
+
const chain = chainMap[config.chainId];
|
|
80
|
+
if (!chain) {
|
|
81
|
+
throw new Error(`Unsupported chain for deployment: ${config.chainId}`);
|
|
82
|
+
}
|
|
83
|
+
const account = (0, accounts_1.privateKeyToAccount)(config.agentPrivateKey);
|
|
84
|
+
const walletClient = (0, viem_1.createWalletClient)({
|
|
85
|
+
account,
|
|
86
|
+
chain,
|
|
87
|
+
transport: (0, viem_1.http)(config.rpcUrl, { timeout: 30_000 }),
|
|
88
|
+
});
|
|
89
|
+
const result = await (0, agentwallet_sdk_1.deployWallet)({
|
|
90
|
+
factoryAddress,
|
|
91
|
+
tokenContract: nftContractAddress,
|
|
92
|
+
tokenId,
|
|
93
|
+
chain: chainNameMap[config.chainId] ?? 'base',
|
|
94
|
+
rpcUrl: config.rpcUrl,
|
|
95
|
+
walletClient,
|
|
96
|
+
});
|
|
97
|
+
const explorerAddr = (0, format_js_1.explorerAddressUrl)(result.walletAddress, config.chainId);
|
|
98
|
+
const explorerTx = (0, format_js_1.explorerTxUrl)(result.txHash, config.chainId);
|
|
99
|
+
const cname = (0, format_js_1.chainName)(config.chainId);
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
(0, format_js_1.textContent)(`✅ Agent Wallet deployed successfully!\n\n` +
|
|
103
|
+
`📍 Wallet Address: ${result.walletAddress}\n` +
|
|
104
|
+
`🔗 Explorer: ${explorerAddr}\n\n` +
|
|
105
|
+
`📋 Transaction: ${result.txHash}\n` +
|
|
106
|
+
`🔗 Explorer: ${explorerTx}\n\n` +
|
|
107
|
+
`🔑 Owner NFT: ${nftContractAddress} #${input.token_id}\n` +
|
|
108
|
+
`🌐 Chain: ${cname}\n\n` +
|
|
109
|
+
`ℹ️ Next steps:\n` +
|
|
110
|
+
` 1. Set AGENT_WALLET_ADDRESS=${result.walletAddress} in your .env\n` +
|
|
111
|
+
` 2. Use set_spend_policy (via SDK) to configure autonomous spending limits\n` +
|
|
112
|
+
` 3. Fund the wallet with ETH or USDC for agent payments`),
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return {
|
|
118
|
+
content: [(0, format_js_1.textContent)((0, format_js_1.formatError)(error, 'deploy_wallet'))],
|
|
119
|
+
isError: true,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/tools/deploy.ts"],"names":[],"mappings":";;;AAmEA,gDA+EC;AAlJD;;;GAGG;AACH,6BAAwB;AACxB,+BAA8D;AAC9D,4CAAoD;AACpD,wCAAgD;AAChD,qDAA+C;AAC/C,kDAA+C;AAC/C,kDAA2H;AAE3H,8EAA8E;AAEjE,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,QAAQ,CAAC,2DAA2D,CAAC;IACxE,oBAAoB,EAAE,OAAC;SACpB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,8CAA8C;QAC9C,2CAA2C,CAC5C;IACH,eAAe,EAAE,OAAC;SACf,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,iCAAiC;QACjC,sCAAsC,CACvC;CACJ,CAAC,CAAC;AAIH,8EAA8E;AAEjE,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,+DAA+D;QAC/D,2EAA2E;QAC3E,8DAA8D;QAC9D,yFAAyF;IAC3F,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mDA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O,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* history.ts — get_transaction_history tool.
|
|
3
|
+
* Queries on-chain event logs for the wallet's transaction history.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const GetTransactionHistorySchema: z.ZodObject<{
|
|
7
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
from_block: z.ZodOptional<z.ZodString>;
|
|
9
|
+
to_block: z.ZodOptional<z.ZodString>;
|
|
10
|
+
event_type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["all", "execution", "queued", "approved", "cancelled", "policy_update", "operator_update"]>>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
limit: number;
|
|
13
|
+
event_type: "all" | "execution" | "queued" | "approved" | "cancelled" | "policy_update" | "operator_update";
|
|
14
|
+
from_block?: string | undefined;
|
|
15
|
+
to_block?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
limit?: number | undefined;
|
|
18
|
+
from_block?: string | undefined;
|
|
19
|
+
to_block?: string | undefined;
|
|
20
|
+
event_type?: "all" | "execution" | "queued" | "approved" | "cancelled" | "policy_update" | "operator_update" | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type GetTransactionHistoryInput = z.infer<typeof GetTransactionHistorySchema>;
|
|
23
|
+
export declare const getTransactionHistoryTool: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object";
|
|
28
|
+
properties: {
|
|
29
|
+
limit: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
default: number;
|
|
33
|
+
};
|
|
34
|
+
from_block: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
to_block: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
event_type: {
|
|
43
|
+
type: string;
|
|
44
|
+
enum: string[];
|
|
45
|
+
description: string;
|
|
46
|
+
default: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
required: never[];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare function handleGetTransactionHistory(input: GetTransactionHistoryInput): Promise<{
|
|
53
|
+
content: Array<{
|
|
54
|
+
type: 'text';
|
|
55
|
+
text: string;
|
|
56
|
+
}>;
|
|
57
|
+
isError?: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/tools/history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;EAsBtC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAIrF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCrC,CAAC;AAIF,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAmEhF"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTransactionHistoryTool = exports.GetTransactionHistorySchema = void 0;
|
|
4
|
+
exports.handleGetTransactionHistory = handleGetTransactionHistory;
|
|
5
|
+
/**
|
|
6
|
+
* history.ts — get_transaction_history tool.
|
|
7
|
+
* Queries on-chain event logs for the wallet's transaction history.
|
|
8
|
+
*/
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const agentwallet_sdk_1 = require("agentwallet-sdk");
|
|
11
|
+
const client_js_1 = require("../utils/client.js");
|
|
12
|
+
const format_js_1 = require("../utils/format.js");
|
|
13
|
+
// ─── Schema ────────────────────────────────────────────────────────────────
|
|
14
|
+
exports.GetTransactionHistorySchema = zod_1.z.object({
|
|
15
|
+
limit: zod_1.z
|
|
16
|
+
.number()
|
|
17
|
+
.int()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(100)
|
|
20
|
+
.optional()
|
|
21
|
+
.default(20)
|
|
22
|
+
.describe('Maximum number of entries to return (default: 20, max: 100)'),
|
|
23
|
+
from_block: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Start block number (hex or decimal string). Defaults to recent history.'),
|
|
27
|
+
to_block: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('End block number. Defaults to latest.'),
|
|
31
|
+
event_type: zod_1.z
|
|
32
|
+
.enum(['all', 'execution', 'queued', 'approved', 'cancelled', 'policy_update', 'operator_update'])
|
|
33
|
+
.optional()
|
|
34
|
+
.default('all')
|
|
35
|
+
.describe('Filter by event type (default: all)'),
|
|
36
|
+
});
|
|
37
|
+
// ─── Tool definition ───────────────────────────────────────────────────────
|
|
38
|
+
exports.getTransactionHistoryTool = {
|
|
39
|
+
name: 'get_transaction_history',
|
|
40
|
+
description: 'Retrieve the wallet\'s recent on-chain transaction history from event logs. ' +
|
|
41
|
+
'Shows executions, queued transactions, approvals, cancellations, ' +
|
|
42
|
+
'spend policy updates, and operator changes. ' +
|
|
43
|
+
'Filter by event type or block range for targeted queries.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
limit: {
|
|
48
|
+
type: 'number',
|
|
49
|
+
description: 'Max entries to return (default: 20, max: 100)',
|
|
50
|
+
default: 20,
|
|
51
|
+
},
|
|
52
|
+
from_block: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Start block (decimal string). Defaults to 1000 blocks ago.',
|
|
55
|
+
},
|
|
56
|
+
to_block: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'End block (decimal string). Defaults to latest.',
|
|
59
|
+
},
|
|
60
|
+
event_type: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
enum: ['all', 'execution', 'queued', 'approved', 'cancelled', 'policy_update', 'operator_update'],
|
|
63
|
+
description: 'Filter by event type (default: all)',
|
|
64
|
+
default: 'all',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
required: [],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
// ─── Handler ───────────────────────────────────────────────────────────────
|
|
71
|
+
async function handleGetTransactionHistory(input) {
|
|
72
|
+
try {
|
|
73
|
+
const wallet = (0, client_js_1.getWallet)();
|
|
74
|
+
const config = (0, client_js_1.getConfig)();
|
|
75
|
+
// Default: look back ~1000 blocks if no range specified
|
|
76
|
+
let fromBlock;
|
|
77
|
+
let toBlock;
|
|
78
|
+
if (input.from_block) {
|
|
79
|
+
fromBlock = BigInt(input.from_block);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Get current block and look back ~1000 blocks
|
|
83
|
+
const latest = await wallet.publicClient.getBlockNumber();
|
|
84
|
+
fromBlock = latest > 1000n ? latest - 1000n : 0n;
|
|
85
|
+
}
|
|
86
|
+
if (input.to_block) {
|
|
87
|
+
toBlock = BigInt(input.to_block);
|
|
88
|
+
}
|
|
89
|
+
const allEntries = await (0, agentwallet_sdk_1.getActivityHistory)(wallet, {
|
|
90
|
+
fromBlock,
|
|
91
|
+
toBlock,
|
|
92
|
+
});
|
|
93
|
+
// Filter by event type
|
|
94
|
+
const eventType = input.event_type ?? 'all';
|
|
95
|
+
const filtered = eventType === 'all'
|
|
96
|
+
? allEntries
|
|
97
|
+
: allEntries.filter((e) => e.type === eventType);
|
|
98
|
+
// Apply limit (most recent first after sort)
|
|
99
|
+
const limit = input.limit ?? 20;
|
|
100
|
+
const recent = filtered.slice(-limit).reverse();
|
|
101
|
+
if (recent.length === 0) {
|
|
102
|
+
return {
|
|
103
|
+
content: [
|
|
104
|
+
(0, format_js_1.textContent)(`📜 **Transaction History**\n\n` +
|
|
105
|
+
`No transactions found in the queried range.\n\n` +
|
|
106
|
+
` Block range: ${fromBlock?.toString() ?? '0'} → ${toBlock?.toString() ?? 'latest'}\n` +
|
|
107
|
+
` Event type: ${eventType}\n\n` +
|
|
108
|
+
`Try expanding the from_block range for older history.`),
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
let out = `📜 **Transaction History** (${recent.length} entries)\n`;
|
|
113
|
+
out += ` Chain: ${(0, format_js_1.chainName)(config.chainId)}\n`;
|
|
114
|
+
out += ` Block range: ${fromBlock?.toString() ?? '0'} → ${toBlock?.toString() ?? 'latest'}\n`;
|
|
115
|
+
out += ` Filter: ${eventType}\n\n`;
|
|
116
|
+
for (const entry of recent) {
|
|
117
|
+
out += formatActivityEntry(entry, config.chainId);
|
|
118
|
+
out += '\n';
|
|
119
|
+
}
|
|
120
|
+
return { content: [(0, format_js_1.textContent)(out)] };
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return {
|
|
124
|
+
content: [(0, format_js_1.textContent)((0, format_js_1.formatError)(error, 'get_transaction_history'))],
|
|
125
|
+
isError: true,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// ─── Entry formatter ───────────────────────────────────────────────────────
|
|
130
|
+
function formatActivityEntry(entry, chainId) {
|
|
131
|
+
const emoji = typeEmoji(entry.type);
|
|
132
|
+
const label = typeLabel(entry.type);
|
|
133
|
+
const txUrl = (0, format_js_1.explorerTxUrl)(entry.transactionHash, chainId);
|
|
134
|
+
let out = `${emoji} **${label}**\n`;
|
|
135
|
+
out += ` Block: ${entry.blockNumber.toString()}\n`;
|
|
136
|
+
out += ` TX: ${entry.transactionHash}\n`;
|
|
137
|
+
out += ` 🔗 ${txUrl}\n`;
|
|
138
|
+
// Format args based on type
|
|
139
|
+
const args = entry.args;
|
|
140
|
+
if (entry.type === 'execution' && args) {
|
|
141
|
+
if (args['target'])
|
|
142
|
+
out += ` To: ${args['target']}\n`;
|
|
143
|
+
if (args['value'] !== undefined)
|
|
144
|
+
out += ` Value: ${(0, format_js_1.formatEth)(BigInt(String(args['value'])))}\n`;
|
|
145
|
+
if (args['executor'])
|
|
146
|
+
out += ` By: ${args['executor']}\n`;
|
|
147
|
+
}
|
|
148
|
+
if (entry.type === 'queued' && args) {
|
|
149
|
+
if (args['txId'] !== undefined)
|
|
150
|
+
out += ` Queue ID: ${args['txId']}\n`;
|
|
151
|
+
if (args['to'])
|
|
152
|
+
out += ` To: ${args['to']}\n`;
|
|
153
|
+
if (args['value'] !== undefined)
|
|
154
|
+
out += ` Value: ${(0, format_js_1.formatEth)(BigInt(String(args['value'])))}\n`;
|
|
155
|
+
}
|
|
156
|
+
if (entry.type === 'approved' && args) {
|
|
157
|
+
if (args['txId'] !== undefined)
|
|
158
|
+
out += ` Queue ID: ${args['txId']}\n`;
|
|
159
|
+
}
|
|
160
|
+
if (entry.type === 'cancelled' && args) {
|
|
161
|
+
if (args['txId'] !== undefined)
|
|
162
|
+
out += ` Queue ID: ${args['txId']}\n`;
|
|
163
|
+
}
|
|
164
|
+
if (entry.type === 'policy_update' && args) {
|
|
165
|
+
if (args['token'])
|
|
166
|
+
out += ` Token: ${args['token']}\n`;
|
|
167
|
+
if (args['perTxLimit'] !== undefined)
|
|
168
|
+
out += ` Per-tx: ${(0, format_js_1.formatEth)(BigInt(String(args['perTxLimit'])))}\n`;
|
|
169
|
+
if (args['periodLimit'] !== undefined)
|
|
170
|
+
out += ` Period: ${(0, format_js_1.formatEth)(BigInt(String(args['periodLimit'])))}\n`;
|
|
171
|
+
}
|
|
172
|
+
if (entry.type === 'operator_update' && args) {
|
|
173
|
+
if (args['operator'])
|
|
174
|
+
out += ` Operator: ${args['operator']}\n`;
|
|
175
|
+
if (args['authorized'] !== undefined)
|
|
176
|
+
out += ` Status: ${args['authorized'] ? '✅ Added' : '❌ Removed'}\n`;
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
function typeEmoji(type) {
|
|
181
|
+
const map = {
|
|
182
|
+
execution: '⚡',
|
|
183
|
+
queued: '⏳',
|
|
184
|
+
approved: '✅',
|
|
185
|
+
cancelled: '🚫',
|
|
186
|
+
policy_update: '📋',
|
|
187
|
+
operator_update: '🔑',
|
|
188
|
+
};
|
|
189
|
+
return map[type] ?? '📄';
|
|
190
|
+
}
|
|
191
|
+
function typeLabel(type) {
|
|
192
|
+
const map = {
|
|
193
|
+
execution: 'Transaction Executed',
|
|
194
|
+
queued: 'Transaction Queued',
|
|
195
|
+
approved: 'Transaction Approved',
|
|
196
|
+
cancelled: 'Transaction Cancelled',
|
|
197
|
+
policy_update: 'Spend Policy Updated',
|
|
198
|
+
operator_update: 'Operator Updated',
|
|
199
|
+
};
|
|
200
|
+
return map[type] ?? type;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/tools/history.ts"],"names":[],"mappings":";;;AAmFA,kEAqEC;AAxJD;;;GAGG;AACH,6BAAwB;AACxB,qDAAqD;AACrD,kDAA0D;AAC1D,kDAO4B;AAG5B,8EAA8E;AAEjE,QAAA,2BAA2B,GAAG,OAAC,CAAC,MAAM,CAAC;IAClD,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;SACX,QAAQ,CAAC,6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C;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,SAAS,CAAC,IAA2B;IAC5C,MAAM,GAAG,GAA0C;QACjD,SAAS,EAAE,GAAG;QACd,MAAM,EAAE,GAAG;QACX,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;KACtB,CAAC;IACF,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC3B,CAAC;AAED,SAAS,SAAS,CAAC,IAA2B;IAC5C,MAAM,GAAG,GAA0C;QACjD,SAAS,EAAE,sBAAsB;QACjC,MAAM,EAAE,oBAAoB;QAC5B,QAAQ,EAAE,sBAAsB;QAChC,SAAS,EAAE,uBAAuB;QAClC,aAAa,EAAE,sBAAsB;QACrC,eAAe,EAAE,kBAAkB;KACpC,CAAC;IACF,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* payments.ts — send_payment tool.
|
|
3
|
+
* Executes ETH or ERC20 token transfers via the AgentAccountV2 contract.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const SendPaymentSchema: z.ZodObject<{
|
|
7
|
+
to: z.ZodString;
|
|
8
|
+
amount_eth: z.ZodString;
|
|
9
|
+
token: z.ZodOptional<z.ZodString>;
|
|
10
|
+
token_decimals: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
11
|
+
memo: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
to: string;
|
|
14
|
+
amount_eth: string;
|
|
15
|
+
token_decimals: number;
|
|
16
|
+
token?: string | undefined;
|
|
17
|
+
memo?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
to: string;
|
|
20
|
+
amount_eth: string;
|
|
21
|
+
token?: string | undefined;
|
|
22
|
+
token_decimals?: number | undefined;
|
|
23
|
+
memo?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type SendPaymentInput = z.infer<typeof SendPaymentSchema>;
|
|
26
|
+
export declare const sendPaymentTool: {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: "object";
|
|
31
|
+
properties: {
|
|
32
|
+
to: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
amount_eth: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
token: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
token_decimals: {
|
|
45
|
+
type: string;
|
|
46
|
+
description: string;
|
|
47
|
+
default: number;
|
|
48
|
+
};
|
|
49
|
+
memo: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
maxLength: number;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
required: string[];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export declare function handleSendPayment(input: SendPaymentInput): Promise<{
|
|
59
|
+
content: Array<{
|
|
60
|
+
type: 'text';
|
|
61
|
+
text: string;
|
|
62
|
+
}>;
|
|
63
|
+
isError?: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Parse a human-readable token amount string into base units (bigint).
|
|
67
|
+
* Handles floating-point precision correctly without using JavaScript floats.
|
|
68
|
+
* e.g., "1.5" with decimals=6 → 1500000n
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseTokenAmount(amount: string, decimals: number): bigint;
|
|
71
|
+
//# sourceMappingURL=payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../src/tools/payments.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;EA+B5B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAIjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC3B,CAAC;AAIF,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAqEhF;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWzE"}
|