web3agent 0.1.0 → 0.2.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.
@@ -0,0 +1,276 @@
1
+ import {
2
+ VERSION,
3
+ createGoatToolMetadata,
4
+ createRuntime,
5
+ createStartupReport,
6
+ formatHealthSummary,
7
+ getAcpToolDefinitions,
8
+ getAgdpToolDefinitions,
9
+ getErc8004ToolDefinitions,
10
+ getErc8183ToolDefinitions,
11
+ getEvmToolDefinitions,
12
+ getLifiToolDefinitions,
13
+ getOrbsToolDefinitions,
14
+ getTokenToolDefinitions,
15
+ getTransactionToolDefinitions,
16
+ getUtilityToolDefinitions,
17
+ getWalletToolDefinitions,
18
+ getX402ToolDefinitions,
19
+ normalizeInputSchema,
20
+ toHealthStatus
21
+ } from "../chunk-B4LSSN7C.js";
22
+ import "../chunk-ETI3ZR2C.js";
23
+ import "../chunk-4G55KHRO.js";
24
+ import {
25
+ dispatchGoatTool,
26
+ formatToolError
27
+ } from "../chunk-BJUU5ESI.js";
28
+ import {
29
+ walletEvents
30
+ } from "../chunk-KPRIUALX.js";
31
+ import "../chunk-7QEKU2RP.js";
32
+
33
+ // src/runtime/server.ts
34
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
35
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
36
+ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
37
+ function toMcpTool(tool) {
38
+ return {
39
+ name: tool.name,
40
+ description: tool.description,
41
+ inputSchema: normalizeInputSchema(tool.inputSchema),
42
+ ...tool.annotations && { annotations: tool.annotations }
43
+ };
44
+ }
45
+ function getGoatTools(goatProvider) {
46
+ const snapshot = goatProvider.getReferenceSnapshot();
47
+ if (!snapshot) return [];
48
+ return snapshot.listOfTools.map((tool) => createGoatToolMetadata(tool));
49
+ }
50
+ function createLegacyRuntimeBridge(blockscoutAdapter, etherscanAdapter, goatProvider) {
51
+ const frameworkTools = [
52
+ ...getWalletToolDefinitions(),
53
+ ...getTransactionToolDefinitions(),
54
+ ...getUtilityToolDefinitions()
55
+ ];
56
+ const lifiTools = getLifiToolDefinitions();
57
+ const orbsTools = getOrbsToolDefinitions();
58
+ const tokenTools = getTokenToolDefinitions();
59
+ const x402Tools = getX402ToolDefinitions();
60
+ const erc8183Tools = getErc8183ToolDefinitions();
61
+ const acpVirtualsTools = getAcpToolDefinitions();
62
+ const agdpTools = getAgdpToolDefinitions();
63
+ const erc8004Tools = getErc8004ToolDefinitions();
64
+ const evmNativeTools = getEvmToolDefinitions();
65
+ let goatToolNames = new Set(goatProvider.getAllToolNames());
66
+ const toolDispatch = /* @__PURE__ */ new Map();
67
+ const rebuildDispatchMap = () => {
68
+ toolDispatch.clear();
69
+ for (const tool of blockscoutAdapter.getTools()) {
70
+ toolDispatch.set(
71
+ tool.name,
72
+ (args) => blockscoutAdapter.callTool(tool.name, args)
73
+ );
74
+ }
75
+ for (const tool of etherscanAdapter.getTools()) {
76
+ toolDispatch.set(
77
+ tool.name,
78
+ (args) => etherscanAdapter.callTool(tool.name, args)
79
+ );
80
+ }
81
+ for (const tool of evmNativeTools) {
82
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
83
+ }
84
+ for (const tool of tokenTools) {
85
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
86
+ }
87
+ for (const name of goatToolNames) {
88
+ toolDispatch.set(name, (args) => dispatchGoatTool(name, args));
89
+ }
90
+ for (const tool of lifiTools) {
91
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
92
+ }
93
+ for (const tool of orbsTools) {
94
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
95
+ }
96
+ for (const tool of x402Tools) {
97
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
98
+ }
99
+ for (const tool of erc8183Tools) {
100
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
101
+ }
102
+ for (const tool of acpVirtualsTools) {
103
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
104
+ }
105
+ for (const tool of agdpTools) {
106
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
107
+ }
108
+ for (const tool of erc8004Tools) {
109
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
110
+ }
111
+ for (const tool of frameworkTools) {
112
+ toolDispatch.set(tool.name, (args) => tool.handler(args));
113
+ }
114
+ };
115
+ rebuildDispatchMap();
116
+ return {
117
+ getMcpTools() {
118
+ return [
119
+ ...frameworkTools.map(toMcpTool),
120
+ ...getGoatTools(goatProvider),
121
+ ...blockscoutAdapter.getTools(),
122
+ ...etherscanAdapter.getTools(),
123
+ ...evmNativeTools.map(toMcpTool),
124
+ ...lifiTools.map(toMcpTool),
125
+ ...orbsTools.map(toMcpTool),
126
+ ...tokenTools.map(toMcpTool),
127
+ ...x402Tools.map(toMcpTool),
128
+ ...erc8183Tools.map(toMcpTool),
129
+ ...acpVirtualsTools.map(toMcpTool),
130
+ ...agdpTools.map(toMcpTool),
131
+ ...erc8004Tools.map(toMcpTool)
132
+ ];
133
+ },
134
+ async invokeTool(name, args = {}) {
135
+ const handler = toolDispatch.get(name);
136
+ if (!handler) {
137
+ return formatToolError("UNKNOWN_TOOL", `Unknown tool: ${name}`);
138
+ }
139
+ return handler(args);
140
+ },
141
+ onToolsChanged(listener) {
142
+ const handler = () => {
143
+ goatProvider.waitForRebuild().then(() => {
144
+ goatToolNames = new Set(goatProvider.getAllToolNames());
145
+ rebuildDispatchMap();
146
+ listener();
147
+ }).catch((e) => {
148
+ process.stderr.write(`[web3agent] Failed to update tools after wallet change: ${e}
149
+ `);
150
+ });
151
+ };
152
+ walletEvents.on("wallet-changed", handler);
153
+ return () => {
154
+ walletEvents.off("wallet-changed", handler);
155
+ };
156
+ },
157
+ async shutdown() {
158
+ goatProvider.shutdown();
159
+ await goatProvider.waitForRebuild().catch(() => {
160
+ });
161
+ await Promise.allSettled([blockscoutAdapter.shutdown(), etherscanAdapter.shutdown()]);
162
+ }
163
+ };
164
+ }
165
+ function isRuntimeBridge(value) {
166
+ if (!value || typeof value !== "object") return false;
167
+ const candidate = value;
168
+ return typeof candidate.getMcpTools === "function" && typeof candidate.invokeTool === "function" && typeof candidate.onToolsChanged === "function" && typeof candidate.shutdown === "function";
169
+ }
170
+ function requireLegacyAdapter(value, name) {
171
+ if (value === void 0) {
172
+ throw new Error(
173
+ `Legacy ProxyServer construction requires ${name}; use createRuntime() for the managed runtime path`
174
+ );
175
+ }
176
+ return value;
177
+ }
178
+ var ProxyServer = class {
179
+ server;
180
+ removeToolsChangedListener;
181
+ runtime;
182
+ constructor(runtimeOrBlockscout, etherscanAdapter, goatProviderInstance) {
183
+ this.runtime = isRuntimeBridge(runtimeOrBlockscout) ? runtimeOrBlockscout : createLegacyRuntimeBridge(
184
+ runtimeOrBlockscout,
185
+ requireLegacyAdapter(etherscanAdapter, "etherscanAdapter"),
186
+ requireLegacyAdapter(goatProviderInstance, "goatProvider")
187
+ );
188
+ this.server = new Server(
189
+ { name: "web3agent", version: VERSION },
190
+ {
191
+ capabilities: { tools: { listChanged: true } },
192
+ instructions: [
193
+ "web3agent is a unified Web3 MCP proxy server.",
194
+ "Token resolution: ALWAYS call resolve_token before swaps/bridges to get the correct contract address.",
195
+ "Write operations: By default, writes (swaps, bridges, transfers) are queued. Call transaction_confirm(id) to execute, transaction_deny(id) to discard.",
196
+ "Wallet activation: Call wallet_activate with a private key or mnemonic to enable write operations. Call wallet_get_active to check current state.",
197
+ "Browser wallet flows: Use the *_prepare_* intent tools plus transaction_simulate to prepare and inspect externally signed transactions. Generic MCP hosts cannot trigger browser wallet signing prompts themselves.",
198
+ "Chain selection: Most tools accept an optional chainId parameter. Default chain is Base (8453).",
199
+ "Tool routing: Use blockscout_* for historical/indexed data, evm_* for live on-chain state, other tools for DeFi operations."
200
+ ].join(" ")
201
+ }
202
+ );
203
+ this.registerHandlers();
204
+ this.removeToolsChangedListener = this.runtime.onToolsChanged(() => {
205
+ this.server.notification({ method: "notifications/tools/list_changed" }).catch((e) => {
206
+ process.stderr.write(`[web3agent] Failed to emit tools/list_changed: ${e}
207
+ `);
208
+ });
209
+ });
210
+ }
211
+ registerHandlers() {
212
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
213
+ tools: this.getAggregatedTools()
214
+ }));
215
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
216
+ const name = request.params.name;
217
+ const args = request.params.arguments ?? {};
218
+ return this.runtime.invokeTool(name, args);
219
+ });
220
+ }
221
+ getAggregatedTools() {
222
+ return this.runtime.getMcpTools();
223
+ }
224
+ async shutdown() {
225
+ if (this.removeToolsChangedListener) {
226
+ this.removeToolsChangedListener();
227
+ this.removeToolsChangedListener = void 0;
228
+ }
229
+ await this.runtime.shutdown();
230
+ await this.server.close().catch((e) => {
231
+ process.stderr.write(`[web3agent] Failed to close MCP server: ${e}
232
+ `);
233
+ });
234
+ }
235
+ async connect(transport) {
236
+ await this.server.connect(transport);
237
+ }
238
+ async start() {
239
+ const transport = new StdioServerTransport();
240
+ await this.connect(transport);
241
+ }
242
+ };
243
+
244
+ // src/runtime/startup.ts
245
+ async function startServer() {
246
+ const runtime = await createRuntime();
247
+ const server = new ProxyServer(runtime);
248
+ const health = runtime.getHealth();
249
+ const report = createStartupReport({
250
+ health: toHealthStatus(health),
251
+ activeChainId: runtime.config.chainId,
252
+ walletMode: health.walletMode,
253
+ walletAddress: health.walletAddress,
254
+ confirmWrites: health.confirmWrites,
255
+ degradedServices: Object.entries(health.backends).filter(([, backend]) => backend.status !== "ok" && backend.status !== "not_configured").map(([name]) => name),
256
+ totalToolCount: health.toolCount,
257
+ pendingOpsRestored: runtime.pendingOpsRestored > 0 ? runtime.pendingOpsRestored : void 0
258
+ });
259
+ process.stderr.write(`${formatHealthSummary(report)}
260
+ `);
261
+ let shuttingDown = false;
262
+ const gracefulShutdown = async () => {
263
+ if (shuttingDown) return;
264
+ shuttingDown = true;
265
+ process.stderr.write("[web3agent] Shutting down...\n");
266
+ await server.shutdown();
267
+ process.exit(0);
268
+ };
269
+ process.on("SIGTERM", gracefulShutdown);
270
+ process.on("SIGINT", gracefulShutdown);
271
+ await server.start();
272
+ }
273
+ export {
274
+ ProxyServer,
275
+ startServer
276
+ };
@@ -0,0 +1,8 @@
1
+ export { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ export { c as createRuntime } from '../managed-runtime-DCLqOBjp.js';
3
+ export { C as CreateRuntimeOptions, R as RuntimeHealth, T as ToolCatalogEntry, d as ToolCategory, e as ToolErrorPayload, f as ToolResultError, g as ToolResultPayload, h as ToolSource, i as ToolSuccessPayload, W as Web3AgentRuntime } from '../types-B_VpZGqQ.js';
4
+ import '@modelcontextprotocol/sdk/client/index.js';
5
+
6
+ declare function shutdownDefaultRuntime(): Promise<void>;
7
+
8
+ export { shutdownDefaultRuntime };
@@ -0,0 +1,15 @@
1
+ import {
2
+ shutdownDefaultRuntime
3
+ } from "../chunk-7ITJ5WGE.js";
4
+ import {
5
+ createRuntime
6
+ } from "../chunk-B4LSSN7C.js";
7
+ import "../chunk-ETI3ZR2C.js";
8
+ import "../chunk-4G55KHRO.js";
9
+ import "../chunk-BJUU5ESI.js";
10
+ import "../chunk-KPRIUALX.js";
11
+ import "../chunk-7QEKU2RP.js";
12
+ export {
13
+ createRuntime,
14
+ shutdownDefaultRuntime
15
+ };
@@ -0,0 +1,174 @@
1
+ import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+
3
+ interface RuntimeConfig {
4
+ chainId: number;
5
+ privateKey?: string;
6
+ mnemonic?: string;
7
+ walletAccountIndex: number;
8
+ walletAddressIndex: number;
9
+ rpcUrl?: string;
10
+ /** Per-chain RPC overrides keyed by chain ID, parsed from RPC_URL_<chainId> env vars. */
11
+ chainRpcUrls: Record<number, string>;
12
+ confirmWrites: boolean;
13
+ confirmTtlMinutes: number;
14
+ blockscoutMcpUrl: string;
15
+ etherscanMcpUrl: string;
16
+ etherscanApiKey?: string;
17
+ lifiApiKey?: string;
18
+ zeroxApiKey?: string;
19
+ coingeckoApiKey?: string;
20
+ orbsPartner?: string;
21
+ acpContractAddress?: string;
22
+ acpPaymentToken?: string;
23
+ pinataJwt?: string;
24
+ erc8004AgentUri?: string;
25
+ agdpApiUrl?: string;
26
+ }
27
+
28
+ type BackendStatusCode = "ok" | "degraded" | "unavailable" | "not_configured";
29
+ interface BackendStatus {
30
+ name: string;
31
+ status: BackendStatusCode;
32
+ message?: string;
33
+ toolCount?: number;
34
+ }
35
+
36
+ type WalletMode = "private-key" | "mnemonic" | "read-only";
37
+ interface WalletState {
38
+ mode: WalletMode;
39
+ address?: string;
40
+ chainId: number;
41
+ accountIndex: number;
42
+ addressIndex: number;
43
+ }
44
+
45
+ type ToolSource = "wallet" | "transaction" | "operation" | "utility" | "tokens" | "lifi" | "orbs" | "goat" | "blockscout" | "etherscan" | "evm" | "x402" | "acp" | "agdp" | "erc8004";
46
+ type ToolCategory = "wallet" | "transaction" | "operation" | "status" | "tokens" | "swap" | "orders" | "onchain" | "explorer" | "agenticEconomy";
47
+ interface ToolCatalogEntry {
48
+ name: string;
49
+ description: string;
50
+ inputSchema: Tool["inputSchema"];
51
+ source: ToolSource;
52
+ category: ToolCategory;
53
+ dynamic: boolean;
54
+ annotations?: Tool["annotations"];
55
+ }
56
+ interface ToolResultError {
57
+ code: string;
58
+ message: string;
59
+ details?: unknown;
60
+ }
61
+ interface ToolSuccessPayload<T = unknown> {
62
+ ok: true;
63
+ data: T;
64
+ }
65
+ interface ToolErrorPayload {
66
+ ok: false;
67
+ error: ToolResultError;
68
+ }
69
+ type ToolResultPayload<T = unknown> = ToolSuccessPayload<T> | ToolErrorPayload;
70
+ interface RuntimeHealth {
71
+ activeChainId: number;
72
+ walletMode: WalletMode;
73
+ walletAddress?: string;
74
+ confirmWrites: boolean;
75
+ toolCount: number;
76
+ backends: {
77
+ blockscout: BackendStatus;
78
+ etherscan: BackendStatus;
79
+ evm: BackendStatus;
80
+ goat: BackendStatus;
81
+ lifi: BackendStatus;
82
+ orbs: BackendStatus;
83
+ agenticEconomy: BackendStatus;
84
+ };
85
+ }
86
+ type RuntimeToolListener = () => void;
87
+ interface WalletGenerateResult {
88
+ address: string;
89
+ privateKey: string;
90
+ warning: string;
91
+ }
92
+ interface WalletGenerateMnemonicResult {
93
+ mnemonic: string;
94
+ firstAddress: string;
95
+ derivationPath: string;
96
+ warning: string;
97
+ }
98
+ interface WalletAddressDerivationResult {
99
+ address: string;
100
+ derivationPath: string;
101
+ }
102
+ interface WalletDerivedAddressEntry {
103
+ index: number;
104
+ address: string;
105
+ derivationPath: string;
106
+ }
107
+ interface WalletActiveResult {
108
+ mode: string;
109
+ chainId: number;
110
+ address?: string;
111
+ }
112
+ interface WalletDeactivationResult {
113
+ mode: string;
114
+ message: string;
115
+ }
116
+ interface WalletConfirmationResult {
117
+ confirmationRequired: boolean;
118
+ message: string;
119
+ }
120
+ interface TransactionListEntry {
121
+ id: string;
122
+ type: string;
123
+ description: string;
124
+ createdAt: string;
125
+ expiresIn: number;
126
+ walletAddress?: string;
127
+ }
128
+ interface TransactionListResult {
129
+ count: number;
130
+ operations: TransactionListEntry[];
131
+ }
132
+ interface TransactionConfirmResult {
133
+ confirmed: true;
134
+ id: string;
135
+ [key: string]: unknown;
136
+ }
137
+ interface TransactionDenyResult {
138
+ denied: true;
139
+ id: string;
140
+ message: string;
141
+ }
142
+ interface Web3AgentRuntime {
143
+ readonly config: RuntimeConfig;
144
+ listTools(): ToolCatalogEntry[];
145
+ getTool(name: string): ToolCatalogEntry | undefined;
146
+ invokeTool(name: string, args?: Record<string, unknown>): Promise<CallToolResult>;
147
+ getHealth(): RuntimeHealth;
148
+ shutdown(): Promise<void>;
149
+ wallet: {
150
+ generate(): Promise<WalletGenerateResult>;
151
+ generateMnemonic(): Promise<WalletGenerateMnemonicResult>;
152
+ fromMnemonic(params: Record<string, unknown>): Promise<WalletAddressDerivationResult>;
153
+ deriveAddresses(params: Record<string, unknown>): Promise<WalletDerivedAddressEntry[]>;
154
+ getActive(): Promise<WalletActiveResult>;
155
+ activate(params: Record<string, unknown>): Promise<WalletActiveResult>;
156
+ deactivate(): Promise<WalletDeactivationResult>;
157
+ setConfirmation(params: Record<string, unknown>): Promise<WalletConfirmationResult>;
158
+ };
159
+ transactions: {
160
+ list(): Promise<TransactionListResult>;
161
+ confirm(id: string): Promise<TransactionConfirmResult>;
162
+ deny(id: string): Promise<TransactionDenyResult>;
163
+ };
164
+ status: {
165
+ server(): Promise<RuntimeHealth>;
166
+ supportedChains(): Promise<unknown>;
167
+ };
168
+ }
169
+ interface CreateRuntimeOptions {
170
+ config?: RuntimeConfig;
171
+ env?: Partial<Record<string, string>>;
172
+ }
173
+
174
+ export type { BackendStatus as B, CreateRuntimeOptions as C, RuntimeHealth as R, ToolCatalogEntry as T, Web3AgentRuntime as W, WalletState as a, RuntimeConfig as b, RuntimeToolListener as c, ToolCategory as d, ToolErrorPayload as e, ToolResultError as f, ToolResultPayload as g, ToolSource as h, ToolSuccessPayload as i, BackendStatusCode as j, WalletGenerateResult as k, WalletGenerateMnemonicResult as l, WalletAddressDerivationResult as m, WalletDerivedAddressEntry as n, WalletActiveResult as o, WalletDeactivationResult as p, WalletConfirmationResult as q, TransactionListResult as r, TransactionConfirmResult as s, TransactionDenyResult as t };
@@ -0,0 +1,13 @@
1
+ import { x402Client, PaymentRequired } from '@x402/fetch';
2
+
3
+ type X402ClientResult = {
4
+ client: x402Client;
5
+ fetchWithPayment: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
6
+ };
7
+ declare function createX402Client(chainId: number): X402ClientResult;
8
+ declare function probePaymentRequirements(url: string, method?: string, headers?: Record<string, string>, body?: string): Promise<{
9
+ requirements: PaymentRequired | null;
10
+ probeResponse: Response;
11
+ }>;
12
+
13
+ export { type X402ClientResult, createX402Client, probePaymentRequirements };
@@ -0,0 +1,10 @@
1
+ import {
2
+ createX402Client,
3
+ probePaymentRequirements
4
+ } from "../chunk-4G55KHRO.js";
5
+ import "../chunk-KPRIUALX.js";
6
+ import "../chunk-7QEKU2RP.js";
7
+ export {
8
+ createX402Client,
9
+ probePaymentRequirements
10
+ };
@@ -0,0 +1,30 @@
1
+ import { getChain, isSupportedChain, listChainTokens, resolveCanonicalTokenSync } from "web3agent";
2
+
3
+ const chainId = 8453;
4
+ const chain = getChain(chainId);
5
+ const sampleToken = resolveCanonicalTokenSync({ symbol: "USDC", chainId });
6
+ const tokens = listChainTokens({ chainId });
7
+
8
+ process.stdout.write(
9
+ `${JSON.stringify(
10
+ {
11
+ chain: chain
12
+ ? {
13
+ id: chain.id,
14
+ name: chain.name,
15
+ }
16
+ : null,
17
+ supported: isSupportedChain(chainId),
18
+ sampleToken: sampleToken
19
+ ? {
20
+ symbol: sampleToken.symbol,
21
+ address: sampleToken.address,
22
+ decimals: sampleToken.decimals,
23
+ }
24
+ : null,
25
+ tokenCount: tokens.tokens.length,
26
+ },
27
+ null,
28
+ 2
29
+ )}\n`
30
+ );
@@ -0,0 +1,77 @@
1
+ import { createRuntime } from "web3agent/runtime";
2
+
3
+ const shouldRun = process.argv.includes("--run");
4
+
5
+ if (!shouldRun) {
6
+ process.stdout.write(
7
+ `${JSON.stringify(
8
+ {
9
+ createRuntime: typeof createRuntime,
10
+ mode: "imports-only",
11
+ hint: "Pass --run to start the live runtime smoke test.",
12
+ },
13
+ null,
14
+ 2
15
+ )}\n`
16
+ );
17
+ process.exit(0);
18
+ }
19
+
20
+ let runtime;
21
+
22
+ try {
23
+ runtime = await createRuntime();
24
+ const health = runtime.getHealth();
25
+ const toolPreview = runtime
26
+ .listTools()
27
+ .slice(0, 10)
28
+ .map((tool) => ({
29
+ name: tool.name,
30
+ source: tool.source,
31
+ category: tool.category,
32
+ dynamic: tool.dynamic,
33
+ }));
34
+ const supportedChains = await runtime.invokeTool("list_supported_chains");
35
+ const supportedChainsPayload = supportedChains.structuredContent;
36
+
37
+ process.stdout.write(
38
+ `${JSON.stringify(
39
+ {
40
+ mode: "live-runtime",
41
+ health: {
42
+ activeChainId: health.activeChainId,
43
+ walletMode: health.walletMode,
44
+ toolCount: health.toolCount,
45
+ backends: Object.fromEntries(
46
+ Object.entries(health.backends).map(([name, backend]) => [name, backend.status])
47
+ ),
48
+ },
49
+ toolPreview,
50
+ supportedChains:
51
+ supportedChainsPayload?.ok === true
52
+ ? supportedChainsPayload.data
53
+ : supportedChainsPayload?.ok === false
54
+ ? supportedChainsPayload.error
55
+ : supportedChains,
56
+ },
57
+ null,
58
+ 2
59
+ )}\n`
60
+ );
61
+ } catch (error) {
62
+ process.stderr.write(
63
+ `[runtime-smoke] Failed to start live runtime: ${error instanceof Error ? error.message : String(error)}\n`
64
+ );
65
+ process.stderr.write(
66
+ "[runtime-smoke] This path requires live adapter initialization and network access.\n"
67
+ );
68
+ process.exitCode = 1;
69
+ } finally {
70
+ if (runtime) {
71
+ await runtime.shutdown().catch((error) => {
72
+ process.stderr.write(
73
+ `[runtime-smoke] Failed to shut down runtime cleanly: ${error instanceof Error ? error.message : String(error)}\n`
74
+ );
75
+ });
76
+ }
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web3agent",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Web3 MCP proxy server — gives AI agents complete blockchain capabilities through a single install",
5
5
  "license": "MIT",
6
6
  "author": "Apeguru <hello@apeguru.dev>",
@@ -21,15 +21,28 @@
21
21
  "cursor"
22
22
  ],
23
23
  "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./runtime": {
30
+ "types": "./dist/runtime/index.d.ts",
31
+ "import": "./dist/runtime/index.js"
32
+ },
33
+ "./mcp": {
34
+ "types": "./dist/mcp/index.d.ts",
35
+ "import": "./dist/mcp/index.js"
36
+ }
37
+ },
24
38
  "bin": {
25
- "web3agent": "dist/index.js"
39
+ "web3agent": "dist/cli.js"
26
40
  },
