wowok_agent 2.1.26 → 2.1.28

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/index.js CHANGED
@@ -8,10 +8,156 @@ import packageJson from "../package.json" with { type: "json" };
8
8
  // Import schema
9
9
  import { CallService_DataSchema, CallMachine_DataSchema, MachineNode2File_InputSchema, MachineNode2File_OutputWrappedSchema, CallProgress_DataSchema, CallPermission_DataSchema, CallGuard_DataSchema, Guard2File_InputSchema, Guard2File_OutputWrappedSchema, CallArbitration_DataSchema, CallRepository_DataSchema, CallContact_DataSchema, CallTreasury_DataSchema, CallReward_DataSchema, CallAllocation_DataSchema, CallPersonal_DataSchema, CallPayment_DataSchema, CallDemand_DataSchema, CallOrder_DataSchema, CallEnvSchema, SubmissionCallSchema, strictParse, CallOutputSchema, handleCallResult, createServerConfig, createCapabilitiesConfig, createToolMeta, transformSubmission, getEnvConfig, WipGenerationOptionsSchema, WipToHtmlOptionsSchema, TokenDataFilterSchema, LocalInfoFilterSchema, LocalMarkFilterSchema, AccountFilterSchema, TokenTypeSchema, OnchainEventsInputSchema, OnchainEventsResultSchema, ProtocolInfoQuerySchema, ProtocolInfoResultSchema, WatchQueryOperationsResultSchema, NameOrAddressSchema, AccountOrMark_AddressSchema, ObjectTypeSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, MessengerOperationInputSchema, } from "./schema/index.js";
10
10
  // Import wowok SDK
