agentpay-mcp 1.2.0 → 4.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.
Files changed (79) hide show
  1. package/.env.example +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +732 -33
  4. package/claude_desktop_config.json +17 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +248 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/session/manager.d.ts +90 -0
  10. package/dist/session/manager.d.ts.map +1 -0
  11. package/dist/session/manager.js +262 -0
  12. package/dist/session/manager.js.map +1 -0
  13. package/dist/session/types.d.ts +113 -0
  14. package/dist/session/types.d.ts.map +1 -0
  15. package/dist/session/types.js +16 -0
  16. package/dist/session/types.js.map +1 -0
  17. package/dist/tools/bridge.d.ts +52 -0
  18. package/dist/tools/bridge.d.ts.map +1 -0
  19. package/dist/tools/bridge.js +97 -0
  20. package/dist/tools/bridge.js.map +1 -0
  21. package/dist/tools/budget.d.ts +84 -0
  22. package/dist/tools/budget.d.ts.map +1 -0
  23. package/dist/tools/budget.js +163 -0
  24. package/dist/tools/budget.js.map +1 -0
  25. package/dist/tools/deploy.d.ts +49 -0
  26. package/dist/tools/deploy.d.ts.map +1 -0
  27. package/dist/tools/deploy.js +123 -0
  28. package/dist/tools/deploy.js.map +1 -0
  29. package/dist/tools/escrow.d.ts +73 -0
  30. package/dist/tools/escrow.d.ts.map +1 -0
  31. package/dist/tools/escrow.js +146 -0
  32. package/dist/tools/escrow.js.map +1 -0
  33. package/dist/tools/history.d.ts +59 -0
  34. package/dist/tools/history.d.ts.map +1 -0
  35. package/dist/tools/history.js +202 -0
  36. package/dist/tools/history.js.map +1 -0
  37. package/dist/tools/identity.d.ts +65 -0
  38. package/dist/tools/identity.d.ts.map +1 -0
  39. package/dist/tools/identity.js +158 -0
  40. package/dist/tools/identity.js.map +1 -0
  41. package/dist/tools/payments.d.ts +71 -0
  42. package/dist/tools/payments.d.ts.map +1 -0
  43. package/dist/tools/payments.js +158 -0
  44. package/dist/tools/payments.js.map +1 -0
  45. package/dist/tools/session.d.ts +240 -0
  46. package/dist/tools/session.d.ts.map +1 -0
  47. package/dist/tools/session.js +678 -0
  48. package/dist/tools/session.js.map +1 -0
  49. package/dist/tools/swap.d.ts +65 -0
  50. package/dist/tools/swap.d.ts.map +1 -0
  51. package/dist/tools/swap.js +101 -0
  52. package/dist/tools/swap.js.map +1 -0
  53. package/dist/tools/tokens.d.ts +129 -0
  54. package/dist/tools/tokens.d.ts.map +1 -0
  55. package/dist/tools/tokens.js +138 -0
  56. package/dist/tools/tokens.js.map +1 -0
  57. package/dist/tools/transfers.d.ts +86 -0
  58. package/dist/tools/transfers.d.ts.map +1 -0
  59. package/dist/tools/transfers.js +136 -0
  60. package/dist/tools/transfers.js.map +1 -0
  61. package/dist/tools/wallet.d.ts +107 -0
  62. package/dist/tools/wallet.d.ts.map +1 -0
  63. package/dist/tools/wallet.js +271 -0
  64. package/dist/tools/wallet.js.map +1 -0
  65. package/dist/tools/x402.d.ts +90 -0
  66. package/dist/tools/x402.d.ts.map +1 -0
  67. package/dist/tools/x402.js +268 -0
  68. package/dist/tools/x402.js.map +1 -0
  69. package/dist/utils/client.d.ts +46 -0
  70. package/dist/utils/client.d.ts.map +1 -0
  71. package/dist/utils/client.js +123 -0
  72. package/dist/utils/client.js.map +1 -0
  73. package/dist/utils/format.d.ts +59 -0
  74. package/dist/utils/format.d.ts.map +1 -0
  75. package/dist/utils/format.js +161 -0
  76. package/dist/utils/format.js.map +1 -0
  77. package/package.json +62 -12
  78. package/index.d.ts +0 -1
  79. package/index.js +0 -13