27
- "files": ["dist", "WEB3_CONTEXT.md", "README.md", "LICENSE"],
41
+ "files": ["dist", "examples", "WEB3_CONTEXT.md", "README.md", "LICENSE"],
28
42
  "engines": {
29
- "node": ">=18"
43
+ "node": ">=22"
30
44
  },
31
45
  "dependencies": {
32
- "@goat-sdk/adapter-model-context-protocol": "^0.2.11",
33
46
  "@goat-sdk/core": "^0.5.0",
34
47
  "@goat-sdk/plugin-0x": "^0.1.11",
35
48
  "@goat-sdk/plugin-balancer": "^0.1.15",
@@ -44,14 +57,17 @@
44
57
  "@modelcontextprotocol/sdk": "^1.27.1",
45
58
  "@orbs-network/liquidity-hub-sdk": "^1.0.74",
46
59
  "@orbs-network/twap-sdk": "^5.0.0",
47
- "reflect-metadata": "^0.2.2",
60
+ "@orbs-network/twap-ui": "4.0.26-fix.1",
61
+ "@x402/core": "^2.6.0",
62
+ "@x402/evm": "^2.6.0",
63
+ "@x402/fetch": "^2.6.0",
48
64
  "viem": "^2.0.0",
49
65
  "zod": "^3.25.0",
50
66
  "zod-to-json-schema": "^3.23.5"
51
67
  },