11
- import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, guard2file, parseGuardFile, formatGuardParseErrors, machineNode2file, generateNodeComments, generate_wip, verify_wip, sign_wip, wip2html, account_operation, local_mark_operation, local_info_operation, watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, query_personal, query_objects, query_table, queryProtocolInfo, query_received, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_events, blacklist, friendslist, guardlist, settings, } from "wowok";
11
+ import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, guard2file, parseGuardFile, formatGuardParseErrors, machineNode2file, generateNodeComments, generate_wip, verify_wip, sign_wip, wip2html, account_operation, local_mark_operation, local_info_operation, watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, query_personal, query_objects, query_table, queryProtocolInfo, query_received, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_events, blacklist, friendslist, guardlist, settings, AmountType, } from "wowok";
12
+ const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
13
+
14
+ ## Token System Overview
15
+
16
+ ### Default Platform Token: WOW
17
+ - Token Type: 0x2::wow::WOW
18
+ - Precision: 1_000_000_000 (9 decimal places)
19
+ - This is the default token for all operations unless specified otherwise
20
+
21
+ ### Multi-Token Support
22
+ The platform supports ANY token (e.g., USDT, USDC, custom tokens). To use non-WOW tokens:
23
+ 1. Use query_toolkit with query_type='token_list' to query available tokens and their precision info
24
+ 2. Use the token's full type string (e.g., '0x2::usdt::USDT') in token_type parameter
25
+ 3. Each token has its own precision - always verify before operations
26
+
27
+ ### Token Precision Handling
28
+ Different tokens have different precisions. ALWAYS query to verify:
29
+ - WOW (default): 1_000_000_000 (9 decimals)
30
+ - Other tokens: Use query_toolkit with query_type='token_list' to get actual precision
31
+ - Never assume a token's decimal places - always query first
32
+
33
+ ## CRITICAL: Token Amount Handling
34
+
35
+ ### Amount Input Rules
36
+ 1. WITH currency unit (e.g., '2WOW', '10.5WOW', '100USDT'):
37
+ - Auto-converted using token's precision: 2WOW -> 2_000_000_000
38
+ - Use for: All on-chain token operations
39
+ - MUST match the token_type parameter
40
+
41
+ 2. WITHOUT currency unit (e.g., '2', '100'):
42
+ - Used as-is: 2 -> 2
43
+ - Use for: Regular numeric parameters (counts, indices, etc.)
44
+
45
+ ### Multi-Token Operation Examples
46
+ - Create USDT-priced Service: token_type='0x2::usdt::USDT', amount='100USDT'
47
+ - Allocate USDC rewards: token_type='0x2::usdc::USDC', amount='500USDC'
48
+ - WOW remains default: omit token_type or use '0x2::wow::WOW'
49
+
50
+ ### Security Warning
51
+ Token amounts are HIGHLY SENSITIVE. Always:
52
+ - Confirm user's intent before executing transfers
53
+ - Verify token type and amount format (with/without unit)
54
+ - Query token precision if unsure
55
+ - Double-check large amount transactions
56
+ - Never assume decimal places - use explicit token unit
57
+
58
+ ## Tool Selection Guide
59
+
60
+ | User Intent | Correct Tool | Wrong Tool (Avoid) |
61
+ |------------|--------------|-------------------|
62
+ | Create service listing | onchain_operations (service) | query_toolkit |
63
+ | Send coins to address | onchain_operations (payment) | account_operation |
64
+ | Check my balance | query_toolkit (account_balance) | onchain_operations |
65
+ | Manage local wallet | account_operation | onchain_operations |
66
+ | Export Guard for edit | guard2file | query_toolkit |
67
+ | Send/Watch encrypted message | messenger_operation | onchain_operations |
68
+ | Create workflow template | onchain_operations (machine) | wip_file |
69
+ | Store my phone number | local_info_operation | onchain_operations |
70
+ | Buy service (create order) | onchain_operations (order) | onchain_operations (service) |
71
+ | Manage my orders | onchain_operations (order) | query_toolkit |
72
+ | Apply for arbitration | onchain_operations (order) | onchain_operations (arbitration) |
73
+ | Create reward pool for marketing | onchain_operations (reward) | onchain_operations (treasury) |
74
+ | Claim rewards from pool | onchain_operations (reward) | query_toolkit |
75
+ | Create fund allocation plan | onchain_operations (allocation) | onchain_operations (treasury) |
76
+ | Execute fund distribution | onchain_operations (allocation) | onchain_operations (payment) |
77
+ | Post service demand with reward | onchain_operations (demand) | onchain_operations (service) |
78
+ | Submit solution for demand | onchain_operations (demand) | onchain_operations (order) |
79
+ | Create team treasury | onchain_operations (treasury) | onchain_operations (allocation) |
80
+ | Deposit/Withdraw from treasury | onchain_operations (treasury) | onchain_operations (payment) |
81
+ | Create access control rules | onchain_operations (permission) | onchain_operations (guard) |
82
+ | Create validation rules (Guard) | onchain_operations (guard) | onchain_operations (permission) |
83
+ | Export Guard for editing | guard2file | query_toolkit |
84
+ | Export Machine nodes for editing | machineNode2file | query_toolkit |
85
+ | Query token list and precision | query_toolkit (token_list) | wowok_buildin_info |
86
+ | Watch on-chain events | onchain_events | query_toolkit |
87
+ | Generate WIP promise file | wip_file (generate) | messenger_operation |
88
+ | Sign WIP file | wip_file (sign) | account_operation (signData) |
89
+ | Verify WIP file integrity | wip_file (verify) | query_toolkit |
90
+ | Send encrypted file via messenger | messenger_operation (send_file) | wip_file |
91
+ | Generate witness timestamp (WTS) | messenger_operation (generate_wts) | wip_file |
92
+ | Query protocol constants | wowok_buildin_info | query_toolkit |
93
+ | Get documentation URL | documents_and_learn | wowok_buildin_info |
94
+
95
+ ## Local vs On-chain Operations
96
+
97
+ ### LOCAL ONLY (Never touch blockchain):
98
+ - account_operation
99
+ - local_mark_operation
100
+ - local_info_operation
101
+
102
+ ### ON-CHAIN (Blockchain transactions):
103
+ - onchain_operations
104
+ - messenger_operation (some operations)
105
+ - wip_file (sign operation)
106
+
107
+ ### QUERY (Read-only):
108
+ - query_toolkit
109
+ - onchain_events
110
+ - wowok_buildin_info
111
+ - documents_and_learn
112
+ - guard2file
113
+ - machineNode2file
114
+ `;
12
115
  // Create server instance
13
116
  const server = new McpServer(createServerConfig(packageJson), createCapabilitiesConfig());
14
117
  // ================================================
118
+ // Helper Functions
119
+ // ================================================
120
+ /**
121
+ * Convert string amount type to AmountType enum
122
+ * Handles case-insensitive matching
123
+ */
124
+ function convertAmountType(type) {
125
+ if (typeof type === "number")
126
+ return type;
127
+ const upperType = type.toUpperCase();
128
+ if (upperType === "GUARDU64IDENTIFIER" || upperType === "GUARD_U64_IDENTIFIER") {
129
+ return AmountType.GuardU64Identifier;
130
+ }
131
+ if (upperType === "FIXED") {
132
+ return AmountType.Fixed;
133
+ }
134
+ return AmountType.Fixed; // default
135
+ }
136
+ /**
137
+ * Transform reward data to convert string amount types to enum values
138
+ */
139
+ function transformRewardData(data) {
140
+ if (!data)
141
+ return data;
142
+ const transformed = { ...data };
143
+ // Transform guard_add array
144
+ if (transformed.guard_add && Array.isArray(transformed.guard_add)) {
145
+ transformed.guard_add = transformed.guard_add.map((guard) => {
146
+ if (guard.amount && typeof guard.amount.type === "string") {
147
+ return {
148
+ ...guard,
149
+ amount: {
150
+ ...guard.amount,
151
+ type: convertAmountType(guard.amount.type)
152
+ }
153
+ };
154
+ }
155
+ return guard;
156
+ });
157
+ }
158
+ return transformed;
159
+ }
160
+ // ================================================
15
161
  // Schema Definitions
16
162
  // ================================================
17
163
  // On-chain Operations Schema (Merged from Merchant and Personal Operations)
@@ -314,7 +460,9 @@ async function handleOnchainOperations(args) {
314
460
  return handleCallResult(result);
315
461
  }
316
462
  case "reward": {
317
- const callReward = new CallReward(validated.data);
463
+ // Transform reward data to convert string amount types to enum values
464
+ const transformedData = transformRewardData(validated.data);
465
+ const callReward = new CallReward(transformedData);
318
466
  const result = validated.submission
319
467
  ? await callReward.call_with_submission(env, transformSubmission(validated.submission))
320
468
  : await callReward.call(env);
@@ -388,7 +536,57 @@ async function handleOnchainOperations(args) {
388
536
  }
389
537
  // Personal Operations
390
538
  case "personal": {
391
- const callPersonal = new CallPersonal(validated.data);
539
+ // Transform AI-friendly string format to SDK object format
540
+ const transformPersonalData = (data) => {
541
+ const result = { ...data };
542
+ // Transform mark operations
543
+ if (data.mark) {
544
+ const transformAddress = (addr) => {
545
+ if (typeof addr === 'string') {
546
+ return { name_or_address: addr, local_mark_first: true };
547
+ }
548
+ return addr;
549
+ };
550
+ if (data.mark.op === 'add' && data.mark.data) {
551
+ result.mark = {
552
+ ...data.mark,
553
+ data: data.mark.data.map((item) => ({
554
+ ...item,
555
+ address: transformAddress(item.address)
556
+ }))
557
+ };
558
+ }
559
+ else if (data.mark.op === 'remove' && data.mark.data) {
560
+ result.mark = {
561
+ ...data.mark,
562
+ data: data.mark.data.map((item) => ({
563
+ ...item,
564
+ address: transformAddress(item.address)
565
+ }))
566
+ };
567
+ }
568
+ else if (data.mark.op === 'clear' && data.mark.address) {
569
+ const addr = data.mark.address;
570
+ if (Array.isArray(addr) && addr.every((a) => typeof a === 'string')) {
571
+ result.mark = {
572
+ ...data.mark,
573
+ address: {
574
+ entities: addr.map((a) => ({ name_or_address: a, local_mark_first: true }))
575
+ }
576
+ };
577
+ }
578
+ }
579
+ else if (data.mark.op === 'transfer' && data.mark.to) {
580
+ result.mark = {
581
+ ...data.mark,
582
+ to: transformAddress(data.mark.to)
583
+ };
584
+ }
585
+ }
586
+ return result;
587
+ };
588
+ const transformedData = transformPersonalData(validated.data);
589
+ const callPersonal = new CallPersonal(transformedData);
392
590
  const result = await callPersonal.call(env);
393
591
  return handleCallResult(result);
394
592
  }