@@ -0,0 +1,65 @@
1
+ /**
2
+ * identity.ts — verify_agent_identity, get_reputation tools.
3
+ *
4
+ * Wraps agentwallet-sdk v6 ERC8004Client + ReputationClient.
5
+ */
6
+ import { z } from 'zod';
7
+ export declare const VerifyAgentIdentitySchema: z.ZodObject<{
8
+ agentAddress: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ agentAddress: string;
11
+ }, {
12
+ agentAddress: string;
13
+ }>;
14
+ export type VerifyAgentIdentityInput = z.infer<typeof VerifyAgentIdentitySchema>;
15
+ export declare const verifyAgentIdentityTool: {
16
+ name: string;
17
+ description: string;
18
+ inputSchema: {
19
+ type: "object";
20
+ properties: {
21
+ agentAddress: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ };
26
+ required: string[];
27
+ };
28
+ };
29
+ export declare function handleVerifyAgentIdentity(input: VerifyAgentIdentityInput): Promise<{
30
+ content: Array<{
31
+ type: 'text';
32
+ text: string;
33
+ }>;
34
+ isError?: boolean;
35
+ }>;
36
+ export declare const GetReputationSchema: z.ZodObject<{
37
+ agentAddress: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ agentAddress: string;
40
+ }, {
41
+ agentAddress: string;
42
+ }>;
43
+ export type GetReputationInput = z.infer<typeof GetReputationSchema>;
44
+ export declare const getReputationTool: {
45
+ name: string;
46
+ description: string;
47
+ inputSchema: {
48
+ type: "object";
49
+ properties: {
50
+ agentAddress: {
51
+ type: string;
52
+ description: string;
53
+ };
54
+ };
55
+ required: string[];
56
+ };
57
+ };
58
+ export declare function handleGetReputation(input: GetReputationInput): Promise<{
59
+ content: Array<{
60
+ type: 'text';
61
+ text: string;
62
+ }>;
63
+ isError?: boolean;
64
+ }>;
65
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/tools/identity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAiCvB,eAAO,MAAM,yBAAyB;;;;;;EAIpC,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAEhF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAgBnC,CAAA;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,wBAAwB,GAC9B,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,CA6ChF;AAID,eAAO,MAAM,mBAAmB;;;;;;EAI9B,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAEpE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAgB7B,CAAA;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,kBAAkB,GACxB,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,CAoDhF"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReputationTool = exports.GetReputationSchema = exports.verifyAgentIdentityTool = exports.VerifyAgentIdentitySchema = void 0;
4
+ exports.handleVerifyAgentIdentity = handleVerifyAgentIdentity;
5
+ exports.handleGetReputation = handleGetReputation;
6
+ /**
7
+ * identity.ts — verify_agent_identity, get_reputation tools.
8
+ *
9
+ * Wraps agentwallet-sdk v6 ERC8004Client + ReputationClient.
10
+ */
11
+ const zod_1 = require("zod");
12
+ const agentwallet_sdk_1 = require("agentwallet-sdk");
13
+ const client_js_1 = require("../utils/client.js");
14
+ const format_js_1 = require("../utils/format.js");
15
+ const CHAIN_ID_TO_NAME = {
16
+ 1: 'ethereum',
17
+ 8453: 'base',
18
+ 84532: 'base-sepolia',
19
+ 42161: 'arbitrum',
20
+ 421614: 'arbitrum-sepolia',
21
+ 137: 'polygon',
22
+ };
23
+ function getChainName(chainId) {
24
+ const name = CHAIN_ID_TO_NAME[chainId];
25
+ if (!name)
26
+ throw new Error(`Unsupported chain ID for identity: ${chainId}`);
27
+ return name;
28
+ }
29
+ // ─── verify_agent_identity ─────────────────────────────────────────────────
30
+ exports.VerifyAgentIdentitySchema = zod_1.z.object({
31
+ agentAddress: zod_1.z
32
+ .string()
33
+ .describe('Agent owner address to verify identity for (0x-prefixed)'),
34
+ });
35
+ exports.verifyAgentIdentityTool = {
36
+ name: 'verify_agent_identity',
37
+ description: 'Verify an agent\'s on-chain identity using ERC-8004. ' +
38
+ 'Looks up the agent by owner address and returns identity details ' +
39
+ 'including agent ID, URI, and registration file.',
40
+ inputSchema: {
41
+ type: 'object',
42
+ properties: {
43
+ agentAddress: {
44
+ type: 'string',
45
+ description: 'Agent owner address (0x-prefixed)',
46
+ },
47
+ },
48
+ required: ['agentAddress'],
49
+ },
50
+ };
51
+ async function handleVerifyAgentIdentity(input) {
52
+ try {
53
+ const config = (0, client_js_1.getConfig)();
54
+ const chainName = getChainName(config.chainId);
55
+ const client = new agentwallet_sdk_1.ERC8004Client({ chain: chainName });
56
+ const identity = await client.lookupAgentByOwner(input.agentAddress);
57
+ if (!identity) {
58
+ return {
59
+ content: [
60
+ (0, format_js_1.textContent)(JSON.stringify({
61
+ found: false,
62
+ agentAddress: input.agentAddress,
63
+ chain: chainName,
64
+ })),
65
+ ],
66
+ };
67
+ }
68
+ return {
69
+ content: [
70
+ (0, format_js_1.textContent)(JSON.stringify({
71
+ found: true,
72
+ agentId: identity.agentId.toString(),
73
+ owner: identity.owner,
74
+ agentWallet: identity.agentWallet,
75
+ agentURI: identity.agentURI,
76
+ registrationFile: identity.registrationFile,
77
+ modelMetadata: identity.modelMetadata ?? null,
78
+ chain: chainName,
79
+ })),
80
+ ],
81
+ };
82
+ }
83
+ catch (error) {
84
+ return {
85
+ content: [(0, format_js_1.textContent)((0, format_js_1.formatError)(error, 'verify_agent_identity'))],
86
+ isError: true,
87
+ };
88
+ }
89
+ }
90
+ // ─── get_reputation ────────────────────────────────────────────────────────
91
+ exports.GetReputationSchema = zod_1.z.object({
92
+ agentAddress: zod_1.z
93
+ .string()
94
+ .describe('Agent owner address to look up reputation for (0x-prefixed)'),
95
+ });
96
+ exports.getReputationTool = {
97
+ name: 'get_reputation',
98
+ description: 'Get the on-chain reputation score for an agent. ' +
99
+ 'Resolves agent ID from owner address via ERC-8004, ' +
100
+ 'then queries the Reputation Registry for score and feedback.',
101
+ inputSchema: {
102
+ type: 'object',
103
+ properties: {
104
+ agentAddress: {
105
+ type: 'string',
106
+ description: 'Agent owner address (0x-prefixed)',
107
+ },
108
+ },
109
+ required: ['agentAddress'],
110
+ },
111
+ };
112
+ async function handleGetReputation(input) {
113
+ try {
114
+ const config = (0, client_js_1.getConfig)();
115
+ const chainName = getChainName(config.chainId);
116
+ // Step 1: resolve agentId from owner address
117
+ const identityClient = new agentwallet_sdk_1.ERC8004Client({ chain: chainName });
118
+ const identity = await identityClient.lookupAgentByOwner(input.agentAddress);
119
+ if (!identity) {
120
+ return {
121
+ content: [
122
+ (0, format_js_1.textContent)(JSON.stringify({
123
+ found: false,
124
+ agentAddress: input.agentAddress,
125
+ chain: chainName,
126
+ message: 'No registered agent identity found for this address.',
127
+ })),
128
+ ],
129
+ };
130
+ }
131
+ // Step 2: query reputation
132
+ const reputationClient = new agentwallet_sdk_1.ReputationClient({ chain: chainName });
133
+ const reputation = await reputationClient.getAgentReputation(identity.agentId);
134
+ return {
135
+ content: [
136
+ (0, format_js_1.textContent)(JSON.stringify({
137
+ found: true,
138
+ agentAddress: input.agentAddress,
139
+ agentId: identity.agentId.toString(),
140
+ chain: chainName,
141
+ reputation: {
142
+ count: reputation.count.toString(),
143
+ totalScore: reputation.totalScore.toString(),
144
+ avgCategory: reputation.avgCategory,
145
+ clients: reputation.clients,
146
+ },
147
+ })),
148
+ ],
149
+ };
150
+ }
151
+ catch (error) {
152
+ return {
153
+ content: [(0, format_js_1.textContent)((0, format_js_1.formatError)(error, 'get_reputation'))],
154
+ isError: true,
155
+ };
156
+ }
157
+ }
158
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/tools/identity.ts"],"names":[],"mappings":";;;AAgEA,8DA+CC;AA8BD,kDAsDC;AAnMD;;;;GAIG;AACH,6BAAuB;AACvB,qDAAiE;AAEjE,kDAA8C;AAC9C,kDAA6D;AAY7D,MAAM,gBAAgB,GAA2C;IAC/D,CAAC,EAAE,UAAU;IACb,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,kBAAkB;IAC1B,GAAG,EAAE,SAAS;CACf,CAAA;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAA;IAC3E,OAAO,IAAI,CAAA;AACb,CAAC;AAED,8EAA8E;AAEjE,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChD,YAAY,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CAAC,0DAA0D,CAAC;CACxE,CAAC,CAAA;AAIW,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,uDAAuD;QACvD,mEAAmE;QACnE,iDAAiD;IACnD,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;SACF;QACD,QAAQ,EAAE,CAAC,cAAc,CAAC;KAC3B;CACF,CAAA;AAEM,KAAK,UAAU,yBAAyB,CAC7C,KAA+B;IAE/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA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;YACL,OAAO,EAAE;gBACP,IAAA,uBAAW,EACT,IAAI,CAAC,SAAS,CAAC;oBACb,KAAK,EAAE,IAAI;oBACX,YAAY,EAAE,KAAK,CAAC,YAAY;oBAChC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE;oBACpC,KAAK,EAAE,SAAS;oBAChB,UAAU,EAAE;wBACV,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE;wBAClC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE;wBAC5C,WAAW,EAAE,UAAU,CAAC,WAAW;wBACnC,OAAO,EAAE,UAAU,CAAC,OAAO;qBAC5B;iBACF,CAAC,CACH;aACF;SACF,CAAA;IACH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO;YACL,OAAO,EAAE,CAAC,IAAA,uBAAW,EAAC,IAAA,uBAAW,EAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;YAC5D,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;AACH,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"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendPaymentTool = exports.SendPaymentSchema = void 0;
4
+ exports.handleSendPayment = handleSendPayment;
5
+ exports.parseTokenAmount = parseTokenAmount;
6
+ /**
7
+ * payments.ts — send_payment tool.
8
+ * Executes ETH or ERC20 token transfers via the AgentAccountV2 contract.
9
+ */
10
+ const zod_1 = require("zod");
11
+ const viem_1 = require("viem");
12
+ const agentwallet_sdk_1 = require("agentwallet-sdk");
13
+ const client_js_1 = require("../utils/client.js");
14
+ const format_js_1 = require("../utils/format.js");
15
+ const NATIVE_TOKEN = viem_1.zeroAddress;
16
+ // ─── Schema ────────────────────────────────────────────────────────────────
17
+ exports.SendPaymentSchema = zod_1.z.object({
18
+ to: zod_1.z
19
+ .string()
20
+ .describe('Recipient address (0x-prefixed, checksummed or lowercase)'),
21
+ amount_eth: zod_1.z
22
+ .string()
23
+ .describe('Amount to send, expressed in ETH (e.g. "0.001"). ' +
24
+ 'For ERC20 tokens, this is the human-readable amount (e.g. "1.5" for 1.5 USDC). ' +
25
+ 'Use the token_decimals parameter to control precision.'),
26
+ token: zod_1.z
27
+ .string()
28
+ .optional()
29
+ .describe('ERC20 token contract address. ' +
30
+ 'Omit or use "0x0000000000000000000000000000000000000000" for native ETH.'),
31
+ token_decimals: zod_1.z
32
+ .number()
33
+ .int()
34
+ .min(0)
35
+ .max(18)
36
+ .optional()
37
+ .default(18)
38
+ .describe('Token decimal places (default: 18 for ETH; use 6 for USDC).'),
39
+ memo: zod_1.z
40
+ .string()
41
+ .max(200)
42
+ .optional()
43
+ .describe('Optional memo/note for this payment (logged locally, not on-chain).'),
44
+ });
45
+ // ─── Tool definition ───────────────────────────────────────────────────────
46
+ exports.sendPaymentTool = {
47
+ name: 'send_payment',
48
+ description: 'Send ETH or ERC20 tokens from the Agent Wallet. ' +
49
+ 'If the amount is within the configured spend limits, it executes immediately and returns the tx hash. ' +
50
+ 'If it exceeds limits, the transaction is queued for owner approval (use queue_approval to manage). ' +
51
+ 'Always check spend limits first with check_spend_limit to avoid surprises.',
52
+ inputSchema: {
53
+ type: 'object',
54
+ properties: {
55
+ to: {
56
+ type: 'string',
57
+ description: 'Recipient wallet address (0x-prefixed)',
58
+ },
59
+ amount_eth: {
60
+ type: 'string',
61
+ description: 'Amount in ETH (or token units). E.g. "0.001" for 0.001 ETH, "1.5" for 1.5 USDC',
62
+ },
63
+ token: {
64
+ type: 'string',
65
+ description: 'ERC20 token address. Omit for native ETH.',
66
+ },
67
+ token_decimals: {
68
+ type: 'number',
69
+ description: 'Token decimals (default 18 for ETH, 6 for USDC)',
70
+ default: 18,
71
+ },
72
+ memo: {
73
+ type: 'string',
74
+ description: 'Optional memo for this payment (not stored on-chain)',
75
+ maxLength: 200,
76
+ },
77
+ },
78
+ required: ['to', 'amount_eth'],
79
+ },
80
+ };
81
+ // ─── Handler ───────────────────────────────────────────────────────────────
82
+ async function handleSendPayment(input) {
83
+ try {
84
+ const wallet = (0, client_js_1.getWallet)();
85
+ const config = (0, client_js_1.getConfig)();
86
+ // Validate recipient address
87
+ if (!input.to.startsWith('0x') || input.to.length !== 42) {
88
+ throw new Error(`Invalid recipient address: "${input.to}". Must be a 0x-prefixed 42-character hex string.`);
89
+ }
90
+ const toAddress = input.to;
91
+ // Parse amount
92
+ const amountCheck = parseFloat(input.amount_eth);
93
+ if (isNaN(amountCheck) || amountCheck <= 0) {
94
+ throw new Error(`Invalid amount: "${input.amount_eth}". Must be a positive number.`);
95
+ }
96
+ const decimals = input.token_decimals ?? 18;
97
+ const amountWei = parseTokenAmount(input.amount_eth, decimals);
98
+ const isNativeEth = !input.token || input.token === NATIVE_TOKEN || input.token === '0x0000000000000000000000000000000000000000';
99
+ const tokenAddress = isNativeEth ? NATIVE_TOKEN : input.token;
100
+ const tokenLabel = isNativeEth ? 'ETH' : input.token ?? 'ETH';
101
+ let txHash;
102
+ if (isNativeEth) {
103
+ // Native ETH transfer via agentExecute
104
+ const result = await (0, agentwallet_sdk_1.agentExecute)(wallet, {
105
+ to: toAddress,
106
+ value: amountWei,
107
+ });
108
+ txHash = result.txHash;
109
+ }
110
+ else {
111
+ // ERC20 transfer via agentTransferToken
112
+ txHash = await (0, agentwallet_sdk_1.agentTransferToken)(wallet, {
113
+ token: tokenAddress,
114
+ to: toAddress,
115
+ amount: amountWei,
116
+ });
117
+ }
118
+ const explorerUrl = (0, format_js_1.explorerTxUrl)(txHash, config.chainId);
119
+ const memoLine = input.memo ? `\n📝 Memo: ${input.memo}` : '';
120
+ return {
121
+ content: [
122
+ (0, format_js_1.textContent)(`✅ **Payment Sent**\n\n` +
123
+ ` To: ${toAddress}\n` +
124
+ ` Amount: ${input.amount_eth} ${tokenLabel}\n` +
125
+ ` Token: ${tokenLabel}\n` +
126
+ ` Network: ${(0, format_js_1.chainName)(config.chainId)}\n` +
127
+ ` TX Hash: ${txHash}\n` +
128
+ ` 🔗 ${explorerUrl}` +
129
+ memoLine + '\n\n' +
130
+ `ℹ️ If the transaction was over-limit, it was queued for owner approval.\n` +
131
+ ` Use queue_approval (action="list") to check pending transactions.`),
132
+ ],
133
+ };
134
+ }
135
+ catch (error) {
136
+ return {
137
+ content: [(0, format_js_1.textContent)((0, format_js_1.formatError)(error, 'send_payment'))],
138
+ isError: true,
139
+ };
140
+ }
141
+ }
142
+ // ─── Token amount parser ───────────────────────────────────────────────────
143
+ /**
144
+ * Parse a human-readable token amount string into base units (bigint).
145
+ * Handles floating-point precision correctly without using JavaScript floats.
146
+ * e.g., "1.5" with decimals=6 → 1500000n
147
+ */
148
+ function parseTokenAmount(amount, decimals) {
149
+ const trimmed = amount.trim();
150
+ if (!trimmed || isNaN(Number(trimmed))) {
151
+ throw new Error(`Invalid amount: "${amount}"`);
152
+ }
153
+ const [intPart, fracPart = ''] = trimmed.split('.');
154
+ const fracTrimmed = fracPart.slice(0, decimals).padEnd(decimals, '0');
155
+ const intStr = (intPart ?? '0') + fracTrimmed;
156
+ return BigInt(intStr);
157
+ }
158
+ //# sourceMappingURL=payments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/tools/payments.ts"],"names":[],"mappings":";;;AAgGA,8CAuEC;AASD,4CAWC;AA3LD;;;GAGG;AACH,6BAAwB;AACxB,+BAAiD;AACjD,qDAAmE;AACnE,kDAA0D;AAC1D,kDAM4B;AAE5B,MAAM,YAAY,GAAG,kBAAW,CAAC;AAEjC,8EAA8E;AAEjE,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,OAAC;SACF,MAAM,EAAE;SACR,QAAQ,CAAC,2DAA2D,CAAC;IACxE,UAAU,EAAE,OAAC;SACV,MAAM,EAAE;SACR,QAAQ,CACP,mDAAmD;QACnD,iFAAiF;QACjF,wDAAwD,CACzD;IACH,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,gCAAgC;QAChC,0EAA0E,CAC3E;IACH,cAAc,EAAE,OAAC;SACd,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;SACX,QAAQ,CAAC,6DAA6D,CAAC;IAC1E,IAAI,EAAE,OAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,qEAAqE,CAAC;CACnF,CAAC,CAAC;AAIH,8EAA8E;AAEjE,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,kDAAkD;QAClD,wGAAwG;QACxG,qGAAqG;QACrG,4EAA4E;IAC9E,WAAW,EAAE;QACX,IAAI,EA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