@wowok/agent-mcp 2.3.7 → 2.3.8

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 (38) hide show
  1. package/dist/index.d.ts +1 -15838
  2. package/dist/index.js +40 -394
  3. package/dist/schema/call/bridge-handler.d.ts +5 -0
  4. package/dist/schema/call/bridge-handler.js +234 -0
  5. package/dist/schema/call/bridge.d.ts +2212 -0
  6. package/dist/schema/call/bridge.js +408 -0
  7. package/dist/schema/call/handler.js +29 -15
  8. package/dist/schema/call/index.d.ts +1 -0
  9. package/dist/schema/call/index.js +1 -0
  10. package/dist/schema/index.d.ts +1 -0
  11. package/dist/schema/index.js +1 -0
  12. package/dist/schema/messenger/index.d.ts +74 -74
  13. package/dist/schema/operations.d.ts +24302 -0
  14. package/dist/schema/operations.js +393 -0
  15. package/dist/schema-query/index.d.ts +3 -1
  16. package/dist/schema-query/index.js +63 -3
  17. package/dist/schemas/account_operation.output.json +1395 -0
  18. package/dist/schemas/bridge_operation.output.json +64 -0
  19. package/dist/schemas/bridge_operation.schema.json +547 -0
  20. package/dist/schemas/guard2file.output.json +84 -0
  21. package/dist/schemas/index.json +33 -14
  22. package/dist/schemas/local_info_operation.output.json +70 -0
  23. package/dist/schemas/local_mark_operation.output.json +114 -0
  24. package/dist/schemas/machineNode2file.output.json +89 -0
  25. package/dist/schemas/messenger_operation.output.json +1068 -0
  26. package/dist/schemas/onchain_events.output.json +513 -0
  27. package/dist/schemas/onchain_operations.output.json +1764 -0
  28. package/dist/schemas/onchain_operations.schema.json +8324 -49
  29. package/dist/schemas/onchain_table_data.output.json +1938 -0
  30. package/dist/schemas/onchain_table_data.schema.json +483 -22
  31. package/dist/schemas/query_toolkit.output.json +18 -0
  32. package/dist/schemas/query_toolkit.schema.json +454 -19
  33. package/dist/schemas/schema_query.output.json +42 -0
  34. package/dist/schemas/schema_query.schema.json +1 -0
  35. package/dist/schemas/wip_file.output.json +116 -0
  36. package/dist/schemas/wip_file.schema.json +163 -15
  37. package/dist/schemas/wowok_buildin_info.output.json +577 -0
  38. package/package.json +2 -2