52
68
  "devDependencies": {
53
69
  "@biomejs/biome": "^1.9.0",
54
- "@types/node": "^20.0.0",
70
+ "@types/node": "^22.0.0",
55
71
  "tsup": "^8.0.0",
56
72
  "typescript": "^5.5.0",
57
73
  "vitest": "^2.0.0"
@@ -59,7 +75,6 @@
59
75
  "pnpm": {
60
76
  "peerDependencyRules": {
61
77
  "allowedVersions": {
62
- "@goat-sdk/adapter-model-context-protocol>@modelcontextprotocol/sdk": "1.27.1",
63
78
  "@goat-sdk/core": "0.5.0",
64
79
  "viem": "2.47.0",
65
80
  "@goat-sdk/wallet-evm": "0.3.0",
@@ -74,7 +89,7 @@
74
89
  "lint": "biome check .",
75
90
  "lint:fix": "biome check --write .",
76
91
  "typecheck": "tsc --noEmit",
77
- "pack:check": "pnpm pack --dry-run"
92
+ "pack:check": "node -e \"const { execFileSync } = require('node:child_process'); const { mkdtempSync, rmSync } = require('node:fs'); const { tmpdir } = require('node:os'); const { join } = require('node:path'); const dir = mkdtempSync(join(tmpdir(), 'web3agent-pack-')); try { execFileSync(process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm', ['pack', '--pack-destination', dir], { stdio: 'inherit' }); } finally { rmSync(dir, { recursive: true, force: true }); }\""
78
93
  },
79
94
  "packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
80
95
  }