wowok_agent 2.1.38 â 2.1.40
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.d.ts +45 -2
- package/dist/index.js +1 -1319
- package/dist/schema/call/allocation.js +1 -27
- package/dist/schema/call/arbitration.js +1 -106
- package/dist/schema/call/base.js +1 -152
- package/dist/schema/call/contact.js +1 -41
- package/dist/schema/call/demand.js +1 -51
- package/dist/schema/call/guard.d.ts +6 -6
- package/dist/schema/call/guard.js +1 -67
- package/dist/schema/call/handler.d.ts +0 -45
- package/dist/schema/call/handler.js +1 -230
- package/dist/schema/call/index.js +1 -19
- package/dist/schema/call/machine.js +1 -164
- package/dist/schema/call/order.js +1 -39
- package/dist/schema/call/payment.js +1 -20
- package/dist/schema/call/permission.js +1 -118
- package/dist/schema/call/personal.js +1 -81
- package/dist/schema/call/progress.js +1 -28
- package/dist/schema/call/proof.js +1 -27
- package/dist/schema/call/repository.js +1 -85
- package/dist/schema/call/reward.d.ts +12 -0
- package/dist/schema/call/reward.js +1 -46
- package/dist/schema/call/service.js +1 -88
- package/dist/schema/call/treasury.d.ts +84 -0
- package/dist/schema/call/treasury.js +1 -76
- package/dist/schema/common/index.js +1 -395
- package/dist/schema/index.js +1 -8
- package/dist/schema/local/index.js +1 -913
- package/dist/schema/local/wip.js +1 -230
- package/dist/schema/messenger/index.d.ts +4 -6
- package/dist/schema/messenger/index.js +1 -479
- package/dist/schema/query/index.d.ts +155 -0
- package/dist/schema/query/index.js +1 -1256
- package/dist/schema/utils/guard-parser.js +1 -410
- package/dist/schema/utils/guard-query-utils.js +1 -22
- package/dist/schema/utils/node-parser.d.ts +0 -14
- package/dist/schema/utils/node-parser.js +1 -382
- package/dist/schema/utils/permission-index-utils.js +1 -10
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -1,1320 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
-
import { readFileSync } from "fs";
|
|
6
|
-
import { resolve } from "path";
|
|
7
|
-
// Read package.json
|
|
8
|
-
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
9
|
-
// Import schema
|
|
10
|
-
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";
|
|
11
|
-
// Import wowok SDK
|
|
12
|
-
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, mark_messages_as_viewed, mark_conversation_as_viewed, 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";
|
|
13
|
-
const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
|
|
14
|
-
|
|
15
|
-
## Token System Overview
|
|
16
|
-
|
|
17
|
-
### Default Platform Token: WOW
|
|
18
|
-
- Token Type: 0x2::wow::WOW
|
|
19
|
-
- Precision: 1_000_000_000 (9 decimal places)
|
|
20
|
-
- This is the default token for all operations unless specified otherwise
|
|
21
|
-
|
|
22
|
-
### Multi-Token Support
|
|
23
|
-
The platform supports ANY token (e.g., USDT, USDC, custom tokens). To use non-WOW tokens:
|
|
24
|
-
1. Use query_toolkit with query_type='token_list' to query available tokens and their precision info
|
|
25
|
-
2. Use the token's full type string (e.g., '0x2::usdt::USDT') in token_type parameter
|
|
26
|
-
3. Each token has its own precision - always verify before operations
|
|
27
|
-
|
|
28
|
-
### Token Precision Handling
|
|
29
|
-
Different tokens have different precisions. ALWAYS query to verify:
|
|
30
|
-
- WOW (default): 1_000_000_000 (9 decimals)
|
|
31
|
-
- Other tokens: Use query_toolkit with query_type='token_list' to get actual precision
|
|
32
|
-
- Never assume a token's decimal places - always query first
|
|
33
|
-
|
|
34
|
-
## CRITICAL: Token Amount Handling
|
|
35
|
-
|
|
36
|
-
### Amount Input Rules
|
|
37
|
-
1. WITH currency unit (e.g., '2WOW', '10.5WOW', '100USDT'):
|
|
38
|
-
- Auto-converted using token's precision: 2WOW -> 2_000_000_000
|
|
39
|
-
- Use for: All on-chain token operations
|
|
40
|
-
- MUST match the token_type parameter
|
|
41
|
-
|
|
42
|
-
2. WITHOUT currency unit (e.g., '2', '100'):
|
|
43
|
-
- Used as-is: 2 -> 2
|
|
44
|
-
- Use for: Regular numeric parameters (counts, indices, etc.)
|
|
45
|
-
|
|
46
|
-
### Multi-Token Operation Examples
|
|
47
|
-
- Create USDT-priced Service: token_type='0x2::usdt::USDT', amount='100USDT'
|
|
48
|
-
- Allocate USDC rewards: token_type='0x2::usdc::USDC', amount='500USDC'
|
|
49
|
-
- WOW remains default: omit token_type or use '0x2::wow::WOW'
|
|
50
|
-
|
|
51
|
-
### Security Warning
|
|
52
|
-
Token amounts are HIGHLY SENSITIVE. Always:
|
|
53
|
-
- Confirm user's intent before executing transfers
|
|
54
|
-
- Verify token type and amount format (with/without unit)
|
|
55
|
-
- Query token precision if unsure
|
|
56
|
-
- Double-check large amount transactions
|
|
57
|
-
- Never assume decimal places - use explicit token unit
|
|
58
|
-
|
|
59
|
-
## Tool Selection Guide
|
|
60
|
-
|
|
61
|
-
| User Intent | Correct Tool | Wrong Tool (Avoid) |
|
|
62
|
-
|------------|--------------|-------------------|
|
|
63
|
-
| Create service listing | onchain_operations (service) | query_toolkit |
|
|
64
|
-
| Send coins to address | onchain_operations (payment) | account_operation |
|
|
65
|
-
| Check my balance | query_toolkit (account_balance) | onchain_operations |
|
|
66
|
-
| Manage local wallet | account_operation | onchain_operations |
|
|
67
|
-
| Export Guard for edit | guard2file | query_toolkit |
|
|
68
|
-
| Send/Watch encrypted message | messenger_operation | onchain_operations |
|
|
69
|
-
| Create workflow template | onchain_operations (machine) | wip_file |
|
|
70
|
-
| Store my phone number | local_info_operation | onchain_operations |
|
|
71
|
-
| Buy service (create order) | onchain_operations (order) | onchain_operations (service) |
|
|
72
|
-
| Manage my orders | onchain_operations (order) | query_toolkit |
|
|
73
|
-
| Apply for arbitration | onchain_operations (order) | onchain_operations (arbitration) |
|
|
74
|
-
| Create reward pool for marketing | onchain_operations (reward) | onchain_operations (treasury) |
|
|
75
|
-
| Claim rewards from pool | onchain_operations (reward) | query_toolkit |
|
|
76
|
-
| Create fund allocation plan | onchain_operations (allocation) | onchain_operations (treasury) |
|
|
77
|
-
| Execute fund distribution | onchain_operations (allocation) | onchain_operations (payment) |
|
|
78
|
-
| Post service demand with reward | onchain_operations (demand) | onchain_operations (service) |
|
|
79
|
-
| Submit solution for demand | onchain_operations (demand) | onchain_operations (order) |
|
|
80
|
-
| Create team treasury | onchain_operations (treasury) | onchain_operations (allocation) |
|
|
81
|
-
| Deposit/Withdraw from treasury | onchain_operations (treasury) | onchain_operations (payment) |
|
|
82
|
-
| Create access control rules | onchain_operations (permission) | onchain_operations (guard) |
|
|
83
|
-
| Create validation rules (Guard) | onchain_operations (guard) | onchain_operations (permission) |
|
|
84
|
-
| Export Guard for editing | guard2file | query_toolkit |
|
|
85
|
-
| Export Machine nodes for editing | machineNode2file | query_toolkit |
|
|
86
|
-
| Query token list and precision | query_toolkit (token_list) | wowok_buildin_info |
|
|
87
|
-
| Watch on-chain events | onchain_events | query_toolkit |
|
|
88
|
-
| Generate WIP promise file | wip_file (generate) | messenger_operation |
|
|
89
|
-
| Sign WIP file | wip_file (sign) | account_operation (signData) |
|
|
90
|
-
| Verify WIP file integrity | wip_file (verify) | query_toolkit |
|
|
91
|
-
| Send encrypted file via messenger | messenger_operation (send_file) | wip_file |
|
|
92
|
-
| Generate witness timestamp (WTS) | messenger_operation (generate_wts) | wip_file |
|
|
93
|
-
| Query protocol constants | wowok_buildin_info | query_toolkit |
|
|
94
|
-
| Get documentation URL | documents_and_learn | wowok_buildin_info |
|
|
95
|
-
|
|
96
|
-
## Local vs On-chain Operations
|
|
97
|
-
|
|
98
|
-
### LOCAL ONLY (Never touch blockchain):
|
|
99
|
-
- account_operation
|
|
100
|
-
- local_mark_operation
|
|
101
|
-
- local_info_operation
|
|
102
|
-
|
|
103
|
-
### ON-CHAIN (Blockchain transactions):
|
|
104
|
-
- onchain_operations
|
|
105
|
-
- messenger_operation (some operations)
|
|
106
|
-
- wip_file (sign operation)
|
|
107
|
-
|
|
108
|
-
### QUERY (Read-only):
|
|
109
|
-
- query_toolkit
|
|
110
|
-
- onchain_events
|
|
111
|
-
- wowok_buildin_info
|
|
112
|
-
- documents_and_learn
|
|
113
|
-
- guard2file
|
|
114
|
-
- machineNode2file
|
|
115
|
-
`;
|
|
116
|
-
// Create server instance with SERVER_DESCRIPTION
|
|
117
|
-
const server = new McpServer(createServerConfig(packageJson, SERVER_DESCRIPTION), createCapabilitiesConfig());
|
|
118
|
-
// ================================================
|
|
119
|
-
// Helper Functions
|
|
120
|
-
// ================================================
|
|
121
|
-
/**
|
|
122
|
-
* Convert string amount type to AmountType enum
|
|
123
|
-
* Handles case-insensitive matching
|
|
124
|
-
*/
|
|
125
|
-
function convertAmountType(type) {
|
|
126
|
-
if (typeof type === "number")
|
|
127
|
-
return type;
|
|
128
|
-
const upperType = type.toUpperCase();
|
|
129
|
-
if (upperType === "GUARDU64IDENTIFIER" || upperType === "GUARD_U64_IDENTIFIER") {
|
|
130
|
-
return AmountType.GuardU64Identifier;
|
|
131
|
-
}
|
|
132
|
-
if (upperType === "FIXED") {
|
|
133
|
-
return AmountType.Fixed;
|
|
134
|
-
}
|
|
135
|
-
return AmountType.Fixed; // default
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Transform reward data to convert string amount types to enum values
|
|
139
|
-
*/
|
|
140
|
-
function transformRewardData(data) {
|
|
141
|
-
if (!data)
|
|
142
|
-
return data;
|
|
143
|
-
const transformed = { ...data };
|
|
144
|
-
// Transform guard_add array
|
|
145
|
-
if (transformed.guard_add && Array.isArray(transformed.guard_add)) {
|
|
146
|
-
transformed.guard_add = transformed.guard_add.map((guard) => {
|
|
147
|
-
if (guard.amount && typeof guard.amount.type === "string") {
|
|
148
|
-
return {
|
|
149
|
-
...guard,
|
|
150
|
-
amount: {
|
|
151
|
-
...guard.amount,
|
|
152
|
-
type: convertAmountType(guard.amount.type)
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return guard;
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return transformed;
|
|
160
|
-
}
|
|
161
|
-
// ================================================
|
|
162
|
-
// Schema Definitions
|
|
163
|
-
// ================================================
|
|
164
|
-
// On-chain Operations Schema (Merged from Merchant and Personal Operations)
|
|
165
|
-
const OnchainOperationsSchema = z.discriminatedUnion("operation_type", [
|
|
166
|
-
// Merchant Operations
|
|
167
|
-
z.object({
|
|
168
|
-
operation_type: z.literal("service"),
|
|
169
|
-
data: CallService_DataSchema,
|
|
170
|
-
env: CallEnvSchema.optional(),
|
|
171
|
-
submission: SubmissionCallSchema.optional(),
|
|
172
|
-
}).describe("đĒ Service Object: Create and manage product/service listings with transparent promises, bind workflow templates to order processing, set pricing, issue discount coupons to customers, and establish quality standards, etc.."),
|
|
173
|
-
z.object({
|
|
174
|
-
operation_type: z.literal("machine"),
|
|
175
|
-
data: CallMachine_DataSchema,
|
|
176
|
-
env: CallEnvSchema.optional(),
|
|
177
|
-
submission: SubmissionCallSchema.optional(),
|
|
178
|
-
}).describe("âī¸ Machine Object: Design and deploy automated workflow templates (Machines) that define how services are delivered, etc.."),
|
|
179
|
-
z.object({
|
|
180
|
-
operation_type: z.literal("progress"),
|
|
181
|
-
data: CallProgress_DataSchema,
|
|
182
|
-
env: CallEnvSchema.optional(),
|
|
183
|
-
submission: SubmissionCallSchema.optional(),
|
|
184
|
-
}).describe("đ Progress Object: Track and manage active workflows in real-time."),
|
|
185
|
-
z.object({
|
|
186
|
-
operation_type: z.literal("repository"),
|
|
187
|
-
data: CallRepository_DataSchema,
|
|
188
|
-
env: CallEnvSchema.optional(),
|
|
189
|
-
submission: SubmissionCallSchema.optional(),
|
|
190
|
-
}).describe("đĻ Repository Object: Read/write database with consensus field + address as key, strongly-typed data as value."),
|
|
191
|
-
z.object({
|
|
192
|
-
operation_type: z.literal("arbitration"),
|
|
193
|
-
data: CallArbitration_DataSchema,
|
|
194
|
-
env: CallEnvSchema.optional(),
|
|
195
|
-
submission: SubmissionCallSchema.optional(),
|
|
196
|
-
}).describe("âī¸ Arbitration Object: Access a transparent on-chain arbitration system for resolving order conflicts."),
|
|
197
|
-
z.object({
|
|
198
|
-
operation_type: z.literal("contact"),
|
|
199
|
-
data: CallContact_DataSchema,
|
|
200
|
-
env: CallEnvSchema.optional(),
|
|
201
|
-
submission: SubmissionCallSchema.optional(),
|
|
202
|
-
}).describe("đŦ Contact Object: Manage on-chain instant messaging contact profiles."),
|
|
203
|
-
z.object({
|
|
204
|
-
operation_type: z.literal("treasury"),
|
|
205
|
-
data: CallTreasury_DataSchema,
|
|
206
|
-
env: CallEnvSchema.optional(),
|
|
207
|
-
submission: SubmissionCallSchema.optional(),
|
|
208
|
-
}).describe("đ° Treasury Object: Create and manage treasury for team funds with deposit/withdrawal rules, etc.."),
|
|
209
|
-
z.object({
|
|
210
|
-
operation_type: z.literal("reward"),
|
|
211
|
-
data: CallReward_DataSchema,
|
|
212
|
-
env: CallEnvSchema.optional(),
|
|
213
|
-
submission: SubmissionCallSchema.optional(),
|
|
214
|
-
}).describe("đ Reward Object: Create reward pools and set claim conditions by Guard verification."),
|
|
215
|
-
z.object({
|
|
216
|
-
operation_type: z.literal("allocation"),
|
|
217
|
-
data: CallAllocation_DataSchema,
|
|
218
|
-
env: CallEnvSchema.optional(),
|
|
219
|
-
submission: SubmissionCallSchema.optional(),
|
|
220
|
-
}).describe("đ¤ Allocation Object: Create distribution plans to auto-distribute funds to multiple recipients."),
|
|
221
|
-
z.object({
|
|
222
|
-
operation_type: z.literal("permission"),
|
|
223
|
-
data: CallPermission_DataSchema,
|
|
224
|
-
env: CallEnvSchema.optional(),
|
|
225
|
-
}).describe("đ Permission Object: Define who can perform which operations on WoWok objects. Important Note: If needed, you should first query 'guard instructions' through the 'wowok_buildin_info' tool."),
|
|
226
|
-
z.object({
|
|
227
|
-
operation_type: z.literal("guard"),
|
|
228
|
-
data: CallGuard_DataSchema,
|
|
229
|
-
env: CallEnvSchema.optional(),
|
|
230
|
-
}).describe("đĄī¸ Guard Object: Create immutable programmable validation rules that return boolean results. Set 'namedNew' to name the new Guard. Use root.type='node' for direct node tree or root.type='file' to load from file. Use 'wowok_buildin_info' tool with query='guard instructions' for all available operations."),
|
|
231
|
-
// Personal Operations
|
|
232
|
-
z.object({
|
|
233
|
-
operation_type: z.literal("personal"),
|
|
234
|
-
data: CallPersonal_DataSchema,
|
|
235
|
-
env: CallEnvSchema.optional(),
|
|
236
|
-
}).describe("đ Public Identity Profile: Establish and manage your on-chain public identity. â ī¸ CRITICAL: Everything here is PERMANENTLY PUBLIC on the blockchain!"),
|
|
237
|
-
z.object({
|
|
238
|
-
operation_type: z.literal("payment"),
|
|
239
|
-
data: CallPayment_DataSchema,
|
|
240
|
-
env: CallEnvSchema.optional(),
|
|
241
|
-
}).describe("đ° Payment Object: Send instant, irreversible coin transfers to any wallet address."),
|
|
242
|
-
z.object({
|
|
243
|
-
operation_type: z.literal("demand"),
|
|
244
|
-
data: CallDemand_DataSchema,
|
|
245
|
-
env: CallEnvSchema.optional(),
|
|
246
|
-
submission: SubmissionCallSchema.optional(),
|
|
247
|
-
}).describe("đ¯ Demand Object: Post service requests with reward pools on-chain."),
|
|
248
|
-
z.object({
|
|
249
|
-
operation_type: z.literal("order"),
|
|
250
|
-
data: CallOrder_DataSchema,
|
|
251
|
-
env: CallEnvSchema.optional(),
|
|
252
|
-
submission: SubmissionCallSchema.optional(),
|
|
253
|
-
}).describe("đĻ Order Object: Manage the order lifecycle, Including operating order arbitration (Arb Object associated with the order), advancing progress (Progress Object associated with the order), extracting order refunds/payments, setting agents, etc."),
|
|
254
|
-
z.object({
|
|
255
|
-
operation_type: z.literal("gen_passport"),
|
|
256
|
-
guard: z.string().describe("Guard object ID to verify and generate passport from"),
|
|
257
|
-
info: SubmissionCallSchema.optional().describe("Optional submission data. If not provided, will attempt to get existing submissions from the guard."),
|
|
258
|
-
env: CallEnvSchema.optional(),
|
|
259
|
-
}).describe("đ Generate Verified Passport Object: Create immutable verified credentials after Guard validation passes."),
|
|
260
|
-
]);
|
|
261
|
-
// WIP Operations Schema
|
|
262
|
-
const WipOperationsSchema = z.discriminatedUnion("type", [
|
|
263
|
-
z.object({
|
|
264
|
-
type: z.literal("generate"),
|
|
265
|
-
options: WipGenerationOptionsSchema.describe("WIP generation options"),
|
|
266
|
-
outputPath: z.string().describe("Output file path (.wip file). If file exists, it will be overwritten"),
|
|
267
|
-
}).describe("Generate WIP file from markdown text and optional images"),
|
|
268
|
-
z.object({
|
|
269
|
-
type: z.literal("verify"),
|
|
270
|
-
wipFilePath: z.string().describe("WIP file path to verify. Supports: 1) Local file path (e.g., '/path/to/file.wip', 'C:\\Users\\name\\doc.wip'), 2) Network URL (e.g., 'https://example.com/doc.wip', 'http://site.com/file.wip'), 3) Data URL (e.g., 'data:application/json;base64,eyJ3aXAiOi...')"),
|
|
271
|
-
hash_equal: z.string().optional().describe("Optional expected hash value. If provided, the function will first verify if the file's hash matches this value. If not matched, returns hash mismatch error."),
|
|
272
|
-
requireSignature: z.boolean().optional().describe("Optional flag to require digital signature. If true, verification will fail if WIP file has no signature"),
|
|
273
|
-
}).describe("Verify WIP file integrity and signatures"),
|
|
274
|
-
z.object({
|
|
275
|
-
type: z.literal("sign"),
|
|
276
|
-
wipFilePath: z.string().describe("WIP file path to sign. Supports: 1) Local file path (e.g., '/path/to/file.wip'), 2) Network URL (e.g., 'https://example.com/doc.wip'). The file will be loaded, validated, and signed"),
|
|
277
|
-
account: z.string().optional().describe("Signing account (account name or address). If not specified, uses default account"),
|
|
278
|
-
outputPath: z.string().optional().describe("Output file path. If not specified, adds 'signed_' prefix to original file name (e.g., 'doc.wip' becomes 'signed_doc.wip')"),
|
|
279
|
-
}).describe("Sign WIP file with account"),
|
|
280
|
-
z.object({
|
|
281
|
-
type: z.literal("wip2html"),
|
|
282
|
-
wipPath: z.string().describe("WIP file path or directory path. Supports: 1) Single WIP file (e.g., '/path/to/file.wip'), 2) Directory containing .wip files (e.g., '/path/to/wips/'), 3) Network URL (e.g., 'https://example.com/doc.wip'). When directory is provided, all .wip files in the directory will be converted to HTML"),
|
|
283
|
-
options: WipToHtmlOptionsSchema.optional().describe("Conversion options"),
|
|
284
|
-
}).describe("Convert WIP file to HTML format"),
|
|
285
|
-
]);
|
|
286
|
-
// Watch Query Operations Schema
|
|
287
|
-
const WatchQueryOperationsSchema = z.discriminatedUnion("query_type", [
|
|
288
|
-
z.object({
|
|
289
|
-
query_type: z.literal("local_mark_list"),
|
|
290
|
-
filter: LocalMarkFilterSchema.optional().describe("Local mark filter"),
|
|
291
|
-
}).describe("Query local ID/USER address book with optional filter"),
|
|
292
|
-
z.object({
|
|
293
|
-
query_type: z.literal("account_list"),
|
|
294
|
-
filter: AccountFilterSchema.optional().describe("Account filter"),
|
|
295
|
-
}).describe("Query account list with optional filter"),
|
|
296
|
-
z.object({
|
|
297
|
-
query_type: z.literal("local_info_list"),
|
|
298
|
-
filter: LocalInfoFilterSchema.optional().describe("Local info filter"),
|
|
299
|
-
}).describe("Query local info list with optional filter"),
|
|
300
|
-
z.object({
|
|
301
|
-
query_type: z.literal("token_list"),
|
|
302
|
-
filter: TokenDataFilterSchema.optional(),
|
|
303
|
-
}).describe("Query token list with optional filter"),
|
|
304
|
-
z.object({
|
|
305
|
-
query_type: z.literal("account_balance"),
|
|
306
|
-
name_or_address: NameOrAddressSchema.optional().describe("Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."),
|
|
307
|
-
token_type: TokenTypeSchema.optional().describe("Token type; default token type is 0x2::wow::WOW"),
|
|
308
|
-
}).describe("Query account balance or coin objects by the token type"),
|
|
309
|
-
z.object({
|
|
310
|
-
query_type: z.literal("onchain_personal_profile"),
|
|
311
|
-
account: NameOrAddressSchema.optional().describe("Account name or ID to query. Use empty string '' for the default account."),
|
|
312
|
-
}).describe("Query PUBLIC on-chain personal profile for any account address"),
|
|
313
|
-
z.object({
|
|
314
|
-
query_type: z.literal("onchain_objects"),
|
|
315
|
-
objects: z.array(NameOrAddressSchema).describe("List of object IDs to query"),
|
|
316
|
-
}).describe("Query on-chain objects"),
|
|
317
|
-
z.object({
|
|
318
|
-
query_type: z.literal("onchain_table"),
|
|
319
|
-
parent: NameOrAddressSchema,
|
|
320
|
-
object_type: ObjectTypeSchema,
|
|
321
|
-
}).describe("Query on-chain table data of the specified object"),
|
|
322
|
-
z.object({
|
|
323
|
-
query_type: z.literal("onchain_table_item_repository_data"),
|
|
324
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
325
|
-
name: z.string().describe("Name of the record to query"),
|
|
326
|
-
entity: z.union([AccountOrMark_AddressSchema, z.number()]).describe("ID or address of the entity; or address that number is casted to"),
|
|
327
|
-
}).describe("Query repository data table item"),
|
|
328
|
-
z.object({
|
|
329
|
-
query_type: z.literal("onchain_table_item_permission_perm"),
|
|
330
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
331
|
-
address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User ID or address, or Guard ID in the permission perm table"),
|
|
332
|
-
}).describe("Query permission perm table item"),
|
|
333
|
-
z.object({
|
|
334
|
-
query_type: z.literal("onchain_table_item_entity_registrar"),
|
|
335
|
-
address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User ID or address of the entity"),
|
|
336
|
-
}).describe("Query entity registrar table item"),
|
|
337
|
-
z.object({
|
|
338
|
-
query_type: z.literal("onchain_table_item_entity_linker"),
|
|
339
|
-
address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("ID or address that the registrar votes are attached to"),
|
|
340
|
-
}).describe("Query entity linker table item"),
|
|
341
|
-
z.object({
|
|
342
|
-
query_type: z.literal("onchain_table_item_reward_record"),
|
|
343
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
344
|
-
address: AccountOrMark_AddressSchema.describe("User ID or address that claims the reward"),
|
|
345
|
-
}).describe("Query reward record table item"),
|
|
346
|
-
z.object({
|
|
347
|
-
query_type: z.literal("onchain_table_item_demand_presenter"),
|
|
348
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
349
|
-
address: AccountOrMark_AddressSchema.describe("User ID or address of the Demand presenter"),
|
|
350
|
-
}).describe("Query demand presenter table item"),
|
|
351
|
-
z.object({
|
|
352
|
-
query_type: z.literal("onchain_table_item_treasury_history"),
|
|
353
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
354
|
-
address: AccountOrMark_AddressSchema.describe("ID of the payment that the treasury record is attached to"),
|
|
355
|
-
}).describe("Query treasury record table item"),
|
|
356
|
-
z.object({
|
|
357
|
-
query_type: z.literal("onchain_table_item_machine_node"),
|
|
358
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
359
|
-
key: z.string().describe("String key of the node name to query"),
|
|
360
|
-
}).describe("Query machine node table item"),
|
|
361
|
-
z.object({
|
|
362
|
-
query_type: z.literal("onchain_table_item_progress_history"),
|
|
363
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
364
|
-
u64: z.union([z.number(), z.string()]).describe("U64 value of the record to query"),
|
|
365
|
-
}).describe("Query progress history table item"),
|
|
366
|
-
z.object({
|
|
367
|
-
query_type: z.literal("onchain_table_item_address_mark"),
|
|
368
|
-
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
369
|
-
address: AccountOrMark_AddressSchema.describe("ID or address that the mark name and tags are attached to"),
|
|
370
|
-
}).describe("Query address mark table item"),
|
|
371
|
-
z.object({
|
|
372
|
-
query_type: z.literal("onchain_received"),
|
|
373
|
-
object: z.string().describe("Object ID to query"),
|
|
374
|
-
all_type: z.boolean().optional().describe("Whether to query all types of received objects"),
|
|
375
|
-
}).describe("Query on-chain received balance, payments, and NFTs"),
|
|
376
|
-
]);
|
|
377
|
-
// ================================================
|
|
378
|
-
// Handler Functions
|
|
379
|
-
// ================================================
|
|
380
|
-
async function handleOnchainOperations(args) {
|
|
381
|
-
console.log("=== handleOnchainOperations ===");
|
|
382
|
-
console.log("args:", JSON.stringify(args, null, 2));
|
|
383
|
-
try {
|
|
384
|
-
const validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
|
|
385
|
-
console.log("validated:", JSON.stringify(validated, null, 2));
|
|
386
|
-
const env = getEnvConfig(validated.env);
|
|
387
|
-
switch (validated.operation_type) {
|
|
388
|
-
// Merchant Operations
|
|
389
|
-
case "service": {
|
|
390
|
-
const callService = new CallService(validated.data);
|
|
391
|
-
const result = validated.submission
|
|
392
|
-
? await callService.call_with_submission(env, await transformSubmission(validated.submission))
|
|
393
|
-
: await callService.call(env);
|
|
394
|
-
return handleCallResult(result);
|
|
395
|
-
}
|
|
396
|
-
case "machine": {
|
|
397
|
-
// Handle json_or_markdown_file in data.node if provided
|
|
398
|
-
if (validated.data.node && typeof validated.data.node === 'object' && 'json_or_markdown_file' in validated.data.node) {
|
|
399
|
-
const filePathStr = validated.data.node.json_or_markdown_file;
|
|
400
|
-
let fileContent;
|
|
401
|
-
try {
|
|
402
|
-
const filePath = resolve(filePathStr);
|
|
403
|
-
fileContent = readFileSync(filePath, 'utf-8');
|
|
404
|
-
}
|
|
405
|
-
catch (e) {
|
|
406
|
-
throw new Error(`Failed to read file '${filePathStr}': ${e.message}`);
|
|
407
|
-
}
|
|
408
|
-
const parseResult = parseMachineNodesFromText(fileContent);
|
|
409
|
-
if (!parseResult.success) {
|
|
410
|
-
const errorMessages = formatMachineNodeErrors(parseResult.errors);
|
|
411
|
-
throw new Error(`Machine node validation failed for file '${filePathStr}':\n\n${errorMessages}`);
|
|
412
|
-
}
|
|
413
|
-
if (!parseResult.data) {
|
|
414
|
-
throw new Error(`No nodes found in file '${filePathStr}'`);
|
|
415
|
-
}
|
|
416
|
-
// Replace data.node with parsed nodes (set operation with replace)
|
|
417
|
-
validated.data.node = {
|
|
418
|
-
op: "set",
|
|
419
|
-
nodes: parseResult.data,
|
|
420
|
-
bReplace: true
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
const callMachine = new CallMachine(validated.data);
|
|
424
|
-
const result = validated.submission
|
|
425
|
-
? await callMachine.call_with_submission(env, await transformSubmission(validated.submission))
|
|
426
|
-
: await callMachine.call(env);
|
|
427
|
-
return handleCallResult(result);
|
|
428
|
-
}
|
|
429
|
-
case "progress": {
|
|
430
|
-
const callProgress = new CallProgress(validated.data);
|
|
431
|
-
const result = validated.submission
|
|
432
|
-
? await callProgress.call_with_submission(env, await transformSubmission(validated.submission))
|
|
433
|
-
: await callProgress.call(env);
|
|
434
|
-
return handleCallResult(result);
|
|
435
|
-
}
|
|
436
|
-
case "repository": {
|
|
437
|
-
const callRepository = new CallRepository(validated.data);
|
|
438
|
-
const result = validated.submission
|
|
439
|
-
? await callRepository.call_with_submission(env, await transformSubmission(validated.submission))
|
|
440
|
-
: await callRepository.call(env);
|
|
441
|
-
return handleCallResult(result);
|
|
442
|
-
}
|
|
443
|
-
case "arbitration": {
|
|
444
|
-
const callArbitration = new CallArbitration(validated.data);
|
|
445
|
-
const result = validated.submission
|
|
446
|
-
? await callArbitration.call_with_submission(env, await transformSubmission(validated.submission))
|
|
447
|
-
: await callArbitration.call(env);
|
|
448
|
-
return handleCallResult(result);
|
|
449
|
-
}
|
|
450
|
-
case "contact": {
|
|
451
|
-
const callContact = new CallContact(validated.data);
|
|
452
|
-
const result = validated.submission
|
|
453
|
-
? await callContact.call_with_submission(env, await transformSubmission(validated.submission))
|
|
454
|
-
: await callContact.call(env);
|
|
455
|
-
return handleCallResult(result);
|
|
456
|
-
}
|
|
457
|
-
case "treasury": {
|
|
458
|
-
const callTreasury = new CallTreasury(validated.data);
|
|
459
|
-
const result = validated.submission
|
|
460
|
-
? await callTreasury.call_with_submission(env, await transformSubmission(validated.submission))
|
|
461
|
-
: await callTreasury.call(env);
|
|
462
|
-
return handleCallResult(result);
|
|
463
|
-
}
|
|
464
|
-
case "reward": {
|
|
465
|
-
// Transform reward data to convert string amount types to enum values
|
|
466
|
-
const transformedData = transformRewardData(validated.data);
|
|
467
|
-
const callReward = new CallReward(transformedData);
|
|
468
|
-
const result = validated.submission
|
|
469
|
-
? await callReward.call_with_submission(env, await transformSubmission(validated.submission))
|
|
470
|
-
: await callReward.call(env);
|
|
471
|
-
return handleCallResult(result);
|
|
472
|
-
}
|
|
473
|
-
case "allocation": {
|
|
474
|
-
const callAllocation = new CallAllocation(validated.data);
|
|
475
|
-
const result = validated.submission
|
|
476
|
-
? await callAllocation.call_with_submission(env, await transformSubmission(validated.submission))
|
|
477
|
-
: await callAllocation.call(env);
|
|
478
|
-
return handleCallResult(result);
|
|
479
|
-
}
|
|
480
|
-
case "permission": {
|
|
481
|
-
const callPermission = new CallPermission(validated.data);
|
|
482
|
-
const result = await callPermission.call(env);
|
|
483
|
-
return handleCallResult(result);
|
|
484
|
-
}
|
|
485
|
-
case "guard": {
|
|
486
|
-
const validatedData = validated.data;
|
|
487
|
-
// å¤į root.type === "file" įæ
åĩīŧäģæäģļå čŊŊ Guard åŽäš
|
|
488
|
-
if (validatedData.root?.type === "file") {
|
|
489
|
-
const filePath = resolve(validatedData.root.file_path);
|
|
490
|
-
let fileContent;
|
|
491
|
-
try {
|
|
492
|
-
fileContent = readFileSync(filePath, 'utf-8');
|
|
493
|
-
}
|
|
494
|
-
catch (e) {
|
|
495
|
-
throw new Error(`Failed to read Guard definition file '${validatedData.root.file_path}': ${e.message}`);
|
|
496
|
-
}
|
|
497
|
-
// äŊŋ፠SDK į parseGuardFile įģä¸č§Ŗæīŧæ¯æ JSON å Markdownīŧ
|
|
498
|
-
const parseResult = parseGuardFile(fileContent, validatedData.root.format);
|
|
499
|
-
if (!parseResult.success) {
|
|
500
|
-
const errorMessages = formatGuardParseErrors(parseResult.errors);
|
|
501
|
-
throw new Error(`Guard validation failed for file '${validatedData.root.file_path}':\n\n${errorMessages}`);
|
|
502
|
-
}
|
|
503
|
-
const fileData = parseResult.data;
|
|
504
|
-
// ååšļæäģļæ°æŽå፿ˇæäžįčĻįåæŽĩ
|
|
505
|
-
// ፿ˇæäžįåæŽĩäŧå
įē§éĢäēæäģļå
厚
|
|
506
|
-
validatedData.root = { type: "node", node: fileData.root };
|
|
507
|
-
if (fileData.table !== undefined && validatedData.table === undefined) {
|
|
508
|
-
validatedData.table = fileData.table;
|
|
509
|
-
}
|
|
510
|
-
if (fileData.description !== undefined && validatedData.description === undefined) {
|
|
511
|
-
validatedData.description = fileData.description;
|
|
512
|
-
}
|
|
513
|
-
if (fileData.rely !== undefined && validatedData.rely === undefined) {
|
|
514
|
-
validatedData.rely = fileData.rely;
|
|
515
|
-
}
|
|
516
|
-
if (fileData.namedNew !== undefined && validatedData.namedNew === undefined) {
|
|
517
|
-
validatedData.namedNew = fileData.namedNew;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
// čŊŦæĸ root æ ŧåŧīŧåĻæ root.type === "node"īŧæå node åæŽĩäŊä¸ēåŽé
į root
|
|
521
|
-
// å ä¸ē SDK ææį´æĨį GuardNodeīŧč䏿¯å
čŖ
įģæ { type: "node", node: GuardNode }
|
|
522
|
-
if (validatedData.root && typeof validatedData.root === 'object') {
|
|
523
|
-
const rootObj = validatedData.root;
|
|
524
|
-
if (rootObj.type === 'node' && rootObj.node) {
|
|
525
|
-
validatedData.root = rootObj.node;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
// éĒč¯åŋ
éįåæŽĩ
|
|
529
|
-
if (!validatedData.table || validatedData.table.length === 0) {
|
|
530
|
-
throw new Error("Guard 'table' field is required and cannot be empty");
|
|
531
|
-
}
|
|
532
|
-
if (!validatedData.root) {
|
|
533
|
-
throw new Error("Guard 'root' field is required");
|
|
534
|
-
}
|
|
535
|
-
const callGuard = new CallGuard(validatedData);
|
|
536
|
-
const result = await callGuard.call(env);
|
|
537
|
-
return handleCallResult(result);
|
|
538
|
-
}
|
|
539
|
-
// Personal Operations
|
|
540
|
-
case "personal": {
|
|
541
|
-
// Transform AI-friendly string format to SDK object format
|
|
542
|
-
const transformPersonalData = (data) => {
|
|
543
|
-
const result = { ...data };
|
|
544
|
-
// Transform mark operations
|
|
545
|
-
if (data.mark) {
|
|
546
|
-
const transformAddress = (addr) => {
|
|
547
|
-
if (typeof addr === 'string') {
|
|
548
|
-
return { name_or_address: addr, local_mark_first: true };
|
|
549
|
-
}
|
|
550
|
-
return addr;
|
|
551
|
-
};
|
|
552
|
-
if (data.mark.op === 'add' && data.mark.data) {
|
|
553
|
-
result.mark = {
|
|
554
|
-
...data.mark,
|
|
555
|
-
data: data.mark.data.map((item) => ({
|
|
556
|
-
...item,
|
|
557
|
-
address: transformAddress(item.address)
|
|
558
|
-
}))
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
else if (data.mark.op === 'remove' && data.mark.data) {
|
|
562
|
-
result.mark = {
|
|
563
|
-
...data.mark,
|
|
564
|
-
data: data.mark.data.map((item) => ({
|
|
565
|
-
...item,
|
|
566
|
-
address: transformAddress(item.address)
|
|
567
|
-
}))
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
else if (data.mark.op === 'clear' && data.mark.address) {
|
|
571
|
-
const addr = data.mark.address;
|
|
572
|
-
if (Array.isArray(addr) && addr.every((a) => typeof a === 'string')) {
|
|
573
|
-
result.mark = {
|
|
574
|
-
...data.mark,
|
|
575
|
-
address: {
|
|
576
|
-
entities: addr.map((a) => ({ name_or_address: a, local_mark_first: true }))
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
else if (data.mark.op === 'transfer' && data.mark.to) {
|
|
582
|
-
result.mark = {
|
|
583
|
-
...data.mark,
|
|
584
|
-
to: transformAddress(data.mark.to)
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return result;
|
|
589
|
-
};
|
|
590
|
-
const transformedData = transformPersonalData(validated.data);
|
|
591
|
-
const callPersonal = new CallPersonal(transformedData);
|
|
592
|
-
const result = await callPersonal.call(env);
|
|
593
|
-
return handleCallResult(result);
|
|
594
|
-
}
|
|
595
|
-
case "payment": {
|
|
596
|
-
const callPayment = new CallPayment(validated.data);
|
|
597
|
-
const result = await callPayment.call(env);
|
|
598
|
-
return handleCallResult(result);
|
|
599
|
-
}
|
|
600
|
-
case "demand": {
|
|
601
|
-
const callDemand = new CallDemand(validated.data);
|
|
602
|
-
const result = validated.submission
|
|
603
|
-
? await callDemand.call_with_submission(env, await transformSubmission(validated.submission))
|
|
604
|
-
: await callDemand.call(env);
|
|
605
|
-
return handleCallResult(result);
|
|
606
|
-
}
|
|
607
|
-
case "order": {
|
|
608
|
-
const callOrder = new CallOrder(validated.data);
|
|
609
|
-
const result = validated.submission
|
|
610
|
-
? await callOrder.call_with_submission(env, await transformSubmission(validated.submission))
|
|
611
|
-
: await callOrder.call(env);
|
|
612
|
-
return handleCallResult(result);
|
|
613
|
-
}
|
|
614
|
-
case "gen_passport": {
|
|
615
|
-
const result = await gen_passport(env, validated.guard, validated.info);
|
|
616
|
-
return handleCallResult(result);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
throw new Error(`Unknown on-chain operation type: ${validated.operation_type}`);
|
|
620
|
-
}
|
|
621
|
-
catch (error) {
|
|
622
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
623
|
-
return {
|
|
624
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
625
|
-
structuredContent: {
|
|
626
|
-
message: `Error: ${errorMessage}`,
|
|
627
|
-
result: {
|
|
628
|
-
type: "error",
|
|
629
|
-
error: errorMessage,
|
|
630
|
-
},
|
|
631
|
-
},
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
async function handleAccountOperation(args) {
|
|
636
|
-
try {
|
|
637
|
-
const validated = strictParse(AccountOperationSchema, args, "account_operation input");
|
|
638
|
-
const result = await account_operation(validated);
|
|
639
|
-
return {
|
|
640
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
641
|
-
structuredContent: {
|
|
642
|
-
result: {
|
|
643
|
-
status: "success",
|
|
644
|
-
data: result,
|
|
645
|
-
},
|
|
646
|
-
},
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
catch (error) {
|
|
650
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
651
|
-
return {
|
|
652
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
653
|
-
structuredContent: {
|
|
654
|
-
result: {
|
|
655
|
-
status: "error",
|
|
656
|
-
error: errorMessage,
|
|
657
|
-
},
|
|
658
|
-
},
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
async function handleMarkOperation(args) {
|
|
663
|
-
try {
|
|
664
|
-
const validated = strictParse(LocalMarkOperationSchema, args, "local_mark_operation input");
|
|
665
|
-
const result = await local_mark_operation(validated);
|
|
666
|
-
return {
|
|
667
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
668
|
-
structuredContent: {
|
|
669
|
-
result: {
|
|
670
|
-
status: "success",
|
|
671
|
-
data: result,
|
|
672
|
-
},
|
|
673
|
-
},
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
catch (error) {
|
|
677
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
678
|
-
return {
|
|
679
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
680
|
-
structuredContent: {
|
|
681
|
-
result: {
|
|
682
|
-
status: "error",
|
|
683
|
-
error: errorMessage,
|
|
684
|
-
},
|
|
685
|
-
},
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
async function handleInfoOperation(args) {
|
|
690
|
-
try {
|
|
691
|
-
const validated = strictParse(LocalInfoOperationSchema, args, "local_info_operation input");
|
|
692
|
-
const result = await local_info_operation(validated);
|
|
693
|
-
return {
|
|
694
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
695
|
-
structuredContent: {
|
|
696
|
-
result: {
|
|
697
|
-
status: "success",
|
|
698
|
-
data: result,
|
|
699
|
-
},
|
|
700
|
-
},
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
catch (error) {
|
|
704
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
705
|
-
return {
|
|
706
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
707
|
-
structuredContent: {
|
|
708
|
-
result: {
|
|
709
|
-
status: "error",
|
|
710
|
-
error: errorMessage,
|
|
711
|
-
},
|
|
712
|
-
},
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
async function handleWipOperations(args) {
|
|
717
|
-
const validated = strictParse(WipOperationsSchema, args, "wip_file input");
|
|
718
|
-
let structuredContent;
|
|
719
|
-
switch (validated.type) {
|
|
720
|
-
case "generate": {
|
|
721
|
-
const result = await generate_wip(validated.options, validated.outputPath);
|
|
722
|
-
structuredContent = { result: { type: "generate", filePath: result } };
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
case "verify": {
|
|
726
|
-
const result = await verify_wip(validated.wipFilePath, validated.hash_equal, validated.requireSignature);
|
|
727
|
-
structuredContent = { result: { type: "verify", ...result } };
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
case "sign": {
|
|
731
|
-
const result = await sign_wip(validated.wipFilePath, validated.account, validated.outputPath);
|
|
732
|
-
structuredContent = { result: { type: "sign", filePath: result } };
|
|
733
|
-
break;
|
|
734
|
-
}
|
|
735
|
-
case "wip2html": {
|
|
736
|
-
const result = await wip2html(validated.wipPath, validated.options);
|
|
737
|
-
let output = { type: "wip2html" };
|
|
738
|
-
if (typeof result === "string") {
|
|
739
|
-
output.html = result;
|
|
740
|
-
}
|
|
741
|
-
else if (Array.isArray(result)) {
|
|
742
|
-
output.files = result;
|
|
743
|
-
}
|
|
744
|
-
else {
|
|
745
|
-
output.html = String(result);
|
|
746
|
-
}
|
|
747
|
-
structuredContent = { result: output };
|
|
748
|
-
break;
|
|
749
|
-
}
|
|
750
|
-
default:
|
|
751
|
-
throw new Error("Unknown WIP operation type");
|
|
752
|
-
}
|
|
753
|
-
return {
|
|
754
|
-
content: [{ type: "text", text: JSON.stringify(structuredContent) }],
|
|
755
|
-
structuredContent,
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
async function handleWatchQueryOperations(args) {
|
|
759
|
-
const validated = strictParse(WatchQueryOperationsSchema, args, "watch_and_query input");
|
|
760
|
-
let result;
|
|
761
|
-
switch (validated.query_type) {
|
|
762
|
-
case "local_mark_list": {
|
|
763
|
-
const queryResult = await query_local_mark_list(validated.filter || {});
|
|
764
|
-
result = { query_type: "local_mark_list", result: queryResult };
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
case "account_list": {
|
|
768
|
-
const queryResult = await query_account_list(validated.filter);
|
|
769
|
-
result = { query_type: "account_list", result: queryResult };
|
|
770
|
-
break;
|
|
771
|
-
}
|
|
772
|
-
case "local_info_list": {
|
|
773
|
-
const queryResult = await query_local_info_list(validated.filter);
|
|
774
|
-
result = { query_type: "local_info_list", result: queryResult };
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
case "token_list": {
|
|
778
|
-
const queryResult = await query_local_token_list(validated.filter || {});
|
|
779
|
-
result = { query_type: "token_list", result: queryResult };
|
|
780
|
-
break;
|
|
781
|
-
}
|
|
782
|
-
case "account_balance": {
|
|
783
|
-
const queryResult = await query_account({ name_or_address: validated.name_or_address, token_type: validated.token_type, balance: true });
|
|
784
|
-
result = { query_type: "account_balance", result: queryResult };
|
|
785
|
-
break;
|
|
786
|
-
}
|
|
787
|
-
case "onchain_personal_profile": {
|
|
788
|
-
const queryResult = await query_personal({ account: validated.account });
|
|
789
|
-
result = { query_type: "onchain_personal_profile", result: queryResult };
|
|
790
|
-
break;
|
|
791
|
-
}
|
|
792
|
-
case "onchain_objects": {
|
|
793
|
-
const queryResult = await query_objects({ objects: validated.objects });
|
|
794
|
-
// ä¸ē Guard å¯ščąĄæˇģå æä줿 蝴æ
|
|
795
|
-
if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
|
|
796
|
-
queryResult.objects = queryResult.objects.map((obj) => {
|
|
797
|
-
if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
|
|
798
|
-
try {
|
|
799
|
-
const nodeComments = generateNodeComments(obj.data.root);
|
|
800
|
-
return {
|
|
801
|
-
...obj,
|
|
802
|
-
_guard_node_comments: nodeComments
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
catch (e) {
|
|
806
|
-
return obj;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
return obj;
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
result = { query_type: "onchain_objects", result: queryResult };
|
|
813
|
-
break;
|
|
814
|
-
}
|
|
815
|
-
case "onchain_table": {
|
|
816
|
-
const queryResult = await query_table({ parent: validated.parent, object_type: validated.object_type });
|
|
817
|
-
result = { query_type: "onchain_table", result: queryResult };
|
|
818
|
-
break;
|
|
819
|
-
}
|
|
820
|
-
case "onchain_table_item_repository_data": {
|
|
821
|
-
const queryResult = await queryTableItem_RepositoryData({ parent: validated.parent, name: validated.name, entity: validated.entity });
|
|
822
|
-
result = { query_type: "onchain_table_item_repository_data", result: queryResult };
|
|
823
|
-
break;
|
|
824
|
-
}
|
|
825
|
-
case "onchain_table_item_permission_perm": {
|
|
826
|
-
const queryResult = await queryTableItem_PermissionPerm({ parent: validated.parent, address: validated.address });
|
|
827
|
-
result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
|
|
828
|
-
break;
|
|
829
|
-
}
|
|
830
|
-
case "onchain_table_item_reward_record": {
|
|
831
|
-
const queryResult = await queryTableItem_RewardRecord({ parent: validated.parent, address: validated.address });
|
|
832
|
-
result = { query_type: "onchain_table_item_reward_record", result: queryResult };
|
|
833
|
-
break;
|
|
834
|
-
}
|
|
835
|
-
case "onchain_table_item_demand_presenter": {
|
|
836
|
-
const queryResult = await queryTableItem_DemandPresenter({ parent: validated.parent, address: validated.address });
|
|
837
|
-
result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
|
|
838
|
-
break;
|
|
839
|
-
}
|
|
840
|
-
case "onchain_table_item_treasury_history": {
|
|
841
|
-
const queryResult = await queryTableItem_TreasuryHistory({ parent: validated.parent, address: validated.address });
|
|
842
|
-
result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
|
|
843
|
-
break;
|
|
844
|
-
}
|
|
845
|
-
case "onchain_table_item_machine_node": {
|
|
846
|
-
const queryResult = await queryTableItem_MachineNode({ parent: validated.parent, key: validated.key });
|
|
847
|
-
result = { query_type: "onchain_table_item_machine_node", result: queryResult };
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
850
|
-
case "onchain_table_item_progress_history": {
|
|
851
|
-
const queryResult = await queryTableItem_ProgressHistory({ parent: validated.parent, u64: validated.u64 });
|
|
852
|
-
result = { query_type: "onchain_table_item_progress_history", result: queryResult };
|
|
853
|
-
break;
|
|
854
|
-
}
|
|
855
|
-
case "onchain_table_item_address_mark": {
|
|
856
|
-
const queryResult = await queryTableItem_AddressMark({ parent: validated.parent, address: validated.address });
|
|
857
|
-
result = { query_type: "onchain_table_item_address_mark", result: queryResult };
|
|
858
|
-
break;
|
|
859
|
-
}
|
|
860
|
-
case "onchain_table_item_entity_registrar": {
|
|
861
|
-
const queryResult = await queryTableItem_EntityRegistrar({ address: validated.address });
|
|
862
|
-
result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
|
|
863
|
-
break;
|
|
864
|
-
}
|
|
865
|
-
case "onchain_table_item_entity_linker": {
|
|
866
|
-
const queryResult = await queryTableItem_EntityLinker({ address: validated.address });
|
|
867
|
-
result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
|
|
868
|
-
break;
|
|
869
|
-
}
|
|
870
|
-
case "onchain_received": {
|
|
871
|
-
const queryResult = await query_received({ object: validated.object, all_type: validated.all_type });
|
|
872
|
-
result = { query_type: "onchain_received", result: queryResult };
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
default:
|
|
876
|
-
throw new Error(`Unknown watch query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "onchain_personal_profile", "onchain_objects", "onchain_table", "onchain_table_item_repository_data", "onchain_table_item_permission_perm", "onchain_table_item_reward_record", "onchain_table_item_demand_presenter", "onchain_table_item_treasury_history", "onchain_table_item_machine_node", "onchain_table_item_progress_history", "onchain_table_item_address_mark", "onchain_table_item_entity_registrar", "onchain_table_item_entity_linker", "onchain_received"`);
|
|
877
|
-
}
|
|
878
|
-
return {
|
|
879
|
-
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
880
|
-
structuredContent: { result },
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
async function handleWowokInfo(args) {
|
|
884
|
-
const validated = strictParse(ProtocolInfoQuerySchema, args, "wowok_buildin_info input");
|
|
885
|
-
const queryResult = await queryProtocolInfo(validated);
|
|
886
|
-
return {
|
|
887
|
-
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
888
|
-
structuredContent: { result: queryResult },
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
async function handleOnchainEvents(args) {
|
|
892
|
-
const validated = strictParse(OnchainEventsInputSchema, args, "onchain_events input");
|
|
893
|
-
const queryResult = await query_events({
|
|
894
|
-
type: validated.type,
|
|
895
|
-
cursor: validated.cursor ?? null,
|
|
896
|
-
limit: validated.limit ?? null,
|
|
897
|
-
order: validated.order ?? null,
|
|
898
|
-
no_cache: validated.no_cache,
|
|
899
|
-
network: validated.network,
|
|
900
|
-
});
|
|
901
|
-
return {
|
|
902
|
-
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
903
|
-
structuredContent: { result: queryResult },
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
// Helper function to normalize AccountOrMark_Address from union type (string | object) to object
|
|
907
|
-
function normalizeAccountOrMark(input) {
|
|
908
|
-
if (typeof input === 'string') {
|
|
909
|
-
return { name_or_address: input, local_mark_first: true };
|
|
910
|
-
}
|
|
911
|
-
return input;
|
|
912
|
-
}
|
|
913
|
-
// Helper function to normalize ManyAccountOrMark_Address from union type (string[] | object) to object
|
|
914
|
-
function normalizeManyAccountOrMark(input) {
|
|
915
|
-
if (Array.isArray(input)) {
|
|
916
|
-
return {
|
|
917
|
-
entities: input.map(item => typeof item === 'string' ? { name_or_address: item, local_mark_first: true } : item),
|
|
918
|
-
check_all_founded: true
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
return input;
|
|
922
|
-
}
|
|
923
|
-
async function handleMessengerOperation(args) {
|
|
924
|
-
const validated = strictParse(MessengerOperationInputSchema, args, "messenger_operation input");
|
|
925
|
-
let result;
|
|
926
|
-
switch (validated.operation) {
|
|
927
|
-
case "watch_conversations": {
|
|
928
|
-
const conversations = await watch_conversations(validated.filter);
|
|
929
|
-
result = { operation: "watch_conversations", result: conversations };
|
|
930
|
-
break;
|
|
931
|
-
}
|
|
932
|
-
case "send_message": {
|
|
933
|
-
const sendResult = await send_message(validated.from, normalizeAccountOrMark(validated.to), validated.content, validated.options);
|
|
934
|
-
// Filter out leafHash from merkleData to match schema
|
|
935
|
-
const filteredResult = {
|
|
936
|
-
...sendResult,
|
|
937
|
-
merkleData: sendResult.merkleData ? {
|
|
938
|
-
leafIndex: sendResult.merkleData.leafIndex,
|
|
939
|
-
prevRoot: sendResult.merkleData.prevRoot,
|
|
940
|
-
newRoot: sendResult.merkleData.newRoot,
|
|
941
|
-
serverSignature: sendResult.merkleData.serverSignature,
|
|
942
|
-
serverTimestamp: sendResult.merkleData.serverTimestamp,
|
|
943
|
-
serverPublicKey: sendResult.merkleData.serverPublicKey,
|
|
944
|
-
} : undefined,
|
|
945
|
-
};
|
|
946
|
-
result = { operation: "send_message", result: filteredResult };
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
case "send_file": {
|
|
950
|
-
const sendResult = await send_file(validated.from, normalizeAccountOrMark(validated.to), validated.filePath, validated.options);
|
|
951
|
-
// Filter out leafHash from merkleData to match schema
|
|
952
|
-
const filteredResult = {
|
|
953
|
-
...sendResult,
|
|
954
|
-
merkleData: sendResult.merkleData ? {
|
|
955
|
-
leafIndex: sendResult.merkleData.leafIndex,
|
|
956
|
-
prevRoot: sendResult.merkleData.prevRoot,
|
|
957
|
-
newRoot: sendResult.merkleData.newRoot,
|
|
958
|
-
serverSignature: sendResult.merkleData.serverSignature,
|
|
959
|
-
serverTimestamp: sendResult.merkleData.serverTimestamp,
|
|
960
|
-
serverPublicKey: sendResult.merkleData.serverPublicKey,
|
|
961
|
-
} : undefined,
|
|
962
|
-
};
|
|
963
|
-
result = { operation: "send_file", result: filteredResult };
|
|
964
|
-
break;
|
|
965
|
-
}
|
|
966
|
-
case "watch_messages": {
|
|
967
|
-
// Normalize peerAddress in filter if it exists
|
|
968
|
-
const filter = validated.filter ? {
|
|
969
|
-
...validated.filter,
|
|
970
|
-
peerAddress: validated.filter.peerAddress ? normalizeAccountOrMark(validated.filter.peerAddress) : undefined
|
|
971
|
-
} : undefined;
|
|
972
|
-
const messages = await watch_messages(filter);
|
|
973
|
-
result = { operation: "watch_messages", result: messages };
|
|
974
|
-
break;
|
|
975
|
-
}
|
|
976
|
-
case "extract_zip_messages": {
|
|
977
|
-
const extractedPaths = await extract_zip_messages(validated.account, validated.messages, validated.outputDir);
|
|
978
|
-
result = { operation: "extract_zip_messages", result: extractedPaths };
|
|
979
|
-
break;
|
|
980
|
-
}
|
|
981
|
-
case "generate_wts": {
|
|
982
|
-
// Normalize peerAccount in params if it exists
|
|
983
|
-
const params = validated.params ? {
|
|
984
|
-
...validated.params,
|
|
985
|
-
peerAccount: normalizeAccountOrMark(validated.params.peerAccount)
|
|
986
|
-
} : undefined;
|
|
987
|
-
const wtsResult = await generate_wts(params);
|
|
988
|
-
result = { operation: "generate_wts", result: wtsResult };
|
|
989
|
-
break;
|
|
990
|
-
}
|
|
991
|
-
case "verify_wts": {
|
|
992
|
-
const verifyResult = await verify_wts(validated.wtsFilePath);
|
|
993
|
-
result = { operation: "verify_wts", result: verifyResult };
|
|
994
|
-
break;
|
|
995
|
-
}
|
|
996
|
-
case "sign_wts": {
|
|
997
|
-
const signedPath = await sign_wts(validated.wtsFilePath, validated.account, validated.outputPath);
|
|
998
|
-
result = { operation: "sign_wts", result: signedPath };
|
|
999
|
-
break;
|
|
1000
|
-
}
|
|
1001
|
-
case "wts2html": {
|
|
1002
|
-
const htmlResult = await wts2html(validated.wtsPath, validated.options);
|
|
1003
|
-
result = { operation: "wts2html", result: htmlResult };
|
|
1004
|
-
break;
|
|
1005
|
-
}
|
|
1006
|
-
case "proof_message": {
|
|
1007
|
-
const proofResult = await proof_message(validated.account, validated.messageId, validated.network);
|
|
1008
|
-
result = { operation: "proof_message", result: proofResult };
|
|
1009
|
-
break;
|
|
1010
|
-
}
|
|
1011
|
-
case "blacklist": {
|
|
1012
|
-
// Normalize users if they exist (for add, remove, exist operations)
|
|
1013
|
-
const blacklistParams = {
|
|
1014
|
-
account: validated.account,
|
|
1015
|
-
op: validated.blacklist.op
|
|
1016
|
-
};
|
|
1017
|
-
if ('users' in validated.blacklist) {
|
|
1018
|
-
blacklistParams.users = normalizeManyAccountOrMark(validated.blacklist.users);
|
|
1019
|
-
}
|
|
1020
|
-
const blacklistResult = await blacklist(blacklistParams);
|
|
1021
|
-
result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
|
|
1022
|
-
break;
|
|
1023
|
-
}
|
|
1024
|
-
case "friendslist": {
|
|
1025
|
-
// Normalize users if they exist (for add, remove, exist operations)
|
|
1026
|
-
const friendslistParams = {
|
|
1027
|
-
account: validated.account,
|
|
1028
|
-
op: validated.friendslist.op
|
|
1029
|
-
};
|
|
1030
|
-
if ('users' in validated.friendslist) {
|
|
1031
|
-
friendslistParams.users = normalizeManyAccountOrMark(validated.friendslist.users);
|
|
1032
|
-
}
|
|
1033
|
-
const friendslistResult = await friendslist(friendslistParams);
|
|
1034
|
-
result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
|
|
1035
|
-
break;
|
|
1036
|
-
}
|
|
1037
|
-
case "guardlist": {
|
|
1038
|
-
const guardlistResult = await guardlist({
|
|
1039
|
-
account: validated.account,
|
|
1040
|
-
...validated.guardlist
|
|
1041
|
-
});
|
|
1042
|
-
result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
|
|
1043
|
-
break;
|
|
1044
|
-
}
|
|
1045
|
-
case "settings": {
|
|
1046
|
-
const settingsResult = await settings({
|
|
1047
|
-
account: validated.account,
|
|
1048
|
-
...validated.settings
|
|
1049
|
-
});
|
|
1050
|
-
result = { operation: "settings", op: validated.settings.op, result: settingsResult.result };
|
|
1051
|
-
break;
|
|
1052
|
-
}
|
|
1053
|
-
case "mark_messages_as_viewed": {
|
|
1054
|
-
const markedCount = await mark_messages_as_viewed(validated.messageIds, validated.account);
|
|
1055
|
-
result = { operation: "mark_messages_as_viewed", result: markedCount };
|
|
1056
|
-
break;
|
|
1057
|
-
}
|
|
1058
|
-
case "mark_conversation_as_viewed": {
|
|
1059
|
-
const markedCount = await mark_conversation_as_viewed(normalizeAccountOrMark(validated.peerAddress), validated.account);
|
|
1060
|
-
result = { operation: "mark_conversation_as_viewed", result: markedCount };
|
|
1061
|
-
break;
|
|
1062
|
-
}
|
|
1063
|
-
default:
|
|
1064
|
-
throw new Error(`Unknown messenger operation: ${validated.operation}`);
|
|
1065
|
-
}
|
|
1066
|
-
return {
|
|
1067
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
1068
|
-
structuredContent: { result },
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
// ================================================
|
|
1072
|
-
// Guard2File Tool Handler
|
|
1073
|
-
// ================================================
|
|
1074
|
-
async function handleGuard2File(args) {
|
|
1075
|
-
const validated = strictParse(Guard2File_InputSchema, args, "guard2file input");
|
|
1076
|
-
const env = getEnvConfig(validated.env);
|
|
1077
|
-
try {
|
|
1078
|
-
// Call guard2file function from SDK
|
|
1079
|
-
await guard2file(validated.guard, validated.file_path, validated.format || "json", env.network);
|
|
1080
|
-
// Return success result
|
|
1081
|
-
const result = {
|
|
1082
|
-
result: {
|
|
1083
|
-
status: "success",
|
|
1084
|
-
data: {
|
|
1085
|
-
file_path: resolve(validated.file_path),
|
|
1086
|
-
format: validated.format || "json",
|
|
1087
|
-
guard_object: validated.guard,
|
|
1088
|
-
},
|
|
1089
|
-
},
|
|
1090
|
-
};
|
|
1091
|
-
return {
|
|
1092
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
1093
|
-
structuredContent: result,
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
catch (error) {
|
|
1097
|
-
// Return error result
|
|
1098
|
-
const result = {
|
|
1099
|
-
result: {
|
|
1100
|
-
status: "error",
|
|
1101
|
-
error: error.message,
|
|
1102
|
-
},
|
|
1103
|
-
};
|
|
1104
|
-
return {
|
|
1105
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
1106
|
-
structuredContent: result,
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
// ================================================
|
|
1111
|
-
// MachineNode2File Tool Handler
|
|
1112
|
-
// ================================================
|
|
1113
|
-
async function handleMachineNode2File(args) {
|
|
1114
|
-
const validated = strictParse(MachineNode2File_InputSchema, args, "machineNode2file input");
|
|
1115
|
-
const env = getEnvConfig(validated.env);
|
|
1116
|
-
try {
|
|
1117
|
-
// Call machineNode2file function from SDK
|
|
1118
|
-
await machineNode2file(validated.machine, validated.file_path, validated.format || "json", env.network);
|
|
1119
|
-
// Return success result
|
|
1120
|
-
const result = {
|
|
1121
|
-
result: {
|
|
1122
|
-
status: "success",
|
|
1123
|
-
data: {
|
|
1124
|
-
file_path: resolve(validated.file_path),
|
|
1125
|
-
format: validated.format || "json",
|
|
1126
|
-
machine_object: validated.machine,
|
|
1127
|
-
node_count: 0, // SDK function doesn't return node count, but we can add it later
|
|
1128
|
-
},
|
|
1129
|
-
},
|
|
1130
|
-
};
|
|
1131
|
-
return {
|
|
1132
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
1133
|
-
structuredContent: result,
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
catch (error) {
|
|
1137
|
-
// Return error result
|
|
1138
|
-
const result = {
|
|
1139
|
-
result: {
|
|
1140
|
-
status: "error",
|
|
1141
|
-
error: error.message,
|
|
1142
|
-
},
|
|
1143
|
-
};
|
|
1144
|
-
return {
|
|
1145
|
-
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
1146
|
-
structuredContent: result,
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
// ================================================
|
|
1151
|
-
// Schema Query Tool Handler
|
|
1152
|
-
// ================================================
|
|
1153
|
-
// Export Schema Definitions for Tool Schema Query
|
|
1154
|
-
// ================================================
|
|
1155
|
-
export { OnchainOperationsSchema, WipOperationsSchema, WatchQueryOperationsSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, ProtocolInfoQuerySchema, CallOutputSchema, MessengerOperationInputSchema, MessengerOperationOutputSchema };
|
|
1156
|
-
// ================================================
|
|
1157
|
-
// Main Function - Register All Tools
|
|
1158
|
-
// ================================================
|
|
1159
|
-
async function main() {
|
|
1160
|
-
// Unified On-chain Operations Tool (Merged from Merchant and Personal Operations)
|
|
1161
|
-
server.registerTool("onchain_operations", {
|
|
1162
|
-
title: "âī¸ On-chain Operations",
|
|
1163
|
-
description: "On-chain operations for WoWok object: service (marketplace listings), machine (workflow templates), progress (order tracking), repository (on-chain database), arbitration (dispute resolution), contact (IM management), treasury (team funds), reward (incentive pools), allocation (auto-distribution), permission (access control), guard (programmable trust rules), personal (public profile), payment (direct coin transfers), demand (service requests), order (order management), gen_passport (verified credentials).",
|
|
1164
|
-
inputSchema: OnchainOperationsSchema,
|
|
1165
|
-
outputSchema: CallOutputSchema,
|
|
1166
|
-
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
1167
|
-
_meta: createToolMeta("operation", ["service", "machine", "progress", "repository", "arbitration", "contact", "treasury", "reward", "allocation", "permission", "guard", "personal", "payment", "demand", "order", "gen_passport", "on-chain", "blockchain"]),
|
|
1168
|
-
}, handleOnchainOperations);
|
|
1169
|
-
// Account Operation Tool (Local)
|
|
1170
|
-
server.registerTool("account_operation", {
|
|
1171
|
-
title: "đ LOCAL ONLY: Account - Wallet Management",
|
|
1172
|
-
description: "đ 100% LOCAL, NEVER ON-CHAIN đ Manage WoWok accounts locally on device: generate, suspend, resume, faucet-test, operate assets, sign data, etc.",
|
|
1173
|
-
inputSchema: AccountOperationSchema,
|
|
1174
|
-
outputSchema: AccountOperationOutputWrappedSchema,
|
|
1175
|
-
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
1176
|
-
_meta: createToolMeta("operation", ["account", "local", "private", "wallet", "off-chain"]),
|
|
1177
|
-
}, handleAccountOperation);
|
|
1178
|
-
// Local Mark Operation Tool
|
|
1179
|
-
server.registerTool("local_mark_operation", {
|
|
1180
|
-
title: "đ LOCAL ONLY: LocalMark - Address Book Management",
|
|
1181
|
-
description: "100% LOCAL, NEVER ON-CHAIN đ Manage ID names and tags stored ONLY on your local device for easy identification of user address or object IDs by name.",
|
|
1182
|
-
inputSchema: LocalMarkOperationSchema,
|
|
1183
|
-
outputSchema: LocalMarkOperationOutputWrappedSchema,
|
|
1184
|
-
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
1185
|
-
_meta: createToolMeta("operation", ["mark", "local", "private", "address-book", "off-chain"]),
|
|
1186
|
-
}, handleMarkOperation);
|
|
1187
|
-
// Local Info Operation Tool
|
|
1188
|
-
server.registerTool("local_info_operation", {
|
|
1189
|
-
title: "đ LOCAL ONLY: LocalInfo - Private Data Management",
|
|
1190
|
-
description: "100% LOCAL, NEVER ON-CHAIN đ Manage sensitive personal information stored ONLY on your device: delivery addresses, phone numbers, contacts.",
|
|
1191
|
-
inputSchema: LocalInfoOperationSchema,
|
|
1192
|
-
outputSchema: LocalInfoOperationOutputWrappedSchema,
|
|
1193
|
-
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
1194
|
-
_meta: createToolMeta("operation", ["info", "local", "private", "data-management", "off-chain"]),
|
|
1195
|
-
}, handleInfoOperation);
|
|
1196
|
-
// WIP File Operations Tool
|
|
1197
|
-
server.registerTool("wip_file", {
|
|
1198
|
-
title: "đ¤ Witness Information Promise File Operations",
|
|
1199
|
-
description: "generate (create WIP files from markdown and images), verify (integrity check), sign (add signatures), or wip2html (convert to HTML).",
|
|
1200
|
-
inputSchema: WipOperationsSchema,
|
|
1201
|
-
outputSchema: z.object({
|
|
1202
|
-
result: WipOperationOutputSchema,
|
|
1203
|
-
}),
|
|
1204
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
1205
|
-
_meta: createToolMeta("operation", ["wip", "promise", "file-generation", "verification", "signature", "local"]),
|
|
1206
|
-
}, handleWipOperations);
|
|
1207
|
-
// Messenger Operations Tool
|
|
1208
|
-
server.registerTool("messenger_operation", {
|
|
1209
|
-
title: "đŦ Messenger Operations",
|
|
1210
|
-
description: "WoWok encrypted messenger operations: watch conversations (with unread filtering, preview messages), send message, send file, watch messages (with viewed status filtering), extract zip messages, generate WTS, verify WTS, sign WTS, WTS to HTML, proof message on-chain, manage blacklist, friendslist, guardlist, settings, mark messages as viewed, and mark conversation as viewed.",
|
|
1211
|
-
inputSchema: MessengerOperationInputSchema,
|
|
1212
|
-
outputSchema: MessengerOperationOutputSchema,
|
|
1213
|
-
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
1214
|
-
_meta: createToolMeta("operation", ["messenger", "message", "file", "wts", "blacklist", "friendslist", "guardlist", "settings", "proof", "communication"]),
|
|
1215
|
-
}, handleMessengerOperation);
|
|
1216
|
-
// Guard2File Tool - Export Guard to JSON/Markdown file
|
|
1217
|
-
server.registerTool("guard2file", {
|
|
1218
|
-
title: "đ Guard to File - Export Guard Definition",
|
|
1219
|
-
description: "Export a Guard object's definition from the blockchain to a local JSON or Markdown file for editing and creating new Guard objects. Note: To query on-chain object information, use the 'query_toolkit' tool instead.",
|
|
1220
|
-
inputSchema: Guard2File_InputSchema,
|
|
1221
|
-
outputSchema: Guard2File_OutputWrappedSchema,
|
|
1222
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1223
|
-
_meta: createToolMeta("generate file", ["guard", "export", "file", "json", "markdown", "on-chain"]),
|
|
1224
|
-
}, handleGuard2File);
|
|
1225
|
-
// MachineNode2File Tool - Export Machine nodes to JSON/Markdown file
|
|
1226
|
-
server.registerTool("machineNode2file", {
|
|
1227
|
-
title: "âī¸ Machine Node to File - Export Machine Node Definition",
|
|
1228
|
-
description: "Export a Machine object's node definition from the blockchain to a local JSON or Markdown file for editing and creating new Machine objects. Note: To query on-chain object information, use the 'query_toolkit' tool instead.",
|
|
1229
|
-
inputSchema: MachineNode2File_InputSchema,
|
|
1230
|
-
outputSchema: MachineNode2File_OutputWrappedSchema,
|
|
1231
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1232
|
-
_meta: createToolMeta("generate file", ["machine", "export", "file", "json", "markdown", "on-chain", "workflow"]),
|
|
1233
|
-
}, handleMachineNode2File);
|
|
1234
|
-
server.registerTool("query_toolkit", {
|
|
1235
|
-
title: "đ Data Query Toolkit",
|
|
1236
|
-
description: "WOWOK data query toolkit: Query local naming info (accounts, names, Object IDs), and query on-chain WOWOK objects, table items, events, received tokens, user profile, etc.",
|
|
1237
|
-
inputSchema: WatchQueryOperationsSchema,
|
|
1238
|
-
outputSchema: WatchQueryOperationsResultSchema,
|
|
1239
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1240
|
-
_meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tables", "tokens", "balance", "profile"]),
|
|
1241
|
-
}, handleWatchQueryOperations);
|
|
1242
|
-
server.registerTool("onchain_events", {
|
|
1243
|
-
title: "đ
Watch On-chain Events",
|
|
1244
|
-
description: "Watch on-chain WOWOK events by type. Supports arbitration events, new order events, progress events, demand presentation events, demand feedback events, and new entity registration events. Use pagination cursor for fetching large result sets.",
|
|
1245
|
-
inputSchema: OnchainEventsInputSchema,
|
|
1246
|
-
outputSchema: OnchainEventsResultSchema,
|
|
1247
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1248
|
-
_meta: createToolMeta("watch events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
|
|
1249
|
-
}, handleOnchainEvents);
|
|
1250
|
-
server.registerTool("wowok_buildin_info", {
|
|
1251
|
-
title: "âšī¸ WoWok Build-in Information",
|
|
1252
|
-
description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'guard instructions', 'current network', or 'value types'.",
|
|
1253
|
-
inputSchema: ProtocolInfoQuerySchema,
|
|
1254
|
-
outputSchema: ProtocolInfoResultSchema,
|
|
1255
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1256
|
-
_meta: createToolMeta("WoWok info", ["build-in", "constants", "permissions", "guard", "network", "value-types"]),
|
|
1257
|
-
}, handleWowokInfo);
|
|
1258
|
-
// Documents and Learn Tool - Provide documentation URL for users and AI
|
|
1259
|
-
server.registerTool("documents_and_learn", {
|
|
1260
|
-
title: "đ Documents and Learn",
|
|
1261
|
-
description: "Access WoWok documentation and learning resources. Provides official documentation URL for users and AI to get more information about WoWok protocol, components, and usage.",
|
|
1262
|
-
inputSchema: z.object({
|
|
1263
|
-
topic: z.string().optional().describe("Optional topic to search for in documentation (e.g., 'guard', 'service', 'messenger', 'stage-01-introduction')"),
|
|
1264
|
-
}),
|
|
1265
|
-
outputSchema: z.object({
|
|
1266
|
-
documentation_url: z.string().describe("Official WoWok documentation URL on GitHub"),
|
|
1267
|
-
topic: z.string().optional().describe("Requested topic if specified"),
|
|
1268
|
-
original_topic: z.string().optional().describe("Original topic input by user (before normalization)"),
|
|
1269
|
-
message: z.string().describe("Welcome message with documentation information. Always included in response."),
|
|
1270
|
-
}),
|
|
1271
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1272
|
-
_meta: createToolMeta("documentation", ["docs", "learn", "tutorial", "guide", "help", "reference"]),
|
|
1273
|
-
}, async (args) => {
|
|
1274
|
-
const GITHUB_BASE_URL = "https://github.com/wowok-ai/docs/blob/main/docs";
|
|
1275
|
-
if (!args.topic) {
|
|
1276
|
-
// No topic specified, return base documentation URL
|
|
1277
|
-
const url = GITHUB_BASE_URL;
|
|
1278
|
-
const message = `Welcome to WoWok Documentation! Access comprehensive guides, tutorials, and API references at: ${url}`;
|
|
1279
|
-
return {
|
|
1280
|
-
content: [
|
|
1281
|
-
{
|
|
1282
|
-
type: "text",
|
|
1283
|
-
text: message,
|
|
1284
|
-
},
|
|
1285
|
-
],
|
|
1286
|
-
structuredContent: {
|
|
1287
|
-
documentation_url: url,
|
|
1288
|
-
message: message,
|
|
1289
|
-
},
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
// Topic specified, normalize to lowercase for case-insensitive matching
|
|
1293
|
-
const normalizedTopic = args.topic.toLowerCase().trim();
|
|
1294
|
-
const url = `${GITHUB_BASE_URL}/${normalizedTopic}.md`;
|
|
1295
|
-
const message = `Documentation for "${normalizedTopic}"\nGitHub URL: ${url}`;
|
|
1296
|
-
return {
|
|
1297
|
-
content: [
|
|
1298
|
-
{
|
|
1299
|
-
type: "text",
|
|
1300
|
-
text: message,
|
|
1301
|
-
},
|
|
1302
|
-
],
|
|
1303
|
-
structuredContent: {
|
|
1304
|
-
documentation_url: url,
|
|
1305
|
-
topic: normalizedTopic,
|
|
1306
|
-
original_topic: args.topic,
|
|
1307
|
-
message: message,
|
|
1308
|
-
},
|
|
1309
|
-
};
|
|
1310
|
-
});
|
|
1311
|
-
// Connect to transport
|
|
1312
|
-
const transport = new StdioServerTransport();
|
|
1313
|
-
await server.connect(transport);
|
|
1314
|
-
// Cleanup on exit
|
|
1315
|
-
process.on("SIGINT", async () => {
|
|
1316
|
-
await server.close();
|
|
1317
|
-
process.exit(0);
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
main().catch(console.error);
|
|
2
|
+
import{z}from'zod';import{McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{readFileSync}from'fs';import{resolve}from'path';const packageJson=JSON['parse'](readFileSync(new URL('../package.json',import.meta.url),'utf-8'));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 a0a,MessengerOperationInputSchema}from'./schema/index.js';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,mark_messages_as_viewed,mark_conversation_as_viewed,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';const SERVER_DESCRIPTION='WoWok\x20MCP\x20Server\x20-\x20Making\x20It\x20Easy\x20for\x20AI\x20Agents\x20to\x20Communicate,\x20Collaborate,\x20Trade,\x20and\x20Trust.\x0a\x0a##\x20Token\x20System\x20Overview\x0a\x0a###\x20Default\x20Platform\x20Token:\x20WOW\x0a-\x20Token\x20Type:\x200x2::wow::WOW\x0a-\x20Precision:\x201_000_000_000\x20(9\x20decimal\x20places)\x0a-\x20This\x20is\x20the\x20default\x20token\x20for\x20all\x20operations\x20unless\x20specified\x20otherwise\x0a\x0a###\x20Multi-Token\x20Support\x0aThe\x20platform\x20supports\x20ANY\x20token\x20(e.g.,\x20USDT,\x20USDC,\x20custom\x20tokens).\x20To\x20use\x20non-WOW\x20tokens:\x0a1.\x20Use\x20query_toolkit\x20with\x20query_type=\x27token_list\x27\x20to\x20query\x20available\x20tokens\x20and\x20their\x20precision\x20info\x0a2.\x20Use\x20the\x20token\x27s\x20full\x20type\x20string\x20(e.g.,\x20\x270x2::usdt::USDT\x27)\x20in\x20token_type\x20parameter\x0a3.\x20Each\x20token\x20has\x20its\x20own\x20precision\x20-\x20always\x20verify\x20before\x20operations\x0a\x0a###\x20Token\x20Precision\x20Handling\x0aDifferent\x20tokens\x20have\x20different\x20precisions.\x20ALWAYS\x20query\x20to\x20verify:\x0a-\x20WOW\x20(default):\x201_000_000_000\x20(9\x20decimals)\x0a-\x20Other\x20tokens:\x20Use\x20query_toolkit\x20with\x20query_type=\x27token_list\x27\x20to\x20get\x20actual\x20precision\x0a-\x20Never\x20assume\x20a\x20token\x27s\x20decimal\x20places\x20-\x20always\x20query\x20first\x0a\x0a##\x20CRITICAL:\x20Token\x20Amount\x20Handling\x0a\x0a###\x20Amount\x20Input\x20Rules\x0a1.\x20WITH\x20currency\x20unit\x20(e.g.,\x20\x272WOW\x27,\x20\x2710.5WOW\x27,\x20\x27100USDT\x27):\x0a\x20\x20\x20-\x20Auto-converted\x20using\x20token\x27s\x20precision:\x202WOW\x20->\x202_000_000_000\x0a\x20\x20\x20-\x20Use\x20for:\x20All\x20on-chain\x20token\x20operations\x0a\x20\x20\x20-\x20MUST\x20match\x20the\x20token_type\x20parameter\x0a\x0a2.\x20WITHOUT\x20currency\x20unit\x20(e.g.,\x20\x272\x27,\x20\x27100\x27):\x0a\x20\x20\x20-\x20Used\x20as-is:\x202\x20->\x202\x0a\x20\x20\x20-\x20Use\x20for:\x20Regular\x20numeric\x20parameters\x20(counts,\x20indices,\x20etc.)\x0a\x0a###\x20Multi-Token\x20Operation\x20Examples\x0a-\x20Create\x20USDT-priced\x20Service:\x20token_type=\x270x2::usdt::USDT\x27,\x20amount=\x27100USDT\x27\x0a-\x20Allocate\x20USDC\x20rewards:\x20token_type=\x270x2::usdc::USDC\x27,\x20amount=\x27500USDC\x27\x0a-\x20WOW\x20remains\x20default:\x20omit\x20token_type\x20or\x20use\x20\x270x2::wow::WOW\x27\x0a\x0a###\x20Security\x20Warning\x0aToken\x20amounts\x20are\x20HIGHLY\x20SENSITIVE.\x20Always:\x0a-\x20Confirm\x20user\x27s\x20intent\x20before\x20executing\x20transfers\x0a-\x20Verify\x20token\x20type\x20and\x20amount\x20format\x20(with/without\x20unit)\x0a-\x20Query\x20token\x20precision\x20if\x20unsure\x0a-\x20Double-check\x20large\x20amount\x20transactions\x0a-\x20Never\x20assume\x20decimal\x20places\x20-\x20use\x20explicit\x20token\x20unit\x0a\x0a##\x20Tool\x20Selection\x20Guide\x0a\x0a|\x20User\x20Intent\x20|\x20Correct\x20Tool\x20|\x20Wrong\x20Tool\x20(Avoid)\x20|\x0a|------------|--------------|-------------------|\x0a|\x20Create\x20service\x20listing\x20|\x20onchain_operations\x20(service)\x20|\x20query_toolkit\x20|\x0a|\x20Send\x20coins\x20to\x20address\x20|\x20onchain_operations\x20(payment)\x20|\x20account_operation\x20|\x0a|\x20Check\x20my\x20balance\x20|\x20query_toolkit\x20(account_balance)\x20|\x20onchain_operations\x20|\x0a|\x20Manage\x20local\x20wallet\x20|\x20account_operation\x20|\x20onchain_operations\x20|\x0a|\x20Export\x20Guard\x20for\x20edit\x20|\x20guard2file\x20|\x20query_toolkit\x20|\x0a|\x20Send/Watch\x20encrypted\x20message\x20|\x20messenger_operation\x20|\x20onchain_operations\x20|\x0a|\x20Create\x20workflow\x20template\x20|\x20onchain_operations\x20(machine)\x20|\x20wip_file\x20|\x0a|\x20Store\x20my\x20phone\x20number\x20|\x20local_info_operation\x20|\x20onchain_operations\x20|\x0a|\x20Buy\x20service\x20(create\x20order)\x20|\x20onchain_operations\x20(order)\x20|\x20onchain_operations\x20(service)\x20|\x0a|\x20Manage\x20my\x20orders\x20|\x20onchain_operations\x20(order)\x20|\x20query_toolkit\x20|\x0a|\x20Apply\x20for\x20arbitration\x20|\x20onchain_operations\x20(order)\x20|\x20onchain_operations\x20(arbitration)\x20|\x0a|\x20Create\x20reward\x20pool\x20for\x20marketing\x20|\x20onchain_operations\x20(reward)\x20|\x20onchain_operations\x20(treasury)\x20|\x0a|\x20Claim\x20rewards\x20from\x20pool\x20|\x20onchain_operations\x20(reward)\x20|\x20query_toolkit\x20|\x0a|\x20Create\x20fund\x20allocation\x20plan\x20|\x20onchain_operations\x20(allocation)\x20|\x20onchain_operations\x20(treasury)\x20|\x0a|\x20Execute\x20fund\x20distribution\x20|\x20onchain_operations\x20(allocation)\x20|\x20onchain_operations\x20(payment)\x20|\x0a|\x20Post\x20service\x20demand\x20with\x20reward\x20|\x20onchain_operations\x20(demand)\x20|\x20onchain_operations\x20(service)\x20|\x0a|\x20Submit\x20solution\x20for\x20demand\x20|\x20onchain_operations\x20(demand)\x20|\x20onchain_operations\x20(order)\x20|\x0a|\x20Create\x20team\x20treasury\x20|\x20onchain_operations\x20(treasury)\x20|\x20onchain_operations\x20(allocation)\x20|\x0a|\x20Deposit/Withdraw\x20from\x20treasury\x20|\x20onchain_operations\x20(treasury)\x20|\x20onchain_operations\x20(payment)\x20|\x0a|\x20Create\x20access\x20control\x20rules\x20|\x20onchain_operations\x20(permission)\x20|\x20onchain_operations\x20(guard)\x20|\x0a|\x20Create\x20validation\x20rules\x20(Guard)\x20|\x20onchain_operations\x20(guard)\x20|\x20onchain_operations\x20(permission)\x20|\x0a|\x20Export\x20Guard\x20for\x20editing\x20|\x20guard2file\x20|\x20query_toolkit\x20|\x0a|\x20Export\x20Machine\x20nodes\x20for\x20editing\x20|\x20machineNode2file\x20|\x20query_toolkit\x20|\x0a|\x20Query\x20token\x20list\x20and\x20precision\x20|\x20query_toolkit\x20(token_list)\x20|\x20wowok_buildin_info\x20|\x0a|\x20Watch\x20on-chain\x20events\x20|\x20onchain_events\x20|\x20query_toolkit\x20|\x0a|\x20Generate\x20WIP\x20promise\x20file\x20|\x20wip_file\x20(generate)\x20|\x20messenger_operation\x20|\x0a|\x20Sign\x20WIP\x20file\x20|\x20wip_file\x20(sign)\x20|\x20account_operation\x20(signData)\x20|\x0a|\x20Verify\x20WIP\x20file\x20integrity\x20|\x20wip_file\x20(verify)\x20|\x20query_toolkit\x20|\x0a|\x20Send\x20encrypted\x20file\x20via\x20messenger\x20|\x20messenger_operation\x20(send_file)\x20|\x20wip_file\x20|\x0a|\x20Generate\x20witness\x20timestamp\x20(WTS)\x20|\x20messenger_operation\x20(generate_wts)\x20|\x20wip_file\x20|\x0a|\x20Query\x20protocol\x20constants\x20|\x20wowok_buildin_info\x20|\x20query_toolkit\x20|\x0a|\x20Get\x20documentation\x20URL\x20|\x20documents_and_learn\x20|\x20wowok_buildin_info\x20|\x0a\x0a##\x20Local\x20vs\x20On-chain\x20Operations\x0a\x0a###\x20LOCAL\x20ONLY\x20(Never\x20touch\x20blockchain):\x0a-\x20account_operation\x0a-\x20local_mark_operation\x0a-\x20local_info_operation\x0a\x0a###\x20ON-CHAIN\x20(Blockchain\x20transactions):\x0a-\x20onchain_operations\x0a-\x20messenger_operation\x20(some\x20operations)\x0a-\x20wip_file\x20(sign\x20operation)\x0a\x0a###\x20QUERY\x20(Read-only):\x0a-\x20query_toolkit\x0a-\x20onchain_events\x0a-\x20wowok_buildin_info\x0a-\x20documents_and_learn\x0a-\x20guard2file\x0a-\x20machineNode2file\x0a',server=new McpServer(createServerConfig(packageJson,SERVER_DESCRIPTION),createCapabilitiesConfig());function convertAmountType(a){if(typeof a==='number')return a;const b=a['toUpperCase']();if(b==='GUARDU64IDENTIFIER'||b==='GUARD_U64_IDENTIFIER')return AmountType['GuardU64Identifier'];if(b==='FIXED')return AmountType['Fixed'];return AmountType['Fixed'];}function transformRewardData(a){if(!a)return a;const b={...a};return b['guard_add']&&Array['isArray'](b['guard_add'])&&(b['guard_add']=b['guard_add']['map'](c=>{if(c['amount']&&typeof c['amount']['type']==='string')return{...c,'amount':{...c['amount'],'type':convertAmountType(c['amount']['type'])}};return c;})),b;}const OnchainOperationsSchema=z['discriminatedUnion']('operation_type',[z['object']({'operation_type':z['literal']('service'),'data':CallService_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đĒ\x20Service\x20Object:\x20Create\x20and\x20manage\x20product/service\x20listings\x20with\x20transparent\x20promises,\x20bind\x20workflow\x20templates\x20to\x20order\x20processing,\x20set\x20pricing,\x20issue\x20discount\x20coupons\x20to\x20customers,\x20and\x20establish\x20quality\x20standards,\x20etc..'),z['object']({'operation_type':z['literal']('machine'),'data':CallMachine_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('âī¸\x20Machine\x20Object:\x20Design\x20and\x20deploy\x20automated\x20workflow\x20templates\x20(Machines)\x20that\x20define\x20how\x20services\x20are\x20delivered,\x20etc..'),z['object']({'operation_type':z['literal']('progress'),'data':CallProgress_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đ\x20Progress\x20Object:\x20Track\x20and\x20manage\x20active\x20workflows\x20in\x20real-time.'),z['object']({'operation_type':z['literal']('repository'),'data':CallRepository_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đĻ\x20Repository\x20Object:\x20Read/write\x20database\x20with\x20consensus\x20field\x20+\x20address\x20as\x20key,\x20strongly-typed\x20data\x20as\x20value.'),z['object']({'operation_type':z['literal']('arbitration'),'data':CallArbitration_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('âī¸\x20Arbitration\x20Object:\x20Access\x20a\x20transparent\x20on-chain\x20arbitration\x20system\x20for\x20resolving\x20order\x20conflicts.'),z['object']({'operation_type':z['literal']('contact'),'data':CallContact_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đŦ\x20Contact\x20Object:\x20Manage\x20on-chain\x20instant\x20messaging\x20contact\x20profiles.'),z['object']({'operation_type':z['literal']('treasury'),'data':CallTreasury_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đ°\x20Treasury\x20Object:\x20Create\x20and\x20manage\x20treasury\x20for\x20team\x20funds\x20with\x20deposit/withdrawal\x20rules,\x20etc..'),z['object']({'operation_type':z['literal']('reward'),'data':CallReward_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đ\x20Reward\x20Object:\x20Create\x20reward\x20pools\x20and\x20set\x20claim\x20conditions\x20by\x20Guard\x20verification.'),z['object']({'operation_type':z['literal']('allocation'),'data':CallAllocation_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đ¤\x20Allocation\x20Object:\x20Create\x20distribution\x20plans\x20to\x20auto-distribute\x20funds\x20to\x20multiple\x20recipients.'),z['object']({'operation_type':z['literal']('permission'),'data':CallPermission_DataSchema,'env':CallEnvSchema['optional']()})['describe']('đ\x20Permission\x20Object:\x20Define\x20who\x20can\x20perform\x20which\x20operations\x20on\x20WoWok\x20objects.\x20Important\x20Note:\x20If\x20needed,\x20you\x20should\x20first\x20query\x20\x27guard\x20instructions\x27\x20through\x20the\x20\x27wowok_buildin_info\x27\x20tool.'),z['object']({'operation_type':z['literal']('guard'),'data':CallGuard_DataSchema,'env':CallEnvSchema['optional']()})['describe']('đĄī¸\x20Guard\x20Object:\x20Create\x20immutable\x20programmable\x20validation\x20rules\x20that\x20return\x20boolean\x20results.\x20Set\x20\x27namedNew\x27\x20to\x20name\x20the\x20new\x20Guard.\x20Use\x20root.type=\x27node\x27\x20for\x20direct\x20node\x20tree\x20or\x20root.type=\x27file\x27\x20to\x20load\x20from\x20file.\x20Use\x20\x27wowok_buildin_info\x27\x20tool\x20with\x20query=\x27guard\x20instructions\x27\x20for\x20all\x20available\x20operations.'),z['object']({'operation_type':z['literal']('personal'),'data':CallPersonal_DataSchema,'env':CallEnvSchema['optional']()})['describe']('đ\x20Public\x20Identity\x20Profile:\x20Establish\x20and\x20manage\x20your\x20on-chain\x20public\x20identity.\x20â ī¸\x20CRITICAL:\x20Everything\x20here\x20is\x20PERMANENTLY\x20PUBLIC\x20on\x20the\x20blockchain!'),z['object']({'operation_type':z['literal']('payment'),'data':CallPayment_DataSchema,'env':CallEnvSchema['optional']()})['describe']('đ°\x20Payment\x20Object:\x20Send\x20instant,\x20irreversible\x20coin\x20transfers\x20to\x20any\x20wallet\x20address.'),z['object']({'operation_type':z['literal']('demand'),'data':CallDemand_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đ¯\x20Demand\x20Object:\x20Post\x20service\x20requests\x20with\x20reward\x20pools\x20on-chain.'),z['object']({'operation_type':z['literal']('order'),'data':CallOrder_DataSchema,'env':CallEnvSchema['optional'](),'submission':SubmissionCallSchema['optional']()})['describe']('đĻ\x20Order\x20Object:\x20Manage\x20the\x20order\x20lifecycle,\x20Including\x20operating\x20order\x20arbitration\x20(Arb\x20Object\x20associated\x20with\x20the\x20order),\x20advancing\x20progress\x20(Progress\x20Object\x20associated\x20with\x20the\x20order),\x20extracting\x20order\x20refunds/payments,\x20setting\x20agents,\x20etc.'),z['object']({'operation_type':z['literal']('gen_passport'),'guard':z['string']()['describe']('Guard\x20object\x20ID\x20to\x20verify\x20and\x20generate\x20passport\x20from'),'info':SubmissionCallSchema['optional']()['describe']('Optional\x20submission\x20data.\x20If\x20not\x20provided,\x20will\x20attempt\x20to\x20get\x20existing\x20submissions\x20from\x20the\x20guard.'),'env':CallEnvSchema['optional']()})['describe']('đ\x20Generate\x20Verified\x20Passport\x20Object:\x20Create\x20immutable\x20verified\x20credentials\x20after\x20Guard\x20validation\x20passes.')]),WipOperationsSchema=z['discriminatedUnion']('type',[z['object']({'type':z['literal']('generate'),'options':WipGenerationOptionsSchema['describe']('WIP\x20generation\x20options'),'outputPath':z['string']()['describe']('Output\x20file\x20path\x20(.wip\x20file).\x20If\x20file\x20exists,\x20it\x20will\x20be\x20overwritten')})['describe']('Generate\x20WIP\x20file\x20from\x20markdown\x20text\x20and\x20optional\x20images'),z['object']({'type':z['literal']('verify'),'wipFilePath':z['string']()['describe']('WIP\x20file\x20path\x20to\x20verify.\x20Supports:\x201)\x20Local\x20file\x20path\x20(e.g.,\x20\x27/path/to/file.wip\x27,\x20\x27C:\x5cUsers\x5cname\x5cdoc.wip\x27),\x202)\x20Network\x20URL\x20(e.g.,\x20\x27https://example.com/doc.wip\x27,\x20\x27http://site.com/file.wip\x27),\x203)\x20Data\x20URL\x20(e.g.,\x20\x27data:application/json;base64,eyJ3aXAiOi...\x27)'),'hash_equal':z['string']()['optional']()['describe']('Optional\x20expected\x20hash\x20value.\x20If\x20provided,\x20the\x20function\x20will\x20first\x20verify\x20if\x20the\x20file\x27s\x20hash\x20matches\x20this\x20value.\x20If\x20not\x20matched,\x20returns\x20hash\x20mismatch\x20error.'),'requireSignature':z['boolean']()['optional']()['describe']('Optional\x20flag\x20to\x20require\x20digital\x20signature.\x20If\x20true,\x20verification\x20will\x20fail\x20if\x20WIP\x20file\x20has\x20no\x20signature')})['describe']('Verify\x20WIP\x20file\x20integrity\x20and\x20signatures'),z['object']({'type':z['literal']('sign'),'wipFilePath':z['string']()['describe']('WIP\x20file\x20path\x20to\x20sign.\x20Supports:\x201)\x20Local\x20file\x20path\x20(e.g.,\x20\x27/path/to/file.wip\x27),\x202)\x20Network\x20URL\x20(e.g.,\x20\x27https://example.com/doc.wip\x27).\x20The\x20file\x20will\x20be\x20loaded,\x20validated,\x20and\x20signed'),'account':z['string']()['optional']()['describe']('Signing\x20account\x20(account\x20name\x20or\x20address).\x20If\x20not\x20specified,\x20uses\x20default\x20account'),'outputPath':z['string']()['optional']()['describe']('Output\x20file\x20path.\x20If\x20not\x20specified,\x20adds\x20\x27signed_\x27\x20prefix\x20to\x20original\x20file\x20name\x20(e.g.,\x20\x27doc.wip\x27\x20becomes\x20\x27signed_doc.wip\x27)')})['describe']('Sign\x20WIP\x20file\x20with\x20account'),z['object']({'type':z['literal']('wip2html'),'wipPath':z['string']()['describe']('WIP\x20file\x20path\x20or\x20directory\x20path.\x20Supports:\x201)\x20Single\x20WIP\x20file\x20(e.g.,\x20\x27/path/to/file.wip\x27),\x202)\x20Directory\x20containing\x20.wip\x20files\x20(e.g.,\x20\x27/path/to/wips/\x27),\x203)\x20Network\x20URL\x20(e.g.,\x20\x27https://example.com/doc.wip\x27).\x20When\x20directory\x20is\x20provided,\x20all\x20.wip\x20files\x20in\x20the\x20directory\x20will\x20be\x20converted\x20to\x20HTML'),'options':WipToHtmlOptionsSchema['optional']()['describe']('Conversion\x20options')})['describe']('Convert\x20WIP\x20file\x20to\x20HTML\x20format')]),WatchQueryOperationsSchema=z['discriminatedUnion']('query_type',[z['object']({'query_type':z['literal']('local_mark_list'),'filter':LocalMarkFilterSchema['optional']()['describe']('Local\x20mark\x20filter')})['describe']('Query\x20local\x20ID/USER\x20address\x20book\x20with\x20optional\x20filter'),z['object']({'query_type':z['literal']('account_list'),'filter':AccountFilterSchema['optional']()['describe']('Account\x20filter')})['describe']('Query\x20account\x20list\x20with\x20optional\x20filter'),z['object']({'query_type':z['literal']('local_info_list'),'filter':LocalInfoFilterSchema['optional']()['describe']('Local\x20info\x20filter')})['describe']('Query\x20local\x20info\x20list\x20with\x20optional\x20filter'),z['object']({'query_type':z['literal']('token_list'),'filter':TokenDataFilterSchema['optional']()})['describe']('Query\x20token\x20list\x20with\x20optional\x20filter'),z['object']({'query_type':z['literal']('account_balance'),'name_or_address':NameOrAddressSchema['optional']()['describe']('Account\x20name\x20or\x20address.\x20Use\x20empty\x20string\x20\x27\x27\x20for\x20the\x20default\x20account.\x20Defaults\x20to\x20\x27\x27\x20if\x20omitted.'),'token_type':TokenTypeSchema['optional']()['describe']('Token\x20type;\x20default\x20token\x20type\x20is\x200x2::wow::WOW')})['describe']('Query\x20account\x20balance\x20or\x20coin\x20objects\x20by\x20the\x20token\x20type'),z['object']({'query_type':z['literal']('onchain_personal_profile'),'account':NameOrAddressSchema['optional']()['describe']('Account\x20name\x20or\x20ID\x20to\x20query.\x20Use\x20empty\x20string\x20\x27\x27\x20for\x20the\x20default\x20account.')})['describe']('Query\x20PUBLIC\x20on-chain\x20personal\x20profile\x20for\x20any\x20account\x20address'),z['object']({'query_type':z['literal']('onchain_objects'),'objects':z['array'](NameOrAddressSchema)['describe']('List\x20of\x20object\x20IDs\x20to\x20query')})['describe']('Query\x20on-chain\x20objects'),z['object']({'query_type':z['literal']('onchain_table'),'parent':NameOrAddressSchema,'object_type':ObjectTypeSchema})['describe']('Query\x20on-chain\x20table\x20data\x20of\x20the\x20specified\x20object'),z['object']({'query_type':z['literal']('onchain_table_item_repository_data'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'name':z['string']()['describe']('Name\x20of\x20the\x20record\x20to\x20query'),'entity':z['union']([AccountOrMark_AddressSchema,z['number']()])['describe']('ID\x20or\x20address\x20of\x20the\x20entity;\x20or\x20address\x20that\x20number\x20is\x20casted\x20to')})['describe']('Query\x20repository\x20data\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_permission_perm'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'address':z['union']([AccountOrMark_AddressSchema,z['string']()])['describe']('User\x20ID\x20or\x20address,\x20or\x20Guard\x20ID\x20in\x20the\x20permission\x20perm\x20table')})['describe']('Query\x20permission\x20perm\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_entity_registrar'),'address':z['union']([AccountOrMark_AddressSchema,z['string']()])['describe']('User\x20ID\x20or\x20address\x20of\x20the\x20entity')})['describe']('Query\x20entity\x20registrar\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_entity_linker'),'address':z['union']([AccountOrMark_AddressSchema,z['string']()])['describe']('ID\x20or\x20address\x20that\x20the\x20registrar\x20votes\x20are\x20attached\x20to')})['describe']('Query\x20entity\x20linker\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_reward_record'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'address':AccountOrMark_AddressSchema['describe']('User\x20ID\x20or\x20address\x20that\x20claims\x20the\x20reward')})['describe']('Query\x20reward\x20record\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_demand_presenter'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'address':AccountOrMark_AddressSchema['describe']('User\x20ID\x20or\x20address\x20of\x20the\x20Demand\x20presenter')})['describe']('Query\x20demand\x20presenter\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_treasury_history'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'address':AccountOrMark_AddressSchema['describe']('ID\x20of\x20the\x20payment\x20that\x20the\x20treasury\x20record\x20is\x20attached\x20to')})['describe']('Query\x20treasury\x20record\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_machine_node'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'key':z['string']()['describe']('String\x20key\x20of\x20the\x20node\x20name\x20to\x20query')})['describe']('Query\x20machine\x20node\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_progress_history'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'u64':z['union']([z['number'](),z['string']()])['describe']('U64\x20value\x20of\x20the\x20record\x20to\x20query')})['describe']('Query\x20progress\x20history\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_table_item_address_mark'),'parent':NameOrAddressSchema['describe']('Parent\x20object\x20ID\x20of\x20the\x20data\x20table\x20to\x20query'),'address':AccountOrMark_AddressSchema['describe']('ID\x20or\x20address\x20that\x20the\x20mark\x20name\x20and\x20tags\x20are\x20attached\x20to')})['describe']('Query\x20address\x20mark\x20table\x20item'),z['object']({'query_type':z['literal']('onchain_received'),'object':z['string']()['describe']('Object\x20ID\x20to\x20query'),'all_type':z['boolean']()['optional']()['describe']('Whether\x20to\x20query\x20all\x20types\x20of\x20received\x20objects')})['describe']('Query\x20on-chain\x20received\x20balance,\x20payments,\x20and\x20NFTs')]);async function handleOnchainOperations(a){console['log']('===\x20handleOnchainOperations\x20==='),console['log']('args:',JSON['stringify'](a,null,0x2));try{const b=strictParse(OnchainOperationsSchema,a,'onchain_operations\x20input');console['log']('validated:',JSON['stringify'](b,null,0x2));const c=getEnvConfig(b['env']);switch(b['operation_type']){case'service':{const d=new CallService(b['data']),f=b['submission']?await d['call_with_submission'](c,await transformSubmission(b['submission'])):await d['call'](c);return handleCallResult(f);}case'machine':{if(b['data']['node']&&typeof b['data']['node']==='object'&&'json_or_markdown_file'in b['data']['node']){const i=b['data']['node']['json_or_markdown_file'];let j;try{const l=resolve(i);j=readFileSync(l,'utf-8');}catch(m){throw new Error('Failed\x20to\x20read\x20file\x20\x27'+i+'\x27:\x20'+m['message']);}const k=parseMachineNodesFromText(j);if(!k['success']){const n=a0a(k['errors']);throw new Error('Machine\x20node\x20validation\x20failed\x20for\x20file\x20\x27'+i+'\x27:\x0a\x0a'+n);}if(!k['data'])throw new Error('No\x20nodes\x20found\x20in\x20file\x20\x27'+i+'\x27');b['data']['node']={'op':'set','nodes':k['data'],'bReplace':!![]};}const g=new CallMachine(b['data']),h=b['submission']?await g['call_with_submission'](c,await transformSubmission(b['submission'])):await g['call'](c);return handleCallResult(h);}case'progress':{const o=new CallProgress(b['data']),p=b['submission']?await o['call_with_submission'](c,await transformSubmission(b['submission'])):await o['call'](c);return handleCallResult(p);}case'repository':{const q=new CallRepository(b['data']),r=b['submission']?await q['call_with_submission'](c,await transformSubmission(b['submission'])):await q['call'](c);return handleCallResult(r);}case'arbitration':{const s=new CallArbitration(b['data']),t=b['submission']?await s['call_with_submission'](c,await transformSubmission(b['submission'])):await s['call'](c);return handleCallResult(t);}case'contact':{const u=new CallContact(b['data']),v=b['submission']?await u['call_with_submission'](c,await transformSubmission(b['submission'])):await u['call'](c);return handleCallResult(v);}case'treasury':{const w=new CallTreasury(b['data']),x=b['submission']?await w['call_with_submission'](c,await transformSubmission(b['submission'])):await w['call'](c);return handleCallResult(x);}case'reward':{const y=transformRewardData(b['data']),A=new CallReward(y),B=b['submission']?await A['call_with_submission'](c,await transformSubmission(b['submission'])):await A['call'](c);return handleCallResult(B);}case'allocation':{const C=new CallAllocation(b['data']),D=b['submission']?await C['call_with_submission'](c,await transformSubmission(b['submission'])):await C['call'](c);return handleCallResult(D);}case'permission':{const E=new CallPermission(b['data']),F=await E['call'](c);return handleCallResult(F);}case'guard':{const G=b['data'];if(G['root']?.['type']==='file'){const J=resolve(G['root']['file_path']);let K;try{K=readFileSync(J,'utf-8');}catch(N){throw new Error('Failed\x20to\x20read\x20Guard\x20definition\x20file\x20\x27'+G['root']['file_path']+'\x27:\x20'+N['message']);}const L=parseGuardFile(K,G['root']['format']);if(!L['success']){const O=formatGuardParseErrors(L['errors']);throw new Error('Guard\x20validation\x20failed\x20for\x20file\x20\x27'+G['root']['file_path']+'\x27:\x0a\x0a'+O);}const M=L['data'];G['root']={'type':'node','node':M['root']},M['table']!==undefined&&G['table']===undefined&&(G['table']=M['table']),M['description']!==undefined&&G['description']===undefined&&(G['description']=M['description']),M['rely']!==undefined&&G['rely']===undefined&&(G['rely']=M['rely']),M['namedNew']!==undefined&&G['namedNew']===undefined&&(G['namedNew']=M['namedNew']);}if(G['root']&&typeof G['root']==='object'){const P=G['root'];P['type']==='node'&&P['node']&&(G['root']=P['node']);}if(!G['table']||G['table']['length']===0x0)throw new Error('Guard\x20\x27table\x27\x20field\x20is\x20required\x20and\x20cannot\x20be\x20empty');if(!G['root'])throw new Error('Guard\x20\x27root\x27\x20field\x20is\x20required');const H=new CallGuard(G),I=await H['call'](c);return handleCallResult(I);}case'personal':{const Q=U=>{const V={...U};if(U['mark']){const W=X=>{if(typeof X==='string')return{'name_or_address':X,'local_mark_first':!![]};return X;};if(U['mark']['op']==='add'&&U['mark']['data'])V['mark']={...U['mark'],'data':U['mark']['data']['map'](X=>({...X,'address':W(X['address'])}))};else{if(U['mark']['op']==='remove'&&U['mark']['data'])V['mark']={...U['mark'],'data':U['mark']['data']['map'](X=>({...X,'address':W(X['address'])}))};else{if(U['mark']['op']==='clear'&&U['mark']['address']){const X=U['mark']['address'];Array['isArray'](X)&&X['every'](Y=>typeof Y==='string')&&(V['mark']={...U['mark'],'address':{'entities':X['map'](Y=>({'name_or_address':Y,'local_mark_first':!![]}))}});}else U['mark']['op']==='transfer'&&U['mark']['to']&&(V['mark']={...U['mark'],'to':W(U['mark']['to'])});}}}return V;},R=Q(b['data']),S=new CallPersonal(R),T=await S['call'](c);return handleCallResult(T);}case'payment':{const U=new CallPayment(b['data']),V=await U['call'](c);return handleCallResult(V);}case'demand':{const W=new CallDemand(b['data']),X=b['submission']?await W['call_with_submission'](c,await transformSubmission(b['submission'])):await W['call'](c);return handleCallResult(X);}case'order':{const Y=new CallOrder(b['data']),Z=b['submission']?await Y['call_with_submission'](c,await transformSubmission(b['submission'])):await Y['call'](c);return handleCallResult(Z);}case'gen_passport':{const a0=await gen_passport(c,b['guard'],b['info']);return handleCallResult(a0);}}throw new Error('Unknown\x20on-chain\x20operation\x20type:\x20'+b['operation_type']);}catch(a1){const a2=a1 instanceof Error?a1['message']:String(a1);return{'content':[{'type':'text','text':'Error:\x20'+a2}],'structuredContent':{'message':'Error:\x20'+a2,'result':{'type':'error','error':a2}}};}}async function handleAccountOperation(a){try{const b=strictParse(AccountOperationSchema,a,'account_operation\x20input'),c=await account_operation(b);return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':{'result':{'status':'success','data':c}}};}catch(d){const e=d instanceof Error?d['message']:String(d);return{'content':[{'type':'text','text':'Error:\x20'+e}],'structuredContent':{'result':{'status':'error','error':e}}};}}async function handleMarkOperation(a){try{const b=strictParse(LocalMarkOperationSchema,a,'local_mark_operation\x20input'),c=await local_mark_operation(b);return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':{'result':{'status':'success','data':c}}};}catch(d){const e=d instanceof Error?d['message']:String(d);return{'content':[{'type':'text','text':'Error:\x20'+e}],'structuredContent':{'result':{'status':'error','error':e}}};}}async function handleInfoOperation(a){try{const b=strictParse(LocalInfoOperationSchema,a,'local_info_operation\x20input'),c=await local_info_operation(b);return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':{'result':{'status':'success','data':c}}};}catch(d){const e=d instanceof Error?d['message']:String(d);return{'content':[{'type':'text','text':'Error:\x20'+e}],'structuredContent':{'result':{'status':'error','error':e}}};}}async function handleWipOperations(a){const b=strictParse(WipOperationsSchema,a,'wip_file\x20input');let c;switch(b['type']){case'generate':{const d=await generate_wip(b['options'],b['outputPath']);c={'result':{'type':'generate','filePath':d}};break;}case'verify':{const e=await verify_wip(b['wipFilePath'],b['hash_equal'],b['requireSignature']);c={'result':{'type':'verify',...e}};break;}case'sign':{const f=await sign_wip(b['wipFilePath'],b['account'],b['outputPath']);c={'result':{'type':'sign','filePath':f}};break;}case'wip2html':{const g=await wip2html(b['wipPath'],b['options']);let h={'type':'wip2html'};if(typeof g==='string')h['html']=g;else Array['isArray'](g)?h['files']=g:h['html']=String(g);c={'result':h};break;}default:throw new Error('Unknown\x20WIP\x20operation\x20type');}return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':c};}async function handleWatchQueryOperations(a){const b=strictParse(WatchQueryOperationsSchema,a,'watch_and_query\x20input');let c;switch(b['query_type']){case'local_mark_list':{const d=await query_local_mark_list(b['filter']||{});c={'query_type':'local_mark_list','result':d};break;}case'account_list':{const e=await query_account_list(b['filter']);c={'query_type':'account_list','result':e};break;}case'local_info_list':{const f=await query_local_info_list(b['filter']);c={'query_type':'local_info_list','result':f};break;}case'token_list':{const g=await query_local_token_list(b['filter']||{});c={'query_type':'token_list','result':g};break;}case'account_balance':{const h=await query_account({'name_or_address':b['name_or_address'],'token_type':b['token_type'],'balance':!![]});c={'query_type':'account_balance','result':h};break;}case'onchain_personal_profile':{const i=await query_personal({'account':b['account']});c={'query_type':'onchain_personal_profile','result':i};break;}case'onchain_objects':{const j=await query_objects({'objects':b['objects']});j&&j['objects']&&Array['isArray'](j['objects'])&&(j['objects']=j['objects']['map'](k=>{if(k&&k['data']&&k['data']['type']==='Guard'&&k['data']['root'])try{const l=generateNodeComments(k['data']['root']);return{...k,'_guard_node_comments':l};}catch(m){return k;}return k;}));c={'query_type':'onchain_objects','result':j};break;}case'onchain_table':{const k=await query_table({'parent':b['parent'],'object_type':b['object_type']});c={'query_type':'onchain_table','result':k};break;}case'onchain_table_item_repository_data':{const l=await queryTableItem_RepositoryData({'parent':b['parent'],'name':b['name'],'entity':b['entity']});c={'query_type':'onchain_table_item_repository_data','result':l};break;}case'onchain_table_item_permission_perm':{const m=await queryTableItem_PermissionPerm({'parent':b['parent'],'address':b['address']});c={'query_type':'onchain_table_item_permission_perm','result':m};break;}case'onchain_table_item_reward_record':{const n=await queryTableItem_RewardRecord({'parent':b['parent'],'address':b['address']});c={'query_type':'onchain_table_item_reward_record','result':n};break;}case'onchain_table_item_demand_presenter':{const o=await queryTableItem_DemandPresenter({'parent':b['parent'],'address':b['address']});c={'query_type':'onchain_table_item_demand_presenter','result':o};break;}case'onchain_table_item_treasury_history':{const p=await queryTableItem_TreasuryHistory({'parent':b['parent'],'address':b['address']});c={'query_type':'onchain_table_item_treasury_history','result':p};break;}case'onchain_table_item_machine_node':{const q=await queryTableItem_MachineNode({'parent':b['parent'],'key':b['key']});c={'query_type':'onchain_table_item_machine_node','result':q};break;}case'onchain_table_item_progress_history':{const r=await queryTableItem_ProgressHistory({'parent':b['parent'],'u64':b['u64']});c={'query_type':'onchain_table_item_progress_history','result':r};break;}case'onchain_table_item_address_mark':{const s=await queryTableItem_AddressMark({'parent':b['parent'],'address':b['address']});c={'query_type':'onchain_table_item_address_mark','result':s};break;}case'onchain_table_item_entity_registrar':{const t=await queryTableItem_EntityRegistrar({'address':b['address']});c={'query_type':'onchain_table_item_entity_registrar','result':t};break;}case'onchain_table_item_entity_linker':{const u=await queryTableItem_EntityLinker({'address':b['address']});c={'query_type':'onchain_table_item_entity_linker','result':u};break;}case'onchain_received':{const v=await query_received({'object':b['object'],'all_type':b['all_type']});c={'query_type':'onchain_received','result':v};break;}default:throw new Error('Unknown\x20watch\x20query\x20type.\x20Valid\x20query_types\x20are:\x20\x22local_mark_list\x22,\x20\x22account_list\x22,\x20\x22local_info_list\x22,\x20\x22token_list\x22,\x20\x22account_balance\x22,\x20\x22onchain_personal_profile\x22,\x20\x22onchain_objects\x22,\x20\x22onchain_table\x22,\x20\x22onchain_table_item_repository_data\x22,\x20\x22onchain_table_item_permission_perm\x22,\x20\x22onchain_table_item_reward_record\x22,\x20\x22onchain_table_item_demand_presenter\x22,\x20\x22onchain_table_item_treasury_history\x22,\x20\x22onchain_table_item_machine_node\x22,\x20\x22onchain_table_item_progress_history\x22,\x20\x22onchain_table_item_address_mark\x22,\x20\x22onchain_table_item_entity_registrar\x22,\x20\x22onchain_table_item_entity_linker\x22,\x20\x22onchain_received\x22');}return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}async function handleWowokInfo(a){const b=strictParse(ProtocolInfoQuerySchema,a,'wowok_buildin_info\x20input'),c=await queryProtocolInfo(b);return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}async function handleOnchainEvents(a){const b=strictParse(OnchainEventsInputSchema,a,'onchain_events\x20input'),c=await query_events({'type':b['type'],'cursor':b['cursor']??null,'limit':b['limit']??null,'order':b['order']??null,'no_cache':b['no_cache'],'network':b['network']});return{'content':[{'type':'text','text':JSON['stringify']({'result':c})}],'structuredContent':{'result':c}};}function normalizeAccountOrMark(a){if(typeof a==='string')return{'name_or_address':a,'local_mark_first':!![]};return a;}function normalizeManyAccountOrMark(a){if(Array['isArray'](a))return{'entities':a['map'](b=>typeof b==='string'?{'name_or_address':b,'local_mark_first':!![]}:b),'check_all_founded':!![]};return a;}async function handleMessengerOperation(a){const b=strictParse(MessengerOperationInputSchema,a,'messenger_operation\x20input');let c;switch(b['operation']){case'watch_conversations':{const d=await watch_conversations(b['filter']);c={'operation':'watch_conversations','result':d};break;}case'send_message':{const e=await send_message(b['from'],normalizeAccountOrMark(b['to']),b['content'],b['options']),f={...e,'merkleData':e['merkleData']?{'leafIndex':e['merkleData']['leafIndex'],'prevRoot':e['merkleData']['prevRoot'],'newRoot':e['merkleData']['newRoot'],'serverSignature':e['merkleData']['serverSignature'],'serverTimestamp':e['merkleData']['serverTimestamp'],'serverPublicKey':e['merkleData']['serverPublicKey']}:undefined};c={'operation':'send_message','result':f};break;}case'send_file':{const g=await send_file(b['from'],normalizeAccountOrMark(b['to']),b['filePath'],b['options']),h={...g,'merkleData':g['merkleData']?{'leafIndex':g['merkleData']['leafIndex'],'prevRoot':g['merkleData']['prevRoot'],'newRoot':g['merkleData']['newRoot'],'serverSignature':g['merkleData']['serverSignature'],'serverTimestamp':g['merkleData']['serverTimestamp'],'serverPublicKey':g['merkleData']['serverPublicKey']}:undefined};c={'operation':'send_file','result':h};break;}case'watch_messages':{const i=b['filter']?{...b['filter'],'peerAddress':b['filter']['peerAddress']?normalizeAccountOrMark(b['filter']['peerAddress']):undefined}:undefined,j=await watch_messages(i);c={'operation':'watch_messages','result':j};break;}case'extract_zip_messages':{const k=await extract_zip_messages(b['account'],b['messages'],b['outputDir']);c={'operation':'extract_zip_messages','result':k};break;}case'generate_wts':{const l=b['params']?{...b['params'],'peerAccount':normalizeAccountOrMark(b['params']['peerAccount'])}:undefined,m=await generate_wts(l);c={'operation':'generate_wts','result':m};break;}case'verify_wts':{const n=await verify_wts(b['wtsFilePath']);c={'operation':'verify_wts','result':n};break;}case'sign_wts':{const o=await sign_wts(b['wtsFilePath'],b['account'],b['outputPath']);c={'operation':'sign_wts','result':o};break;}case'wts2html':{const p=await wts2html(b['wtsPath'],b['options']);c={'operation':'wts2html','result':p};break;}case'proof_message':{const q=await proof_message(b['account'],b['messageId'],b['network']);c={'operation':'proof_message','result':q};break;}case'blacklist':{const r={'account':b['account'],'op':b['blacklist']['op']};'users'in b['blacklist']&&(r['users']=normalizeManyAccountOrMark(b['blacklist']['users']));const s=await blacklist(r);c={'operation':'blacklist','op':b['blacklist']['op'],'result':s['result']};break;}case'friendslist':{const t={'account':b['account'],'op':b['friendslist']['op']};'users'in b['friendslist']&&(t['users']=normalizeManyAccountOrMark(b['friendslist']['users']));const u=await friendslist(t);c={'operation':'friendslist','op':b['friendslist']['op'],'result':u['result']};break;}case'guardlist':{const v=await guardlist({'account':b['account'],...b['guardlist']});c={'operation':'guardlist','op':b['guardlist']['op'],'result':v['result']};break;}case'settings':{const w=await settings({'account':b['account'],...b['settings']});c={'operation':'settings','op':b['settings']['op'],'result':w['result']};break;}case'mark_messages_as_viewed':{const x=await mark_messages_as_viewed(b['messageIds'],b['account']);c={'operation':'mark_messages_as_viewed','result':x};break;}case'mark_conversation_as_viewed':{const y=await mark_conversation_as_viewed(normalizeAccountOrMark(b['peerAddress']),b['account']);c={'operation':'mark_conversation_as_viewed','result':y};break;}default:throw new Error('Unknown\x20messenger\x20operation:\x20'+b['operation']);}return{'content':[{'type':'text','text':JSON['stringify'](c)}],'structuredContent':{'result':c}};}async function handleGuard2File(a){const b=strictParse(Guard2File_InputSchema,a,'guard2file\x20input'),c=getEnvConfig(b['env']);try{await guard2file(b['guard'],b['file_path'],b['format']||'json',c['network']);const d={'result':{'status':'success','data':{'file_path':resolve(b['file_path']),'format':b['format']||'json','guard_object':b['guard']}}};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}catch(e){const f={'result':{'status':'error','error':e['message']}};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}}async function handleMachineNode2File(a){const b=strictParse(MachineNode2File_InputSchema,a,'machineNode2file\x20input'),c=getEnvConfig(b['env']);try{await machineNode2file(b['machine'],b['file_path'],b['format']||'json',c['network']);const d={'result':{'status':'success','data':{'file_path':resolve(b['file_path']),'format':b['format']||'json','machine_object':b['machine'],'node_count':0x0}}};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}catch(e){const f={'result':{'status':'error','error':e['message']}};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}}export{OnchainOperationsSchema,WipOperationsSchema,WatchQueryOperationsSchema,AccountOperationSchema,LocalMarkOperationSchema,LocalInfoOperationSchema,ProtocolInfoQuerySchema,CallOutputSchema,MessengerOperationInputSchema,MessengerOperationOutputSchema};async function main(){server['registerTool']('onchain_operations',{'title':'âī¸\x20On-chain\x20Operations','description':'On-chain\x20operations\x20for\x20WoWok\x20object:\x20service\x20(marketplace\x20listings),\x20machine\x20(workflow\x20templates),\x20progress\x20(order\x20tracking),\x20repository\x20(on-chain\x20database),\x20arbitration\x20(dispute\x20resolution),\x20contact\x20(IM\x20management),\x20treasury\x20(team\x20funds),\x20reward\x20(incentive\x20pools),\x20allocation\x20(auto-distribution),\x20permission\x20(access\x20control),\x20guard\x20(programmable\x20trust\x20rules),\x20personal\x20(public\x20profile),\x20payment\x20(direct\x20coin\x20transfers),\x20demand\x20(service\x20requests),\x20order\x20(order\x20management),\x20gen_passport\x20(verified\x20credentials).','inputSchema':OnchainOperationsSchema,'outputSchema':CallOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('operation',['service','machine','progress','repository','arbitration','contact','treasury','reward','allocation','permission','guard','personal','payment','demand','order','gen_passport','on-chain','blockchain'])},handleOnchainOperations),server['registerTool']('account_operation',{'title':'đ\x20LOCAL\x20ONLY:\x20Account\x20-\x20Wallet\x20Management','description':'đ\x20100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20đ\x20Manage\x20WoWok\x20accounts\x20locally\x20on\x20device:\x20generate,\x20suspend,\x20resume,\x20faucet-test,\x20operate\x20assets,\x20sign\x20data,\x20etc.','inputSchema':AccountOperationSchema,'outputSchema':AccountOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['account','local','private','wallet','off-chain'])},handleAccountOperation),server['registerTool']('local_mark_operation',{'title':'đ\x20LOCAL\x20ONLY:\x20LocalMark\x20-\x20Address\x20Book\x20Management','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20đ\x20Manage\x20ID\x20names\x20and\x20tags\x20stored\x20ONLY\x20on\x20your\x20local\x20device\x20for\x20easy\x20identification\x20of\x20user\x20address\x20or\x20object\x20IDs\x20by\x20name.','inputSchema':LocalMarkOperationSchema,'outputSchema':LocalMarkOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['mark','local','private','address-book','off-chain'])},handleMarkOperation),server['registerTool']('local_info_operation',{'title':'đ\x20LOCAL\x20ONLY:\x20LocalInfo\x20-\x20Private\x20Data\x20Management','description':'100%\x20LOCAL,\x20NEVER\x20ON-CHAIN\x20đ\x20Manage\x20sensitive\x20personal\x20information\x20stored\x20ONLY\x20on\x20your\x20device:\x20delivery\x20addresses,\x20phone\x20numbers,\x20contacts.','inputSchema':LocalInfoOperationSchema,'outputSchema':LocalInfoOperationOutputWrappedSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':!![],'openWorldHint':![]},'_meta':createToolMeta('operation',['info','local','private','data-management','off-chain'])},handleInfoOperation),server['registerTool']('wip_file',{'title':'đ¤\x20Witness\x20Information\x20Promise\x20File\x20Operations','description':'generate\x20(create\x20WIP\x20files\x20from\x20markdown\x20and\x20images),\x20verify\x20(integrity\x20check),\x20sign\x20(add\x20signatures),\x20or\x20wip2html\x20(convert\x20to\x20HTML).','inputSchema':WipOperationsSchema,'outputSchema':z['object']({'result':WipOperationOutputSchema}),'annotations':{'readOnlyHint':![],'destructiveHint':![],'idempotentHint':![],'openWorldHint':![]},'_meta':createToolMeta('operation',['wip','promise','file-generation','verification','signature','local'])},handleWipOperations),server['registerTool']('messenger_operation',{'title':'đŦ\x20Messenger\x20Operations','description':'WoWok\x20encrypted\x20messenger\x20operations:\x20watch\x20conversations\x20(with\x20unread\x20filtering,\x20preview\x20messages),\x20send\x20message,\x20send\x20file,\x20watch\x20messages\x20(with\x20viewed\x20status\x20filtering),\x20extract\x20zip\x20messages,\x20generate\x20WTS,\x20verify\x20WTS,\x20sign\x20WTS,\x20WTS\x20to\x20HTML,\x20proof\x20message\x20on-chain,\x20manage\x20blacklist,\x20friendslist,\x20guardlist,\x20settings,\x20mark\x20messages\x20as\x20viewed,\x20and\x20mark\x20conversation\x20as\x20viewed.','inputSchema':MessengerOperationInputSchema,'outputSchema':MessengerOperationOutputSchema,'annotations':{'readOnlyHint':![],'destructiveHint':!![],'idempotentHint':![],'openWorldHint':!![]},'_meta':createToolMeta('operation',['messenger','message','file','wts','blacklist','friendslist','guardlist','settings','proof','communication'])},handleMessengerOperation),server['registerTool']('guard2file',{'title':'đ\x20Guard\x20to\x20File\x20-\x20Export\x20Guard\x20Definition','description':'Export\x20a\x20Guard\x20object\x27s\x20definition\x20from\x20the\x20blockchain\x20to\x20a\x20local\x20JSON\x20or\x20Markdown\x20file\x20for\x20editing\x20and\x20creating\x20new\x20Guard\x20objects.\x20Note:\x20To\x20query\x20on-chain\x20object\x20information,\x20use\x20the\x20\x27query_toolkit\x27\x20tool\x20instead.','inputSchema':Guard2File_InputSchema,'outputSchema':Guard2File_OutputWrappedSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('generate\x20file',['guard','export','file','json','markdown','on-chain'])},handleGuard2File),server['registerTool']('machineNode2file',{'title':'âī¸\x20Machine\x20Node\x20to\x20File\x20-\x20Export\x20Machine\x20Node\x20Definition','description':'Export\x20a\x20Machine\x20object\x27s\x20node\x20definition\x20from\x20the\x20blockchain\x20to\x20a\x20local\x20JSON\x20or\x20Markdown\x20file\x20for\x20editing\x20and\x20creating\x20new\x20Machine\x20objects.\x20Note:\x20To\x20query\x20on-chain\x20object\x20information,\x20use\x20the\x20\x27query_toolkit\x27\x20tool\x20instead.','inputSchema':MachineNode2File_InputSchema,'outputSchema':MachineNode2File_OutputWrappedSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('generate\x20file',['machine','export','file','json','markdown','on-chain','workflow'])},handleMachineNode2File),server['registerTool']('query_toolkit',{'title':'đ\x20Data\x20Query\x20Toolkit','description':'WOWOK\x20data\x20query\x20toolkit:\x20Query\x20local\x20naming\x20info\x20(accounts,\x20names,\x20Object\x20IDs),\x20and\x20query\x20on-chain\x20WOWOK\x20objects,\x20table\x20items,\x20events,\x20received\x20tokens,\x20user\x20profile,\x20etc.','inputSchema':WatchQueryOperationsSchema,'outputSchema':WatchQueryOperationsResultSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('query',['watch','query','on-chain','local','events','objects','tables','tokens','balance','profile'])},handleWatchQueryOperations),server['registerTool']('onchain_events',{'title':'đ
\x20Watch\x20On-chain\x20Events','description':'Watch\x20on-chain\x20WOWOK\x20events\x20by\x20type.\x20Supports\x20arbitration\x20events,\x20new\x20order\x20events,\x20progress\x20events,\x20demand\x20presentation\x20events,\x20demand\x20feedback\x20events,\x20and\x20new\x20entity\x20registration\x20events.\x20Use\x20pagination\x20cursor\x20for\x20fetching\x20large\x20result\x20sets.','inputSchema':OnchainEventsInputSchema,'outputSchema':OnchainEventsResultSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('watch\x20events',['events','on-chain','arbitration','order','progress','demand','entity'])},handleOnchainEvents),server['registerTool']('wowok_buildin_info',{'title':'âšī¸\x20WoWok\x20Build-in\x20Information','description':'Query\x20WoWok\x20protocol\x20information:\x20\x27constants\x27,\x20\x27built-in\x20permissions\x27,\x20\x27guard\x20instructions\x27,\x20\x27current\x20network\x27,\x20or\x20\x27value\x20types\x27.','inputSchema':ProtocolInfoQuerySchema,'outputSchema':ProtocolInfoResultSchema,'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('WoWok\x20info',['build-in','constants','permissions','guard','network','value-types'])},handleWowokInfo),server['registerTool']('documents_and_learn',{'title':'đ\x20Documents\x20and\x20Learn','description':'Access\x20WoWok\x20documentation\x20and\x20learning\x20resources.\x20Provides\x20official\x20documentation\x20URL\x20for\x20users\x20and\x20AI\x20to\x20get\x20more\x20information\x20about\x20WoWok\x20protocol,\x20components,\x20and\x20usage.','inputSchema':z['object']({'topic':z['string']()['optional']()['describe']('Optional\x20topic\x20to\x20search\x20for\x20in\x20documentation\x20(e.g.,\x20\x27guard\x27,\x20\x27service\x27,\x20\x27messenger\x27,\x20\x27stage-01-introduction\x27)')}),'outputSchema':z['object']({'documentation_url':z['string']()['describe']('Official\x20WoWok\x20documentation\x20URL\x20on\x20GitHub'),'topic':z['string']()['optional']()['describe']('Requested\x20topic\x20if\x20specified'),'original_topic':z['string']()['optional']()['describe']('Original\x20topic\x20input\x20by\x20user\x20(before\x20normalization)'),'message':z['string']()['describe']('Welcome\x20message\x20with\x20documentation\x20information.\x20Always\x20included\x20in\x20response.')}),'annotations':{'readOnlyHint':!![],'destructiveHint':![],'idempotentHint':!![],'openWorldHint':!![]},'_meta':createToolMeta('documentation',['docs','learn','tutorial','guide','help','reference'])},async b=>{const c='https://github.com/wowok-ai/docs/blob/main/docs';if(!b['topic']){const g=c,h='Welcome\x20to\x20WoWok\x20Documentation!\x20Access\x20comprehensive\x20guides,\x20tutorials,\x20and\x20API\x20references\x20at:\x20'+g;return{'content':[{'type':'text','text':h}],'structuredContent':{'documentation_url':g,'message':h}};}const d=b['topic']['toLowerCase']()['trim'](),e=c+'/'+d+'.md',f='Documentation\x20for\x20\x22'+d+'\x22\x0aGitHub\x20URL:\x20'+e;return{'content':[{'type':'text','text':f}],'structuredContent':{'documentation_url':e,'topic':d,'original_topic':b['topic'],'message':f}};});const a=new StdioServerTransport();await server['connect'](a),process['on']('SIGINT',async()=>{await server['close'](),process['exit'](0x0);});}main()['catch'](console['error']);
|