@@ -0,0 +1,408 @@
1
+ import { z } from "zod";
2
+ import { CallEnvSchema } from "./base.js";
3
+ import { WowAddressSchema } from "../common/index.js";
4
+ export const BridgeTokenSchema = z.enum(["ETH", "WETH", "WBTC", "USDC", "USDT"])
5
+ .describe("Cross-chain token identifier. ETH=native ETH; WETH/WBTC/USDC/USDT=ERC20. Decimals are handled by SDK config.");
6
+ export const EvmChainSchema = z.enum(["mainnet"])
7
+ .default("mainnet")
8
+ .describe("EVM chain identifier. Currently only 'mainnet' (Ethereum mainnet, chainId=1) is supported. Extensible to BSC/Polygon/Arbitrum in the future.");
9
+ export const EvmAddressSchema = z.string()
10
+ .regex(/^0x[0-9a-fA-F]{40}$/, "Invalid EVM address (must be 0x + 40 hex)")
11
+ .describe("EVM address (0x + 40 hex)");
12
+ export const BridgeAmountSchema = z.string()
13
+ .describe("Cross-chain amount as a string in the smallest unit (e.g. wei / token minimal unit). Example: 1 ETH = '1000000000000000000'");
14
+ export const BridgeOperationTypeSchema = z.enum([
15
+ "cross_chain_wow_to_evm",
16
+ "cross_chain_evm_to_wow",
17
+ "claim_wow_to_evm",
18
+ "withdraw",
19
+ "query_active_evm_account",
20
+ "query_supported_evm_chains",
21
+ "query_supported_tokens",
22
+ "query_transfer_list",
23
+ "query_transfer_status",
24
+ "manage_evm_rpc",
25
+ ]).describe("Bridge operation type");
26
+ export const BridgeWowToEvmDataSchema = z.object({
27
+ token: BridgeTokenSchema.describe("Cross-chain token type"),
28
+ amount: BridgeAmountSchema.describe("Cross-chain amount (WOW-side smallest unit, wowDecimals)"),
29
+ withdrawTo: EvmAddressSchema.optional()
30
+ .describe("Final withdrawal EVM address; if omitted, assets remain in activeEvmAccount. When provided, the SDK uses the activeEvmAccount key to transfer to this address."),
31
+ }).strict().describe("WOW→EVM cross-chain (step 1: deposit only). " +
32
+ "Returns immediately with depositTxDigest + bridgeSeq + transferId. " +
33
+ "This operation only locks assets on WOW; it does NOT complete the cross-chain. " +
34
+ "After deposit, bridge nodes need ~1-5 minutes to sign. " +
35
+ "Use query_transfer_status to monitor progress; when latestState.step shows 'signatures_ready', " +
36
+ "call claim_wow_to_evm (step 2) to claim assets on EVM. " +
37
+ "[Gas requirements] Step 1 needs WOW gas; Step 2 (claim_wow_to_evm) needs activeEvmAccount to have target-chain gas.");
38
+ export const BridgeEvmToWowDataSchema = z.object({
39
+ token: BridgeTokenSchema.describe("Cross-chain token type (ETH=native ETH, others are ERC20)"),
40
+ amount: BridgeAmountSchema.describe("Cross-chain amount (EVM-side smallest unit, evmDecimals)"),
41
+ recipientWowAddress: WowAddressSchema.optional()
42
+ .describe("WOW recipient address or account name; defaults to env.account if omitted"),
43
+ }).strict().describe("EVM→WOW cross-chain (single step: deposit). " +
44
+ "Returns immediately with depositTxHash + transferId. " +
45
+ "Bridge will automatically claim on WOW (no WOW gas needed, no user action required). " +
46
+ "[Time estimate] ~10-20 minutes total: " +
47
+ "(1) 64-block confirmation ~12.8 min on ETH; " +
48
+ "(2) bridge node auto-claim ~1-5 min on WOW. " +
49
+ "[Status flow] Use query_transfer_status(refresh=true) to monitor: " +
50
+ "latestState.step: source_tx_pending → source_tx_confirmed → signatures_ready → completed. " +
51
+ "When latestState.confirmations >= 64, deposit is finalized and bridge nodes will sign. " +
52
+ "[Gas requirements] Only needs activeEvmAccount to have target-chain gas (for deposit). No WOW gas needed.");
53
+ export const BridgeClaimWowToEvmDataSchema = z.object({
54
+ transferId: z.string().describe("Transfer ID from cross_chain_wow_to_evm (br_<timestamp>_<counter>)"),
55
+ }).strict().describe("WOW→EVM claim (step 2): claim assets on EVM after bridge nodes have signed. " +
56
+ "Prerequisite: cross_chain_wow_to_evm (step 1) must be completed, and query_transfer_status " +
57
+ "must show latestState.step = 'signatures_ready' or 'source_tx_confirmed' (nodes have approved). " +
58
+ "Returns claimTxHash on success. " +
59
+ "After claim_wow_to_evm returns, the claim tx has been submitted and confirmed (1 block) on EVM. " +
60
+ "Use query_transfer_status(refresh=true) to verify latestState.step = 'completed'. " +
61
+ "[Gas requirements] Requires activeEvmAccount to have target-chain gas (for the claim transaction).");
62
+ export const BridgeWithdrawDataSchema = z.object({
63
+ to: EvmAddressSchema.describe("Withdrawal target EVM address"),
64
+ amount: BridgeAmountSchema.describe("Withdrawal amount (smallest unit)"),
65
+ token: BridgeTokenSchema.optional()
66
+ .describe("ERC20 token identifier; if omitted or ETH, withdraws native ETH"),
67
+ tokenAddress: EvmAddressSchema.optional()
68
+ .describe("ERC20 contract address (alternative to token; allows withdrawing by contract address)"),
69
+ network: EvmChainSchema.optional()
70
+ .describe("Target chain (defaults to Ethereum mainnet)"),
71
+ }).strict().describe("Withdraw from activeEvmAccount to another EVM address");
72
+ export const BridgeQueryActiveEvmAccountDataSchema = z.object({
73
+ network: EvmChainSchema.optional()
74
+ .describe("Specific chain; if omitted, queries all supported chains"),
75
+ tokens: z.array(EvmAddressSchema).optional()
76
+ .describe("Additional ERC20 token contract addresses to query; if omitted, only native ETH balance is queried"),
77
+ }).strict().describe("Query activeEvmAccount parameters");
78
+ export const BridgeQuerySupportedTokensDataSchema = z.object({
79
+ network: EvmChainSchema.optional()
80
+ .describe("Specific chain; if omitted, returns token lists for all supported chains"),
81
+ }).strict().describe("Query supported Bridge tokens per chain (WOW/EVM addresses, decimals, description)");
82
+ export const BridgeQueryTransferListDataSchema = z.object({
83
+ onlyActive: z.boolean().optional()
84
+ .describe("true returns only in-progress transfers; false/omitted returns all"),
85
+ status: z.enum(["pending", "in_progress", "success", "failed"]).optional()
86
+ .describe("Filter by transfer status"),
87
+ direction: z.enum(["wow_to_evm", "evm_to_wow", "withdraw"]).optional()
88
+ .describe("Filter by transfer direction"),
89
+ token: BridgeTokenSchema.optional()
90
+ .describe("Filter by token type (ETH/WETH/WBTC/USDC/USDT)"),
91
+ limit: z.number().int().positive().max(100).optional()
92
+ .describe("Maximum number of results (default: all, max: 100)"),
93
+ }).strict().describe("Query transfer list with optional filters (status / direction / token / limit)");
94
+ export const BridgeQueryTransferStatusDataSchema = z.object({
95
+ transferId: z.string().describe("Transfer ID (br_<timestamp>_<counter>)"),
96
+ refresh: z.boolean().optional().default(true)
97
+ .describe("Whether to refresh from on-chain state (default true). " +
98
+ "true=queries latest on-chain status (takes 5-15s, timeout at 15s on slow RPC). " +
99
+ "false=instant response from local cache (no on-chain query). " +
100
+ "Recommended: use refresh=true every 1-2 minutes for ongoing transfers; " +
101
+ "use refresh=false for quick checks between refreshes."),
102
+ }).strict().describe("Query single transfer parameters. " +
103
+ "[Wait hint] With refresh=true (default), this call may take 5-15 seconds to query on-chain state. " +
104
+ "If on-chain RPC is slow, it will timeout at 15s and return cached state. " +
105
+ "Set refresh=false for instant response from local cache. " +
106
+ "[Returned fields] The result includes: " +
107
+ "(1) record.step/status - high-level lifecycle (deposit/claimed/success); " +
108
+ "(2) record.latestState.step/status - fine-grained on-chain progress " +
109
+ "(source_tx_pending → source_tx_confirmed → signatures_ready → completed). " +
110
+ "Use latestState.confirmations to estimate remaining time (needs 64 for ETH→WOW finalization).");
111
+ export const BridgeManageEvmRpcDataSchema = z.discriminatedUnion("op", [
112
+ z.object({
113
+ op: z.literal("list").describe("List all configured RPC endpoints with health status"),
114
+ network: EvmChainSchema.optional()
115
+ .describe("Target chain (defaults to Ethereum mainnet)"),
116
+ }).describe("List RPC endpoints (no rpcUrl/rpcUrls needed)"),
117
+ z.object({
118
+ op: z.literal("add").describe("Append one or more RPC endpoints"),
119
+ network: EvmChainSchema.optional()
120
+ .describe("Target chain (defaults to Ethereum mainnet)"),
121
+ rpcUrls: z.array(z.string().url()).min(1)
122
+ .describe("RPC URL(s) to add"),
123
+ }).describe("Add RPC endpoint(s)"),
124
+ z.object({
125
+ op: z.literal("remove").describe("Remove one or more RPC endpoints"),
126
+ network: EvmChainSchema.optional()
127
+ .describe("Target chain (defaults to Ethereum mainnet)"),
128
+ rpcUrls: z.array(z.string().url()).min(1)
129
+ .describe("RPC URL(s) to remove"),
130
+ }).describe("Remove RPC endpoint(s)"),
131
+ z.object({
132
+ op: z.literal("set").describe("Full replace all RPC endpoints"),
133
+ network: EvmChainSchema.optional()
134
+ .describe("Target chain (defaults to Ethereum mainnet)"),
135
+ rpcUrls: z.array(z.string().url()).min(1)
136
+ .describe("Full RPC list (replaces all existing endpoints)"),
137
+ }).describe("Full replace RPC endpoints"),
138
+ z.object({
139
+ op: z.literal("ping").describe("Health check one or more RPC endpoints"),
140
+ network: EvmChainSchema.optional()
141
+ .describe("Target chain (defaults to Ethereum mainnet)"),
142
+ rpcUrls: z.array(z.string().url()).optional()
143
+ .describe("Specific RPC URLs to ping; if omitted, pings all configured RPCs"),
144
+ }).describe("Health check RPC endpoints"),
145
+ ]).describe("EVM RPC endpoint management (discriminated by op)");
146
+ export const BridgeOperationsSchema = z.preprocess((input) => {
147
+ if (typeof input === "object" && input !== null) {
148
+ const obj = { ...input };
149
+ if (typeof obj.description === "string" && !obj.operation_type) {
150
+ try {
151
+ const parsed = JSON.parse(obj.description);
152
+ if (parsed && typeof parsed === "object" && parsed.operation_type) {
153
+ return parsed;
154
+ }
155
+ }
156
+ catch { }
157
+ }
158
+ if (typeof obj.data === "string") {
159
+ try {
160
+ obj.data = JSON.parse(obj.data);
161
+ }
162
+ catch { }
163
+ }
164
+ if (typeof obj.env === "string") {
165
+ try {
166
+ obj.env = JSON.parse(obj.env);
167
+ }
168
+ catch { }
169
+ }
170
+ return obj;
171
+ }
172
+ return input;
173
+ }, z.discriminatedUnion("operation_type", [
174
+ z.object({
175
+ operation_type: z.literal("cross_chain_wow_to_evm"),
176
+ data: BridgeWowToEvmDataSchema,
177
+ env: CallEnvSchema.optional(),
178
+ }).describe("WOW→EVM cross-chain (simplified): assets auto-claim to activeEvmAccount; if withdrawTo is provided, an additional transfer is made to that address. [Requires WOW mainnet env]"),
179
+ z.object({
180
+ operation_type: z.literal("cross_chain_evm_to_wow"),
181
+ data: BridgeEvmToWowDataSchema,
182
+ env: CallEnvSchema.optional(),
183
+ }).describe("EVM→WOW cross-chain (single step): deposit from activeEvmAccount, bridge auto-claims on WOW. No WOW gas needed. [Requires WOW mainnet env]"),
184
+ z.object({
185
+ operation_type: z.literal("claim_wow_to_evm"),
186
+ data: BridgeClaimWowToEvmDataSchema,
187
+ env: CallEnvSchema.optional(),
188
+ }).describe("WOW→EVM claim (step 2): claim assets on EVM after bridge signed. Requires activeEvmAccount to have EVM gas. [Requires WOW mainnet env]"),
189
+ z.object({
190
+ operation_type: z.literal("withdraw"),
191
+ data: BridgeWithdrawDataSchema,
192
+ }).describe("Withdraw from activeEvmAccount to another EVM address (non-cross-chain). [No env needed]"),
193
+ z.object({
194
+ operation_type: z.literal("query_active_evm_account"),
195
+ data: BridgeQueryActiveEvmAccountDataSchema.optional(),
196
+ }).describe("Query activeEvmAccount address + balances (per chain or all chains). [No env needed]"),
197
+ z.object({
198
+ operation_type: z.literal("query_supported_evm_chains"),
199
+ }).describe("List currently supported EVM chains (enum value / description / chainId / RPC health). [No env needed, no data required]"),
200
+ z.object({
201
+ operation_type: z.literal("query_supported_tokens"),
202
+ data: BridgeQuerySupportedTokensDataSchema.optional(),
203
+ }).describe("List supported Bridge tokens per chain (WOW/EVM contract addresses, decimals, description). [No env needed]"),
204
+ z.object({
205
+ operation_type: z.literal("query_transfer_list"),
206
+ data: BridgeQueryTransferListDataSchema.optional(),
207
+ }).describe("Query cross-chain / withdrawal transfer history list (optionally only in-progress). [No env needed]"),
208
+ z.object({
209
+ operation_type: z.literal("query_transfer_status"),
210
+ data: BridgeQueryTransferStatusDataSchema,
211
+ }).describe("Query a single transfer's detail by transferId"),
212
+ z.object({
213
+ operation_type: z.literal("manage_evm_rpc"),
214
+ data: BridgeManageEvmRpcDataSchema,
215
+ }).describe("Manage EVM RPC endpoints (list/add/remove/set/ping) to mitigate public RPC 429 rate limits. [No env needed]"),
216
+ ]));
217
+ export const BridgeLatestStateSchema = z.object({
218
+ status: z.enum([
219
+ "not_started", "pending", "confirmed", "signatures_ready",
220
+ "claiming", "completed", "failed",
221
+ ]).describe("On-chain status (finer-grained than record.status): " +
222
+ "pending=source tx submitted but not confirmed; " +
223
+ "confirmed=source tx confirmed, waiting for bridge node signatures; " +
224
+ "signatures_ready=nodes signed, ready to claim; " +
225
+ "claiming=claim tx submitted, waiting for confirmation; " +
226
+ "completed=fully completed, assets arrived on target chain; " +
227
+ "failed=on-chain failure"),
228
+ step: z.enum([
229
+ "not_started", "source_tx_pending", "source_tx_confirmed",
230
+ "node_signing", "signatures_ready", "claim_tx_pending",
231
+ "completed", "failed",
232
+ ]).describe("Detailed step (more granular than status). " +
233
+ "source_tx_pending=source chain tx waiting for block confirmation; " +
234
+ "source_tx_confirmed=source confirmed, waiting for bridge nodes to approve; " +
235
+ "node_signing=nodes collecting signatures; " +
236
+ "signatures_ready=sufficient signatures collected, ready to claim on target chain; " +
237
+ "claim_tx_pending=claim tx submitted on target chain, waiting for confirmation; " +
238
+ "completed=assets arrived on target chain; " +
239
+ "failed=error occurred"),
240
+ stepDescription: z.string().optional().describe("Human-readable step description (Chinese)"),
241
+ direction: z.enum(["wow_to_evm", "evm_to_wow"]).optional(),
242
+ sourceTxHash: z.string().optional().describe("Source chain tx hash/digest"),
243
+ bridgeSeq: z.string().optional().describe("Bridge sequence number"),
244
+ confirmations: z.number().optional().describe("Source chain confirmation count (EVM→WOW only; needs 64 for finalization)"),
245
+ claimTxDigest: z.string().optional().describe("WOW claim tx digest (evm_to_wow, when completed)"),
246
+ claimReceipt: z.any().optional().describe("EVM claim tx receipt (wow_to_evm, when available)"),
247
+ ethReceipt: z.any().optional().describe("EVM source tx receipt (evm_to_wow)"),
248
+ wowReceipt: z.any().optional().describe("WOW source tx receipt (wow_to_evm)"),
249
+ error: z.string().optional().describe("Error message if step=failed"),
250
+ hint: z.string().optional().describe("Hint message for next action (e.g., when claim_wow_to_evm not yet called)"),
251
+ updatedAt: z.number().optional().describe("Last on-chain update timestamp (ms)"),
252
+ }).describe("Latest on-chain state (from refresh=true query)");
253
+ export const BridgeTransferRecordSchema = z.object({
254
+ transferId: z.string().describe("Unique ID (br_<timestamp>_<counter>)"),
255
+ direction: z.enum(["wow_to_evm", "evm_to_wow", "withdraw"]).describe("Transfer direction"),
256
+ token: BridgeTokenSchema.describe("Token identifier"),
257
+ amount: z.string().describe("Amount in smallest unit (string to avoid bigint issues)"),
258
+ recipientEth: z.string().optional().describe("ETH-side recipient address"),
259
+ recipientWow: z.string().optional().describe("WOW-side recipient address"),
260
+ intermediateEthAccount: z.string().describe("Intermediate EVM account (activeEvmAccount)"),
261
+ step: z.enum(["init", "deposit", "claimed", "withdraw", "withdrawn"]).describe("Current step in the transfer lifecycle: " +
262
+ "init=just created; " +
263
+ "deposit=source chain deposit in progress; " +
264
+ "claimed=claim completed on target chain (success); " +
265
+ "withdraw=intermediate→final withdraw in progress; " +
266
+ "withdrawn=withdraw completed"),
267
+ status: z.enum(["pending", "in_progress", "success", "failed"]).describe("Transfer status: pending/in_progress=ongoing; success=fully completed; failed=error"),
268
+ depositTxHash: z.string().optional().describe("EVM deposit tx hash (evm_to_wow)"),
269
+ depositTxDigest: z.string().optional().describe("WOW deposit tx digest (wow_to_evm)"),
270
+ bridgeSeq: z.string().optional().describe("Bridge sequence number"),
271
+ claimTxHash: z.string().optional().describe("EVM claim tx hash (wow_to_evm)"),
272
+ claimTxDigest: z.string().optional().describe("WOW claim tx digest (evm_to_wow)"),
273
+ withdrawTxHash: z.string().optional().describe("EVM withdraw tx hash (withdraw step)"),
274
+ error: z.string().optional().describe("Error message if status=failed"),
275
+ createdAt: z.number().describe("Creation timestamp (ms)"),
276
+ updatedAt: z.number().describe("Last update timestamp (ms)"),
277
+ latestState: BridgeLatestStateSchema.optional().describe("Latest on-chain state (only present after refresh=true query). " +
278
+ "Provides real-time progress: confirmations count, node signing status, claim tx hash, etc. " +
279
+ "Use this to estimate remaining time and next action."),
280
+ }).strict().describe("Bridge transfer record");
281
+ export const BridgeWowToEvmResultSchema = z.object({
282
+ depositTxDigest: z.string().describe("WOW deposit tx digest"),
283
+ bridgeSeq: z.string().describe("Bridge sequence number"),
284
+ activeEvmAccount: z.string().describe("activeEvmAccount address that will receive the assets"),
285
+ transferId: z.string().describe("Transfer ID (br_<timestamp>_<counter>). Save this for claim_wow_to_evm (step 2) and query_transfer_status"),
286
+ }).strict().describe("WOW→EVM cross-chain step 1 result (deposit only, claim pending)");
287
+ export const BridgeEvmToWowResultSchema = z.object({
288
+ depositTxHash: z.string().describe("EVM deposit tx hash"),
289
+ activeEvmAccount: z.string().describe("activeEvmAccount address that initiated the deposit"),
290
+ transferId: z.string().describe("Transfer ID (br_<timestamp>_<counter>). Save this for query_transfer_status"),
291
+ }).strict().describe("EVM→WOW cross-chain result (deposit submitted, auto-claim in progress)");
292
+ export const BridgeClaimWowToEvmResultSchema = z.object({
293
+ claimTxHash: z.string().describe("EVM claim tx hash"),
294
+ transferId: z.string().describe("Transfer ID"),
295
+ }).strict().describe("WOW→EVM claim (step 2) result");
296
+ export const BridgeWithdrawResultSchema = z.object({
297
+ txHash: z.string().describe("EVM withdraw tx hash"),
298
+ transferId: z.string().describe("Transfer ID (br_<timestamp>_<counter>)"),
299
+ }).strict().describe("Withdraw from activeEvmAccount result");
300
+ export const BridgeQueryActiveEvmAccountResultSchema = z.object({
301
+ address: z.string().describe("activeEvmAccount address (0x + 40 hex)"),
302
+ chains: z.array(z.object({
303
+ chainId: z.number().describe("EVM chain ID"),
304
+ name: z.string().describe("Chain name"),
305
+ nativeBalance: z.string().describe("Native ETH balance (wei, string)"),
306
+ tokens: z.array(z.object({
307
+ tokenAddress: z.string().describe("ERC20 token contract address"),
308
+ balance: z.string().describe("Token balance (smallest unit, string)"),
309
+ })).optional().describe("Additional ERC20 token balances (if requested)"),
310
+ })).describe("Per-chain balance information"),
311
+ }).strict().describe("activeEvmAccount query result");
312
+ export const BridgeQuerySupportedEvmChainsResultSchema = z.array(z.object({
313
+ chainId: z.number().describe("EVM chain ID"),
314
+ name: z.string().describe("Chain name (enum value)"),
315
+ description: z.string().describe("Human-readable chain description"),
316
+ bridgeChainId: z.number().describe("Bridge protocol chain ID"),
317
+ explorerUrl: z.string().describe("Block explorer URL"),
318
+ rpcCount: z.number().describe("Total configured RPC endpoints"),
319
+ healthyRpcCount: z.number().describe("Currently healthy RPC endpoints"),
320
+ })).describe("List of supported EVM chains");
321
+ export const BridgeQuerySupportedTokensResultSchema = z.array(z.object({
322
+ chainId: z.number().describe("EVM chain ID"),
323
+ chainName: z.string().describe("Chain name"),
324
+ bridgeChainId: z.number().describe("Bridge protocol chain ID"),
325
+ tokens: z.array(z.object({
326
+ tokenId: z.number().describe("On-chain token ID"),
327
+ symbol: z.string().describe("Token symbol (ETH/WETH/WBTC/USDC/USDT)"),
328
+ evmAddress: z.string().describe("EVM-side contract address (0x000...000 for native ETH)"),
329
+ evmDecimals: z.number().describe("EVM-side decimals"),
330
+ wowTypeTag: z.string().describe("WOW-side type tag"),
331
+ wowDecimals: z.number().describe("WOW-side decimals"),
332
+ description: z.string().describe("Token description"),
333
+ })).describe("Tokens available on this chain"),
334
+ })).describe("Supported Bridge tokens per chain");
335
+ export const BridgeQueryTransferListResultSchema = z.array(BridgeTransferRecordSchema)
336
+ .describe("Transfer history list");
337
+ export const BridgeQueryTransferStatusResultSchema = BridgeTransferRecordSchema.nullable()
338
+ .describe("Single transfer detail (null if not found)");
339
+ export const BridgeManageEvmRpcResultSchema = z.object({
340
+ op: z.string().describe("Operation performed (list/add/remove/set/ping)"),
341
+ success: z.boolean().describe("Whether the operation succeeded"),
342
+ result: z.any().optional().describe("Operation-specific result (list=array of RPC status, ping=health results, add/remove/set=void)"),
343
+ }).strict().describe("EVM RPC management result");
344
+ export const BridgeOutputSchema = z.discriminatedUnion("operation_type", [
345
+ z.object({
346
+ operation_type: z.literal("cross_chain_wow_to_evm"),
347
+ result: BridgeWowToEvmResultSchema,
348
+ message: z.string().optional().describe("Result summary or hint message"),
349
+ }).describe("WOW→EVM cross-chain result"),
350
+ z.object({
351
+ operation_type: z.literal("cross_chain_evm_to_wow"),
352
+ result: BridgeEvmToWowResultSchema,
353
+ message: z.string().optional().describe("Result summary or hint message"),
354
+ }).describe("EVM→WOW cross-chain result"),
355
+ z.object({
356
+ operation_type: z.literal("claim_wow_to_evm"),
357
+ result: BridgeClaimWowToEvmResultSchema,
358
+ message: z.string().optional().describe("Result summary or hint message"),
359
+ }).describe("WOW→EVM claim (step 2) result"),
360
+ z.object({
361
+ operation_type: z.literal("withdraw"),
362
+ result: BridgeWithdrawResultSchema,
363
+ message: z.string().optional().describe("Result summary or hint message"),
364
+ }).describe("Withdraw from activeEvmAccount result"),
365
+ z.object({
366
+ operation_type: z.literal("query_active_evm_account"),
367
+ result: BridgeQueryActiveEvmAccountResultSchema,
368
+ message: z.string().optional().describe("Result summary or hint message"),
369
+ }).describe("activeEvmAccount query result"),
370
+ z.object({
371
+ operation_type: z.literal("query_supported_evm_chains"),
372
+ result: BridgeQuerySupportedEvmChainsResultSchema,
373
+ message: z.string().optional().describe("Result summary or hint message"),
374
+ }).describe("Supported EVM chains result"),
375
+ z.object({
376
+ operation_type: z.literal("query_supported_tokens"),
377
+ result: BridgeQuerySupportedTokensResultSchema,
378
+ message: z.string().optional().describe("Result summary or hint message"),
379
+ }).describe("Supported Bridge tokens per chain result"),
380
+ z.object({
381
+ operation_type: z.literal("query_transfer_list"),
382
+ result: BridgeQueryTransferListResultSchema,
383
+ message: z.string().optional().describe("Result summary or hint message"),
384
+ }).describe("Transfer history list result"),
385
+ z.object({
386
+ operation_type: z.literal("query_transfer_status"),
387
+ result: BridgeQueryTransferStatusResultSchema,
388
+ message: z.string().optional().describe("Result summary or hint message"),
389
+ }).describe("Single transfer detail result"),
390
+ z.object({
391
+ operation_type: z.literal("manage_evm_rpc"),
392
+ result: BridgeManageEvmRpcResultSchema,
393
+ message: z.string().optional().describe("Result summary or hint message"),
394
+ }).describe("EVM RPC management result"),
395
+ ]).describe("Bridge operation result (discriminated by operation_type with per-operation typed result)");
396
+ export const BridgeCallOutputSchema = z.object({
397
+ message: z.string().optional().describe("Result summary or hint message"),
398
+ result: z.discriminatedUnion("type", [
399
+ z.object({
400
+ type: z.literal("data"),
401
+ data: z.any().describe("Operation result data (structure varies by operation_type)"),
402
+ }).describe("Successful result"),
403
+ z.object({
404
+ type: z.literal("error"),
405
+ error: z.string().describe("Error message"),
406
+ }).describe("Error result"),
407
+ ]).describe("Bridge operation result (data or error)"),
408
+ }).describe("Bridge operation output (matches CallOutput structure returned by the handler)");
@@ -1,7 +1,21 @@
1
1
  import { ResponseData, LocalMark, enrichMoveError } from "@wowok/wowok";
