@t402/mcp 2.6.0 → 2.7.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/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +302 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/index.d.ts +12 -0
- package/dist/cjs/server/index.js +302 -26
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/tools/index.d.ts +179 -1
- package/dist/cjs/tools/index.js +283 -25
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/esm/{chunk-3FGPOVUZ.mjs → chunk-3PMBXSJ3.mjs} +51 -3
- package/dist/esm/chunk-3PMBXSJ3.mjs.map +1 -0
- package/dist/esm/{chunk-RDQ7AMR4.mjs → chunk-B7X7H6NV.mjs} +275 -27
- package/dist/esm/chunk-B7X7H6NV.mjs.map +1 -0
- package/dist/esm/index.d.mts +1 -0
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/server/index.d.mts +12 -0
- package/dist/esm/server/index.mjs +2 -2
- package/dist/esm/tools/index.d.mts +179 -1
- package/dist/esm/tools/index.mjs +21 -1
- package/package.json +4 -5
- package/dist/esm/chunk-3FGPOVUZ.mjs.map +0 -1
- package/dist/esm/chunk-RDQ7AMR4.mjs.map +0 -1
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { S as SupportedNetwork, C as ChainBalance, b as PaymentResult, G as GaslessPaymentResult, B as BridgeFeeQuote, a as BridgeResult } from '../ton-bridge-BN3RKhNy.js';
|
|
3
3
|
export { d as TON_BRIDGE_TOOLS, e as TonMcpBridgeConfig, f as createTonBridgeToolSet, g as executeTonBridgeTool } from '../ton-bridge-BN3RKhNy.js';
|
|
4
4
|
import { T402WDK } from '@t402/wdk';
|
|
5
|
+
import { ResolvedAgent, ReputationSummary } from '@t402/erc8004';
|
|
5
6
|
import 'viem';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -536,6 +537,102 @@ declare function executeAutoPayDemo(input: AutoPayInput): AutoPayResult;
|
|
|
536
537
|
*/
|
|
537
538
|
declare function formatAutoPayResult(result: AutoPayResult): string;
|
|
538
539
|
|
|
540
|
+
/**
|
|
541
|
+
* erc8004/resolveAgent - Look up an agent's on-chain identity
|
|
542
|
+
*/
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Input schema for resolveAgent tool
|
|
546
|
+
*/
|
|
547
|
+
declare const erc8004ResolveAgentInputSchema: z.ZodObject<{
|
|
548
|
+
agentId: z.ZodNumber;
|
|
549
|
+
agentRegistry: z.ZodString;
|
|
550
|
+
}, "strip", z.ZodTypeAny, {
|
|
551
|
+
agentId: number;
|
|
552
|
+
agentRegistry: string;
|
|
553
|
+
}, {
|
|
554
|
+
agentId: number;
|
|
555
|
+
agentRegistry: string;
|
|
556
|
+
}>;
|
|
557
|
+
type Erc8004ResolveAgentInput = z.infer<typeof erc8004ResolveAgentInputSchema>;
|
|
558
|
+
/**
|
|
559
|
+
* Execute resolveAgent tool
|
|
560
|
+
*/
|
|
561
|
+
declare function executeErc8004ResolveAgent(input: Erc8004ResolveAgentInput, rpcUrls?: Partial<Record<SupportedNetwork, string>>): Promise<ResolvedAgent>;
|
|
562
|
+
/**
|
|
563
|
+
* Format resolveAgent result for display
|
|
564
|
+
*/
|
|
565
|
+
declare function formatErc8004ResolveAgentResult(agent: ResolvedAgent): string;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* erc8004/checkReputation - Query an agent's reputation score
|
|
569
|
+
*/
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Input schema for checkReputation tool
|
|
573
|
+
*/
|
|
574
|
+
declare const erc8004CheckReputationInputSchema: z.ZodObject<{
|
|
575
|
+
agentId: z.ZodNumber;
|
|
576
|
+
agentRegistry: z.ZodString;
|
|
577
|
+
reputationRegistry: z.ZodString;
|
|
578
|
+
trustedReviewers: z.ZodArray<z.ZodString, "many">;
|
|
579
|
+
}, "strip", z.ZodTypeAny, {
|
|
580
|
+
agentId: number;
|
|
581
|
+
agentRegistry: string;
|
|
582
|
+
reputationRegistry: string;
|
|
583
|
+
trustedReviewers: string[];
|
|
584
|
+
}, {
|
|
585
|
+
agentId: number;
|
|
586
|
+
agentRegistry: string;
|
|
587
|
+
reputationRegistry: string;
|
|
588
|
+
trustedReviewers: string[];
|
|
589
|
+
}>;
|
|
590
|
+
type Erc8004CheckReputationInput = z.infer<typeof erc8004CheckReputationInputSchema>;
|
|
591
|
+
/**
|
|
592
|
+
* Execute checkReputation tool
|
|
593
|
+
*/
|
|
594
|
+
declare function executeErc8004CheckReputation(input: Erc8004CheckReputationInput, rpcUrls?: Partial<Record<SupportedNetwork, string>>): Promise<ReputationSummary>;
|
|
595
|
+
/**
|
|
596
|
+
* Format checkReputation result for display
|
|
597
|
+
*/
|
|
598
|
+
declare function formatErc8004CheckReputationResult(summary: ReputationSummary): string;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* erc8004/verifyWallet - Verify payTo matches agent's on-chain wallet
|
|
602
|
+
*/
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Input schema for verifyWallet tool
|
|
606
|
+
*/
|
|
607
|
+
declare const erc8004VerifyWalletInputSchema: z.ZodObject<{
|
|
608
|
+
agentId: z.ZodNumber;
|
|
609
|
+
agentRegistry: z.ZodString;
|
|
610
|
+
walletAddress: z.ZodString;
|
|
611
|
+
}, "strip", z.ZodTypeAny, {
|
|
612
|
+
agentId: number;
|
|
613
|
+
agentRegistry: string;
|
|
614
|
+
walletAddress: string;
|
|
615
|
+
}, {
|
|
616
|
+
agentId: number;
|
|
617
|
+
agentRegistry: string;
|
|
618
|
+
walletAddress: string;
|
|
619
|
+
}>;
|
|
620
|
+
type Erc8004VerifyWalletInput = z.infer<typeof erc8004VerifyWalletInputSchema>;
|
|
621
|
+
interface Erc8004VerifyWalletResult {
|
|
622
|
+
matches: boolean;
|
|
623
|
+
agentId: number;
|
|
624
|
+
walletAddress: string;
|
|
625
|
+
registryAddress: string;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Execute verifyWallet tool
|
|
629
|
+
*/
|
|
630
|
+
declare function executeErc8004VerifyWallet(input: Erc8004VerifyWalletInput, rpcUrls?: Partial<Record<SupportedNetwork, string>>): Promise<Erc8004VerifyWalletResult>;
|
|
631
|
+
/**
|
|
632
|
+
* Format verifyWallet result for display
|
|
633
|
+
*/
|
|
634
|
+
declare function formatErc8004VerifyWalletResult(result: Erc8004VerifyWalletResult): string;
|
|
635
|
+
|
|
539
636
|
/**
|
|
540
637
|
* Unified MCP Toolkit - Combines WDK wallet tools with t402 payment tools.
|
|
541
638
|
*
|
|
@@ -1037,5 +1134,86 @@ declare const WDK_TOOL_DEFINITIONS: {
|
|
|
1037
1134
|
};
|
|
1038
1135
|
};
|
|
1039
1136
|
};
|
|
1137
|
+
/**
|
|
1138
|
+
* ERC-8004 tool definitions (always available — read-only on-chain queries)
|
|
1139
|
+
*/
|
|
1140
|
+
declare const ERC8004_TOOL_DEFINITIONS: {
|
|
1141
|
+
'erc8004/resolveAgent': {
|
|
1142
|
+
name: string;
|
|
1143
|
+
description: string;
|
|
1144
|
+
inputSchema: {
|
|
1145
|
+
type: "object";
|
|
1146
|
+
properties: {
|
|
1147
|
+
agentId: {
|
|
1148
|
+
type: string;
|
|
1149
|
+
description: string;
|
|
1150
|
+
};
|
|
1151
|
+
agentRegistry: {
|
|
1152
|
+
type: string;
|
|
1153
|
+
pattern: string;
|
|
1154
|
+
description: string;
|
|
1155
|
+
};
|
|
1156
|
+
};
|
|
1157
|
+
required: string[];
|
|
1158
|
+
};
|
|
1159
|
+
};
|
|
1160
|
+
'erc8004/checkReputation': {
|
|
1161
|
+
name: string;
|
|
1162
|
+
description: string;
|
|
1163
|
+
inputSchema: {
|
|
1164
|
+
type: "object";
|
|
1165
|
+
properties: {
|
|
1166
|
+
agentId: {
|
|
1167
|
+
type: string;
|
|
1168
|
+
description: string;
|
|
1169
|
+
};
|
|
1170
|
+
agentRegistry: {
|
|
1171
|
+
type: string;
|
|
1172
|
+
pattern: string;
|
|
1173
|
+
description: string;
|
|
1174
|
+
};
|
|
1175
|
+
reputationRegistry: {
|
|
1176
|
+
type: string;
|
|
1177
|
+
pattern: string;
|
|
1178
|
+
description: string;
|
|
1179
|
+
};
|
|
1180
|
+
trustedReviewers: {
|
|
1181
|
+
type: string;
|
|
1182
|
+
items: {
|
|
1183
|
+
type: string;
|
|
1184
|
+
pattern: string;
|
|
1185
|
+
};
|
|
1186
|
+
minItems: number;
|
|
1187
|
+
description: string;
|
|
1188
|
+
};
|
|
1189
|
+
};
|
|
1190
|
+
required: string[];
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
'erc8004/verifyWallet': {
|
|
1194
|
+
name: string;
|
|
1195
|
+
description: string;
|
|
1196
|
+
inputSchema: {
|
|
1197
|
+
type: "object";
|
|
1198
|
+
properties: {
|
|
1199
|
+
agentId: {
|
|
1200
|
+
type: string;
|
|
1201
|
+
description: string;
|
|
1202
|
+
};
|
|
1203
|
+
agentRegistry: {
|
|
1204
|
+
type: string;
|
|
1205
|
+
pattern: string;
|
|
1206
|
+
description: string;
|
|
1207
|
+
};
|
|
1208
|
+
walletAddress: {
|
|
1209
|
+
type: string;
|
|
1210
|
+
pattern: string;
|
|
1211
|
+
description: string;
|
|
1212
|
+
};
|
|
1213
|
+
};
|
|
1214
|
+
required: string[];
|
|
1215
|
+
};
|
|
1216
|
+
};
|
|
1217
|
+
};
|
|
1040
1218
|
|
|
1041
|
-
export { type AllBalancesResult, type AutoPayInput, type AutoPayResult, type BridgeInput, type BridgeOptions, GASLESS_SUPPORTED_NETWORKS, type GetAllBalancesInput, type GetBalanceInput, type GetBridgeFeeInput, type PayGaslessInput, type PayGaslessOptions, type PayInput, type PayOptions, type PaymentPlanInput, type PaymentPlanResult, type SmartPayInput, type SmartPayResult, type SmartPayStep, TOOL_DEFINITIONS, UNIFIED_TOOL_DEFINITIONS, type UnifiedMcpConfig, WDK_TOOL_DEFINITIONS, type WdkBalancesResult, type WdkGetBalancesInput, type WdkGetWalletInput, type WdkSwapInput, type WdkSwapResult, type WdkTransferInput, type WdkTransferResult, type WdkWalletInfo, autoPayInputSchema, bridgeInputSchema, executeAutoPay, executeAutoPayDemo, executeBridge, executeGetAllBalances, executeGetBalance, executeGetBridgeFee, executePay, executePayGasless, executePaymentPlan, executePaymentPlanDemo, executeSmartPay, executeSmartPayDemo, executeWdkGetBalances, executeWdkGetBalancesDemo, executeWdkGetWallet, executeWdkGetWalletDemo, executeWdkSwap, executeWdkSwapDemo, executeWdkTransfer, executeWdkTransferDemo, formatAllBalancesResult, formatAutoPayResult, formatBalanceResult, formatBridgeFeeResult, formatBridgeResult, formatGaslessPaymentResult, formatPaymentPlanResult, formatPaymentResult, formatSmartPayResult, formatWdkBalancesResult, formatWdkSwapResult, formatWdkTransferResult, formatWdkWalletResult, getAllBalancesInputSchema, getBalanceInputSchema, getBridgeFeeInputSchema, payGaslessInputSchema, payInputSchema, paymentPlanInputSchema, smartPayInputSchema, wdkGetBalancesInputSchema, wdkGetWalletInputSchema, wdkSwapInputSchema, wdkTransferInputSchema };
|
|
1219
|
+
export { type AllBalancesResult, type AutoPayInput, type AutoPayResult, type BridgeInput, type BridgeOptions, ERC8004_TOOL_DEFINITIONS, type Erc8004CheckReputationInput, type Erc8004ResolveAgentInput, type Erc8004VerifyWalletInput, type Erc8004VerifyWalletResult, GASLESS_SUPPORTED_NETWORKS, type GetAllBalancesInput, type GetBalanceInput, type GetBridgeFeeInput, type PayGaslessInput, type PayGaslessOptions, type PayInput, type PayOptions, type PaymentPlanInput, type PaymentPlanResult, type SmartPayInput, type SmartPayResult, type SmartPayStep, TOOL_DEFINITIONS, UNIFIED_TOOL_DEFINITIONS, type UnifiedMcpConfig, WDK_TOOL_DEFINITIONS, type WdkBalancesResult, type WdkGetBalancesInput, type WdkGetWalletInput, type WdkSwapInput, type WdkSwapResult, type WdkTransferInput, type WdkTransferResult, type WdkWalletInfo, autoPayInputSchema, bridgeInputSchema, erc8004CheckReputationInputSchema, erc8004ResolveAgentInputSchema, erc8004VerifyWalletInputSchema, executeAutoPay, executeAutoPayDemo, executeBridge, executeErc8004CheckReputation, executeErc8004ResolveAgent, executeErc8004VerifyWallet, executeGetAllBalances, executeGetBalance, executeGetBridgeFee, executePay, executePayGasless, executePaymentPlan, executePaymentPlanDemo, executeSmartPay, executeSmartPayDemo, executeWdkGetBalances, executeWdkGetBalancesDemo, executeWdkGetWallet, executeWdkGetWalletDemo, executeWdkSwap, executeWdkSwapDemo, executeWdkTransfer, executeWdkTransferDemo, formatAllBalancesResult, formatAutoPayResult, formatBalanceResult, formatBridgeFeeResult, formatBridgeResult, formatErc8004CheckReputationResult, formatErc8004ResolveAgentResult, formatErc8004VerifyWalletResult, formatGaslessPaymentResult, formatPaymentPlanResult, formatPaymentResult, formatSmartPayResult, formatWdkBalancesResult, formatWdkSwapResult, formatWdkTransferResult, formatWdkWalletResult, getAllBalancesInputSchema, getBalanceInputSchema, getBridgeFeeInputSchema, payGaslessInputSchema, payInputSchema, paymentPlanInputSchema, smartPayInputSchema, wdkGetBalancesInputSchema, wdkGetWalletInputSchema, wdkSwapInputSchema, wdkTransferInputSchema };
|
package/dist/cjs/tools/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/tools/index.ts
|
|
31
31
|
var tools_exports = {};
|
|
32
32
|
__export(tools_exports, {
|
|
33
|
+
ERC8004_TOOL_DEFINITIONS: () => ERC8004_TOOL_DEFINITIONS,
|
|
33
34
|
GASLESS_SUPPORTED_NETWORKS: () => GASLESS_SUPPORTED_NETWORKS,
|
|
34
35
|
TON_BRIDGE_TOOLS: () => TON_BRIDGE_TOOLS,
|
|
35
36
|
TOOL_DEFINITIONS: () => TOOL_DEFINITIONS,
|
|
@@ -38,9 +39,15 @@ __export(tools_exports, {
|
|
|
38
39
|
autoPayInputSchema: () => autoPayInputSchema,
|
|
39
40
|
bridgeInputSchema: () => bridgeInputSchema,
|
|
40
41
|
createTonBridgeToolSet: () => createTonBridgeToolSet,
|
|
42
|
+
erc8004CheckReputationInputSchema: () => erc8004CheckReputationInputSchema,
|
|
43
|
+
erc8004ResolveAgentInputSchema: () => erc8004ResolveAgentInputSchema,
|
|
44
|
+
erc8004VerifyWalletInputSchema: () => erc8004VerifyWalletInputSchema,
|
|
41
45
|
executeAutoPay: () => executeAutoPay,
|
|
42
46
|
executeAutoPayDemo: () => executeAutoPayDemo,
|
|
43
47
|
executeBridge: () => executeBridge,
|
|
48
|
+
executeErc8004CheckReputation: () => executeErc8004CheckReputation,
|
|
49
|
+
executeErc8004ResolveAgent: () => executeErc8004ResolveAgent,
|
|
50
|
+
executeErc8004VerifyWallet: () => executeErc8004VerifyWallet,
|
|
44
51
|
executeGetAllBalances: () => executeGetAllBalances,
|
|
45
52
|
executeGetBalance: () => executeGetBalance,
|
|
46
53
|
executeGetBridgeFee: () => executeGetBridgeFee,
|
|
@@ -64,6 +71,9 @@ __export(tools_exports, {
|
|
|
64
71
|
formatBalanceResult: () => formatBalanceResult,
|
|
65
72
|
formatBridgeFeeResult: () => formatBridgeFeeResult,
|
|
66
73
|
formatBridgeResult: () => formatBridgeResult,
|
|
74
|
+
formatErc8004CheckReputationResult: () => formatErc8004CheckReputationResult,
|
|
75
|
+
formatErc8004ResolveAgentResult: () => formatErc8004ResolveAgentResult,
|
|
76
|
+
formatErc8004VerifyWalletResult: () => formatErc8004VerifyWalletResult,
|
|
67
77
|
formatGaslessPaymentResult: () => formatGaslessPaymentResult,
|
|
68
78
|
formatPaymentPlanResult: () => formatPaymentPlanResult,
|
|
69
79
|
formatPaymentResult: () => formatPaymentResult,
|
|
@@ -1199,10 +1209,10 @@ var import_zod7 = require("zod");
|
|
|
1199
1209
|
var wdkGetWalletInputSchema = import_zod7.z.object({});
|
|
1200
1210
|
async function executeWdkGetWallet(_input, wdk) {
|
|
1201
1211
|
const signer = await wdk.getSigner("ethereum");
|
|
1202
|
-
const
|
|
1212
|
+
const chains7 = wdk.getConfiguredChains();
|
|
1203
1213
|
return {
|
|
1204
1214
|
evmAddress: signer.address,
|
|
1205
|
-
chains:
|
|
1215
|
+
chains: chains7.length > 0 ? chains7 : ["ethereum"]
|
|
1206
1216
|
};
|
|
1207
1217
|
}
|
|
1208
1218
|
function executeWdkGetWalletDemo() {
|
|
@@ -1234,14 +1244,14 @@ function findTokenFormatted(tokens, symbol) {
|
|
|
1234
1244
|
}
|
|
1235
1245
|
async function executeWdkGetBalances(input, wdk) {
|
|
1236
1246
|
const balances = await wdk.getAggregatedBalances();
|
|
1237
|
-
const
|
|
1247
|
+
const chains7 = balances.chains.filter((c) => !input.chains || input.chains.includes(c.chain)).map((c) => ({
|
|
1238
1248
|
chain: c.chain,
|
|
1239
1249
|
usdt0: findTokenFormatted(c.tokens, "USDT0"),
|
|
1240
1250
|
usdc: findTokenFormatted(c.tokens, "USDC"),
|
|
1241
1251
|
native: (0, import_viem6.formatUnits)(c.native, 18)
|
|
1242
1252
|
}));
|
|
1243
1253
|
return {
|
|
1244
|
-
chains:
|
|
1254
|
+
chains: chains7,
|
|
1245
1255
|
totalUsdt0: (0, import_viem6.formatUnits)(balances.totalUsdt0, 6),
|
|
1246
1256
|
totalUsdc: (0, import_viem6.formatUnits)(balances.totalUsdc, 6)
|
|
1247
1257
|
};
|
|
@@ -1381,7 +1391,6 @@ function formatWdkSwapResult(result) {
|
|
|
1381
1391
|
|
|
1382
1392
|
// src/tools/autoPay.ts
|
|
1383
1393
|
var import_zod11 = require("zod");
|
|
1384
|
-
var import_wdk_protocol = require("@t402/wdk-protocol");
|
|
1385
1394
|
var autoPayInputSchema = import_zod11.z.object({
|
|
1386
1395
|
url: import_zod11.z.string().url().describe("URL to fetch (may return 402 Payment Required)"),
|
|
1387
1396
|
maxAmount: import_zod11.z.string().regex(/^\d+(\.\d+)?$/).optional().describe('Maximum amount willing to pay (e.g., "10.00"). If not set, pays any amount.'),
|
|
@@ -1390,8 +1399,9 @@ var autoPayInputSchema = import_zod11.z.object({
|
|
|
1390
1399
|
)
|
|
1391
1400
|
});
|
|
1392
1401
|
async function executeAutoPay(input, wdk) {
|
|
1393
|
-
const
|
|
1394
|
-
const
|
|
1402
|
+
const chains7 = input.preferredChain ? [input.preferredChain] : ["ethereum", "arbitrum", "base"];
|
|
1403
|
+
const { T402Protocol } = await import("@t402/wdk-protocol");
|
|
1404
|
+
const protocol = await T402Protocol.create(wdk, { chains: chains7 });
|
|
1395
1405
|
const { response, receipt } = await protocol.fetch(input.url);
|
|
1396
1406
|
if (receipt && input.maxAmount) {
|
|
1397
1407
|
const paidAmount = parseFloat(receipt.amount) / 1e6;
|
|
@@ -1717,23 +1727,185 @@ function createTonBridgeToolSet(config) {
|
|
|
1717
1727
|
};
|
|
1718
1728
|
}
|
|
1719
1729
|
|
|
1720
|
-
// src/tools/
|
|
1730
|
+
// src/tools/erc8004ResolveAgent.ts
|
|
1721
1731
|
var import_zod12 = require("zod");
|
|
1722
|
-
var
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1732
|
+
var import_erc80042 = require("@t402/erc8004");
|
|
1733
|
+
|
|
1734
|
+
// src/tools/erc8004Shared.ts
|
|
1735
|
+
var import_viem8 = require("viem");
|
|
1736
|
+
var chains6 = __toESM(require("viem/chains"));
|
|
1737
|
+
var import_erc8004 = require("@t402/erc8004");
|
|
1738
|
+
var CHAIN_ID_TO_VIEM = {
|
|
1739
|
+
1: chains6.mainnet,
|
|
1740
|
+
8453: chains6.base,
|
|
1741
|
+
42161: chains6.arbitrum,
|
|
1742
|
+
10: chains6.optimism,
|
|
1743
|
+
137: chains6.polygon,
|
|
1744
|
+
43114: chains6.avalanche,
|
|
1745
|
+
57073: chains6.ink,
|
|
1746
|
+
80094: chains6.berachain,
|
|
1747
|
+
130: chains6.unichain
|
|
1748
|
+
};
|
|
1749
|
+
var CHAIN_ID_TO_NETWORK = Object.fromEntries(
|
|
1750
|
+
Object.entries(CHAIN_IDS).map(([name, id]) => [id, name])
|
|
1751
|
+
);
|
|
1752
|
+
function createErc8004Client(agentRegistry, rpcUrls) {
|
|
1753
|
+
const parsed = (0, import_erc8004.parseAgentRegistry)(agentRegistry);
|
|
1754
|
+
const chainId = parseInt(parsed.chainId, 10);
|
|
1755
|
+
const viemChain = CHAIN_ID_TO_VIEM[chainId];
|
|
1756
|
+
if (!viemChain) {
|
|
1757
|
+
throw new Error(
|
|
1758
|
+
`Unsupported chain ID ${chainId} from registry ${agentRegistry}. Supported: ${Object.keys(CHAIN_ID_TO_VIEM).join(", ")}`
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
const network = CHAIN_ID_TO_NETWORK[chainId];
|
|
1762
|
+
const rpcUrl = network && rpcUrls?.[network] || network && DEFAULT_RPC_URLS[network];
|
|
1763
|
+
const client = (0, import_viem8.createPublicClient)({
|
|
1764
|
+
chain: viemChain,
|
|
1765
|
+
transport: (0, import_viem8.http)(rpcUrl)
|
|
1766
|
+
});
|
|
1767
|
+
return { client, registryAddress: parsed.address };
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// src/tools/erc8004ResolveAgent.ts
|
|
1771
|
+
var erc8004ResolveAgentInputSchema = import_zod12.z.object({
|
|
1772
|
+
agentId: import_zod12.z.number().int().nonnegative().describe("Agent NFT token ID on the Identity Registry"),
|
|
1773
|
+
agentRegistry: import_zod12.z.string().regex(/^eip155:\d+:0x[a-fA-F0-9]+$/).describe('Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")')
|
|
1774
|
+
});
|
|
1775
|
+
async function executeErc8004ResolveAgent(input, rpcUrls) {
|
|
1776
|
+
const { client, registryAddress } = createErc8004Client(input.agentRegistry, rpcUrls);
|
|
1777
|
+
return (0, import_erc80042.resolveAgent)(
|
|
1778
|
+
client,
|
|
1779
|
+
registryAddress,
|
|
1780
|
+
BigInt(input.agentId),
|
|
1781
|
+
input.agentRegistry
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1784
|
+
function formatErc8004ResolveAgentResult(agent) {
|
|
1785
|
+
const lines = [
|
|
1786
|
+
`## Agent Identity (ID: ${agent.agentId})`,
|
|
1787
|
+
"",
|
|
1788
|
+
`**Registry:** ${agent.registry.id}`,
|
|
1789
|
+
`**Wallet:** \`${agent.agentWallet}\``,
|
|
1790
|
+
`**Owner:** \`${agent.owner}\``,
|
|
1791
|
+
`**Registration URI:** ${agent.agentURI}`,
|
|
1792
|
+
""
|
|
1793
|
+
];
|
|
1794
|
+
if (agent.registration) {
|
|
1795
|
+
const reg = agent.registration;
|
|
1796
|
+
lines.push("### Registration File");
|
|
1797
|
+
if (reg.name) lines.push(`- **Name:** ${reg.name}`);
|
|
1798
|
+
if (reg.description) lines.push(`- **Description:** ${reg.description}`);
|
|
1799
|
+
if (reg.image) lines.push(`- **Image:** ${reg.image}`);
|
|
1800
|
+
if (reg.x402Support !== void 0) lines.push(`- **x402 Support:** ${reg.x402Support}`);
|
|
1801
|
+
if (reg.services?.length) {
|
|
1802
|
+
lines.push("");
|
|
1803
|
+
lines.push("### Services");
|
|
1804
|
+
for (const svc of reg.services) {
|
|
1805
|
+
lines.push(`- **${svc.name}:** ${svc.endpoint}`);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
return lines.join("\n");
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// src/tools/erc8004CheckReputation.ts
|
|
1813
|
+
var import_zod13 = require("zod");
|
|
1814
|
+
var import_erc80043 = require("@t402/erc8004");
|
|
1815
|
+
var erc8004CheckReputationInputSchema = import_zod13.z.object({
|
|
1816
|
+
agentId: import_zod13.z.number().int().nonnegative().describe("Agent NFT token ID"),
|
|
1817
|
+
agentRegistry: import_zod13.z.string().regex(/^eip155:\d+:0x[a-fA-F0-9]+$/).describe('Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'),
|
|
1818
|
+
reputationRegistry: import_zod13.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("Reputation Registry contract address on the same chain"),
|
|
1819
|
+
trustedReviewers: import_zod13.z.array(import_zod13.z.string().regex(/^0x[a-fA-F0-9]{40}$/)).min(1).describe("Addresses whose feedback is trusted (required for Sybil resistance)")
|
|
1820
|
+
});
|
|
1821
|
+
async function executeErc8004CheckReputation(input, rpcUrls) {
|
|
1822
|
+
const { client } = createErc8004Client(input.agentRegistry, rpcUrls);
|
|
1823
|
+
return (0, import_erc80043.getReputationSummary)(
|
|
1824
|
+
client,
|
|
1825
|
+
input.reputationRegistry,
|
|
1826
|
+
BigInt(input.agentId),
|
|
1827
|
+
input.trustedReviewers
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
function formatErc8004CheckReputationResult(summary) {
|
|
1831
|
+
const lines = [
|
|
1832
|
+
`## Agent Reputation (ID: ${summary.agentId})`,
|
|
1833
|
+
"",
|
|
1834
|
+
`| Metric | Value |`,
|
|
1835
|
+
`|--------|-------|`,
|
|
1836
|
+
`| Feedback Count | ${summary.count} |`,
|
|
1837
|
+
`| Raw Score | ${summary.summaryValue} |`,
|
|
1838
|
+
`| Score Decimals | ${summary.summaryValueDecimals} |`,
|
|
1839
|
+
`| **Normalized Score** | **${summary.normalizedScore}/100** |`,
|
|
1840
|
+
""
|
|
1841
|
+
];
|
|
1842
|
+
if (summary.normalizedScore >= 80) {
|
|
1843
|
+
lines.push("_High reputation \u2014 trusted agent_");
|
|
1844
|
+
} else if (summary.normalizedScore >= 50) {
|
|
1845
|
+
lines.push("_Moderate reputation_");
|
|
1846
|
+
} else if (summary.count > 0n) {
|
|
1847
|
+
lines.push("_Low reputation \u2014 exercise caution_");
|
|
1848
|
+
} else {
|
|
1849
|
+
lines.push("_No feedback recorded from trusted reviewers_");
|
|
1850
|
+
}
|
|
1851
|
+
return lines.join("\n");
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
// src/tools/erc8004VerifyWallet.ts
|
|
1855
|
+
var import_zod14 = require("zod");
|
|
1856
|
+
var import_erc80044 = require("@t402/erc8004");
|
|
1857
|
+
var erc8004VerifyWalletInputSchema = import_zod14.z.object({
|
|
1858
|
+
agentId: import_zod14.z.number().int().nonnegative().describe("Agent NFT token ID"),
|
|
1859
|
+
agentRegistry: import_zod14.z.string().regex(/^eip155:\d+:0x[a-fA-F0-9]+$/).describe('Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'),
|
|
1860
|
+
walletAddress: import_zod14.z.string().regex(/^0x[a-fA-F0-9]{40}$/).describe("Wallet address to verify (typically the payTo from PaymentRequirements)")
|
|
1861
|
+
});
|
|
1862
|
+
async function executeErc8004VerifyWallet(input, rpcUrls) {
|
|
1863
|
+
const { client, registryAddress } = createErc8004Client(input.agentRegistry, rpcUrls);
|
|
1864
|
+
const matches = await (0, import_erc80044.verifyPayToMatchesAgent)(
|
|
1865
|
+
client,
|
|
1866
|
+
registryAddress,
|
|
1867
|
+
BigInt(input.agentId),
|
|
1868
|
+
input.walletAddress
|
|
1869
|
+
);
|
|
1870
|
+
return {
|
|
1871
|
+
matches,
|
|
1872
|
+
agentId: input.agentId,
|
|
1873
|
+
walletAddress: input.walletAddress,
|
|
1874
|
+
registryAddress
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
function formatErc8004VerifyWalletResult(result) {
|
|
1878
|
+
const status = result.matches ? "VERIFIED" : "MISMATCH";
|
|
1879
|
+
const icon = result.matches ? "[PASS]" : "[FAIL]";
|
|
1880
|
+
const lines = [
|
|
1881
|
+
`## Wallet Verification: ${icon} ${status}`,
|
|
1882
|
+
"",
|
|
1883
|
+
`| Field | Value |`,
|
|
1884
|
+
`|-------|-------|`,
|
|
1885
|
+
`| Agent ID | ${result.agentId} |`,
|
|
1886
|
+
`| Wallet Address | \`${result.walletAddress}\` |`,
|
|
1887
|
+
`| Registry | \`${result.registryAddress}\` |`,
|
|
1888
|
+
`| **Result** | **${result.matches ? "Address matches on-chain agentWallet" : "Address does NOT match on-chain agentWallet"}** |`
|
|
1889
|
+
];
|
|
1890
|
+
return lines.join("\n");
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
// src/tools/unified.ts
|
|
1894
|
+
var import_zod15 = require("zod");
|
|
1895
|
+
var smartPayInputSchema = import_zod15.z.object({
|
|
1896
|
+
url: import_zod15.z.string().url().describe("URL of the 402-protected resource"),
|
|
1897
|
+
maxBridgeFee: import_zod15.z.string().regex(/^\d+(\.\d+)?$/).optional().describe("Maximum acceptable bridge fee in native token (optional)"),
|
|
1898
|
+
preferredNetwork: import_zod15.z.string().optional().describe("Preferred network for payment (optional)")
|
|
1727
1899
|
});
|
|
1728
|
-
var paymentPlanInputSchema =
|
|
1729
|
-
paymentRequired:
|
|
1730
|
-
scheme:
|
|
1731
|
-
network:
|
|
1732
|
-
maxAmountRequired:
|
|
1733
|
-
resource:
|
|
1734
|
-
description:
|
|
1735
|
-
payTo:
|
|
1736
|
-
maxDeadline:
|
|
1900
|
+
var paymentPlanInputSchema = import_zod15.z.object({
|
|
1901
|
+
paymentRequired: import_zod15.z.object({
|
|
1902
|
+
scheme: import_zod15.z.string().optional(),
|
|
1903
|
+
network: import_zod15.z.string().optional(),
|
|
1904
|
+
maxAmountRequired: import_zod15.z.string().optional(),
|
|
1905
|
+
resource: import_zod15.z.string().optional(),
|
|
1906
|
+
description: import_zod15.z.string().optional(),
|
|
1907
|
+
payTo: import_zod15.z.string().optional(),
|
|
1908
|
+
maxDeadline: import_zod15.z.number().optional()
|
|
1737
1909
|
}).passthrough().describe("The 402 PaymentRequired response")
|
|
1738
1910
|
});
|
|
1739
1911
|
var UNIFIED_TOOL_DEFINITIONS = {
|
|
@@ -1773,13 +1945,14 @@ var UNIFIED_TOOL_DEFINITIONS = {
|
|
|
1773
1945
|
};
|
|
1774
1946
|
async function executeSmartPay(input, wdk) {
|
|
1775
1947
|
const steps = [];
|
|
1776
|
-
const
|
|
1948
|
+
const chains7 = input.preferredNetwork ? [input.preferredNetwork] : ["ethereum", "arbitrum", "base"];
|
|
1777
1949
|
steps.push({
|
|
1778
1950
|
action: "check_balance",
|
|
1779
1951
|
status: "success",
|
|
1780
|
-
detail: `Checking balances on ${
|
|
1952
|
+
detail: `Checking balances on ${chains7.join(", ")}`
|
|
1781
1953
|
});
|
|
1782
|
-
const
|
|
1954
|
+
const { T402Protocol } = await import("@t402/wdk-protocol");
|
|
1955
|
+
const protocol = await T402Protocol.create(wdk, { chains: chains7 });
|
|
1783
1956
|
steps.push({
|
|
1784
1957
|
action: "fetch",
|
|
1785
1958
|
status: "success",
|
|
@@ -2271,8 +2444,84 @@ var WDK_TOOL_DEFINITIONS = {
|
|
|
2271
2444
|
}
|
|
2272
2445
|
}
|
|
2273
2446
|
};
|
|
2447
|
+
var ERC8004_TOOL_DEFINITIONS = {
|
|
2448
|
+
"erc8004/resolveAgent": {
|
|
2449
|
+
name: "erc8004/resolveAgent",
|
|
2450
|
+
description: "Look up an agent's on-chain ERC-8004 identity. Returns the agent's registered wallet address, owner, registration file (name, description, services), and verification URI. Use this to verify an agent before making a payment.",
|
|
2451
|
+
inputSchema: {
|
|
2452
|
+
type: "object",
|
|
2453
|
+
properties: {
|
|
2454
|
+
agentId: {
|
|
2455
|
+
type: "number",
|
|
2456
|
+
description: "Agent NFT token ID on the Identity Registry"
|
|
2457
|
+
},
|
|
2458
|
+
agentRegistry: {
|
|
2459
|
+
type: "string",
|
|
2460
|
+
pattern: "^eip155:\\d+:0x[a-fA-F0-9]+$",
|
|
2461
|
+
description: 'Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'
|
|
2462
|
+
}
|
|
2463
|
+
},
|
|
2464
|
+
required: ["agentId", "agentRegistry"]
|
|
2465
|
+
}
|
|
2466
|
+
},
|
|
2467
|
+
"erc8004/checkReputation": {
|
|
2468
|
+
name: "erc8004/checkReputation",
|
|
2469
|
+
description: "Query an agent's reputation score from the on-chain Reputation Registry. Returns a normalized 0-100 score based on feedback from trusted reviewers. Requires explicit trusted reviewer addresses for Sybil resistance.",
|
|
2470
|
+
inputSchema: {
|
|
2471
|
+
type: "object",
|
|
2472
|
+
properties: {
|
|
2473
|
+
agentId: {
|
|
2474
|
+
type: "number",
|
|
2475
|
+
description: "Agent NFT token ID"
|
|
2476
|
+
},
|
|
2477
|
+
agentRegistry: {
|
|
2478
|
+
type: "string",
|
|
2479
|
+
pattern: "^eip155:\\d+:0x[a-fA-F0-9]+$",
|
|
2480
|
+
description: 'Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'
|
|
2481
|
+
},
|
|
2482
|
+
reputationRegistry: {
|
|
2483
|
+
type: "string",
|
|
2484
|
+
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
2485
|
+
description: "Reputation Registry contract address on the same chain"
|
|
2486
|
+
},
|
|
2487
|
+
trustedReviewers: {
|
|
2488
|
+
type: "array",
|
|
2489
|
+
items: { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" },
|
|
2490
|
+
minItems: 1,
|
|
2491
|
+
description: "Addresses whose feedback is trusted (required for Sybil resistance)"
|
|
2492
|
+
}
|
|
2493
|
+
},
|
|
2494
|
+
required: ["agentId", "agentRegistry", "reputationRegistry", "trustedReviewers"]
|
|
2495
|
+
}
|
|
2496
|
+
},
|
|
2497
|
+
"erc8004/verifyWallet": {
|
|
2498
|
+
name: "erc8004/verifyWallet",
|
|
2499
|
+
description: "Verify that a payment address (payTo) matches an agent's on-chain registered wallet. Use this before paying to confirm the recipient address is legitimate and owned by the declared agent.",
|
|
2500
|
+
inputSchema: {
|
|
2501
|
+
type: "object",
|
|
2502
|
+
properties: {
|
|
2503
|
+
agentId: {
|
|
2504
|
+
type: "number",
|
|
2505
|
+
description: "Agent NFT token ID"
|
|
2506
|
+
},
|
|
2507
|
+
agentRegistry: {
|
|
2508
|
+
type: "string",
|
|
2509
|
+
pattern: "^eip155:\\d+:0x[a-fA-F0-9]+$",
|
|
2510
|
+
description: 'Agent registry identifier (e.g., "eip155:8453:0xRegistryAddress")'
|
|
2511
|
+
},
|
|
2512
|
+
walletAddress: {
|
|
2513
|
+
type: "string",
|
|
2514
|
+
pattern: "^0x[a-fA-F0-9]{40}$",
|
|
2515
|
+
description: "Wallet address to verify (typically the payTo from payment requirements)"
|
|
2516
|
+
}
|
|
2517
|
+
},
|
|
2518
|
+
required: ["agentId", "agentRegistry", "walletAddress"]
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
};
|
|
2274
2522
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2275
2523
|
0 && (module.exports = {
|
|
2524
|
+
ERC8004_TOOL_DEFINITIONS,
|
|
2276
2525
|
GASLESS_SUPPORTED_NETWORKS,
|
|
2277
2526
|
TON_BRIDGE_TOOLS,
|
|
2278
2527
|
TOOL_DEFINITIONS,
|
|
@@ -2281,9 +2530,15 @@ var WDK_TOOL_DEFINITIONS = {
|
|
|
2281
2530
|
autoPayInputSchema,
|
|
2282
2531
|
bridgeInputSchema,
|
|
2283
2532
|
createTonBridgeToolSet,
|
|
2533
|
+
erc8004CheckReputationInputSchema,
|
|
2534
|
+
erc8004ResolveAgentInputSchema,
|
|
2535
|
+
erc8004VerifyWalletInputSchema,
|
|
2284
2536
|
executeAutoPay,
|
|
2285
2537
|
executeAutoPayDemo,
|
|
2286
2538
|
executeBridge,
|
|
2539
|
+
executeErc8004CheckReputation,
|
|
2540
|
+
executeErc8004ResolveAgent,
|
|
2541
|
+
executeErc8004VerifyWallet,
|
|
2287
2542
|
executeGetAllBalances,
|
|
2288
2543
|
executeGetBalance,
|
|
2289
2544
|
executeGetBridgeFee,
|
|
@@ -2307,6 +2562,9 @@ var WDK_TOOL_DEFINITIONS = {
|
|
|
2307
2562
|
formatBalanceResult,
|
|
2308
2563
|
formatBridgeFeeResult,
|
|
2309
2564
|
formatBridgeResult,
|
|
2565
|
+
formatErc8004CheckReputationResult,
|
|
2566
|
+
formatErc8004ResolveAgentResult,
|
|
2567
|
+
formatErc8004VerifyWalletResult,
|
|
2310
2568
|
formatGaslessPaymentResult,
|
|
2311
2569
|
formatPaymentPlanResult,
|
|
2312
2570
|
formatPaymentResult,
|