2
+ function convertBigInts(obj) {
3
+ if (typeof obj === "bigint")
4
+ return obj.toString();
5
+ if (Array.isArray(obj))
6
+ return obj.map(convertBigInts);
7
+ if (obj && typeof obj === "object") {
8
+ const out = {};
9
+ for (const k of Object.keys(obj))
10
+ out[k] = convertBigInts(obj[k]);
11
+ return out;
12
+ }
13
+ return obj;
14
+ }
2
15
  export function handleCallResult(result) {
3
- if (result && "error" in result) {
4
- const enrichedError = enrichMoveError(result.error);
16
+ const safeResult = convertBigInts(result);
17
+ if (safeResult && "error" in safeResult) {
18
+ const enrichedError = enrichMoveError(safeResult.error);
5
19
  const output = {
6
20
  message: `Error: ${enrichedError}`,
7
21
  result: { type: "error", error: enrichedError },
@@ -11,10 +25,10 @@ export function handleCallResult(result) {
11
25
  structuredContent: output,
12
26
  };
13
27
  }
14
- if (result && "digest" in result) {
15
- const r = ResponseData(result);
16
- const txStatus = result?.effects?.status?.status;
17
- const txError = result?.effects?.status?.error;
28
+ if (safeResult && "digest" in safeResult) {
29
+ const r = ResponseData(safeResult);
30
+ const txStatus = safeResult?.effects?.status?.status;
31
+ const txError = safeResult?.effects?.status?.error;
18
32
  const isSuccess = txStatus === "success";
19
33
  if (!isSuccess) {
20
34
  const enrichedError = enrichMoveError(txError || txStatus || "unknown error");
@@ -32,7 +46,7 @@ export function handleCallResult(result) {
32
46
  }
33
47
  const output = {
34
48
  message: "Transaction completed successfully",
35
- result: { type: "transaction", ...result },
49
+ result: { type: "transaction", ...safeResult },
36
50
  };
37
51
  return {
38
52
  content: [
@@ -42,33 +56,33 @@ export function handleCallResult(result) {
42
56
  structuredContent: output,
43
57
  };
44
58
  }
45
- if (result && "guard" in result && "submission" in result) {
59
+ if (safeResult && "guard" in safeResult && "submission" in safeResult) {
46
60
  const output = {
47
61
  message: "Submission required for Guard verification",
48
- result: { type: "submission", ...result },
62
+ result: { type: "submission", ...safeResult },
49
63
  };
50
64
  return {
51
65
  content: [
52
66
  { type: "text", text: output.message },
53
- { type: "text", text: JSON.stringify(result) },
67
+ { type: "text", text: JSON.stringify(safeResult) },
54
68
  ],
55
69
  structuredContent: output,
56
70
  };
57
71
  }
58
- if (Array.isArray(result)) {
72
+ if (Array.isArray(safeResult)) {
59
73
  const output = {
60
74
  message: "Operation completed",
61
- result: { type: "data", data: result },
75
+ result: { type: "data", data: safeResult },
62
76
  };
63
77
  return {
64
78
  content: [
65
79
  { type: "text", text: output.message },
66
- { type: "text", text: JSON.stringify(result) },
80
+ { type: "text", text: JSON.stringify(safeResult) },
67
81
  ],
68
82
  structuredContent: output,
69
83
  };
70
84
  }
71
- if (result === undefined || result === null) {
85
+ if (safeResult === undefined || safeResult === null) {
72
86
  const output = {
73
87
  message: "Operation completed",
74
88
  result: { type: "null" },
@@ -80,7 +94,7 @@ export function handleCallResult(result) {
80
94
  }
81
95
  const output = {
82
96
  message: "Operation completed",
83
- result: { type: "transaction", ...result },
97
+ result: { type: "transaction", ...safeResult },
84
98
  };
85
99
  return {
86
100
  content: [{ type: "text", text: output.message }],
@@ -16,3 +16,4 @@ export * from './repository.js';
16
16
  export * from './reward.js';
17
17
  export * from './service.js';
18
18
  export * from './treasury.js';
19
+ export * from './bridge.js';
@@ -16,3 +16,4 @@ export * from './repository.js';
16
16
  export * from './reward.js';
17
17
  export * from './service.js';
18
18
  export * from './treasury.js';
19
+ export * from './bridge.js';
@@ -3,5 +3,6 @@ export * from './query/index.js';
3
3
  export * from './local/index.js';
4
4
  export * from './messenger/index.js';
5
5
  export * from './common/index.js';
6
+ export * from './operations.js';
6
7
  export * from './utils/guard-parser.js';
7
8
  export * from './utils/node-parser.js';
@@ -3,5 +3,6 @@ export * from './query/index.js';
3
3
  export * from './local/index.js';
4
4
  export * from './messenger/index.js';
5
5
  export * from './common/index.js';
6
+ export * from './operations.js';
6
7
  export * from './utils/guard-parser.js';
7
8
  export * from './utils/node-parser.js';