wowok_agent 2.2.3 β†’ 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
5
5
  import { readFileSync } from "fs";
6
6
  import { resolve } from "path";
7
7
  const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
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 formatMachineNodeErrors, MessengerOperationInputSchema, } from "./schema/index.js";
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, TableAnswerSchema, TableItem_RepositoryDataSchema, TableItem_PermissionPermSchema, TableItem_EntityRegistrarSchema, TableItem_EntityLinkerSchema, TableItem_RewardRecordSchema, TableItem_DemandPresenterSchema, TableItem_TreasuryHistorySchema, TableItem_MachineNodeSchema, TableItem_ProgressHistorySchema, TableItem_AddressMarkSchema, NameOrAddressSchema, AccountOrMark_AddressSchema, EntrypointSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, MessengerOperationInputSchema, } from "./schema/index.js";
9
9
  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";
10
10
  const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
11
11
 
@@ -146,6 +146,15 @@ function transformRewardData(data) {
146
146
  const OnchainOperationsSchema = z.preprocess((input) => {
147
147
  if (typeof input === 'object' && input !== null) {
148
148
  const obj = { ...input };
149
+ if (typeof obj.description === 'string' && !obj.operation_type) {
150
+ try {
151
+ const parsed = JSON.parse(obj.description);
152
+ if (parsed && typeof parsed === 'object' && parsed.operation_type) {
153
+ return parsed;
154
+ }
155
+ }
156
+ catch { }
157
+ }
149
158
  if (typeof obj.data === 'string') {
150
159
  try {
151
160
  obj.data = JSON.parse(obj.data);
@@ -237,7 +246,7 @@ const OnchainOperationsSchema = z.preprocess((input) => {
237
246
  operation_type: z.literal("guard"),
238
247
  data: CallGuard_DataSchema,
239
248
  env: CallEnvSchema.optional(),
240
- }).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."),
249
+ }).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. NOTE for EntityLinker/EntityRegistrar queries: Add system addresses to the Guard table - ENTITY_LINKER_ADDRESS (0xaaa) for EntityLinker, ENTITY_REGISTRAR_ADDRESS (0xaab) for EntityRegistrar."),
241
250
  z.object({
242
251
  operation_type: z.literal("personal"),
243
252
  data: CallPersonal_DataSchema,
@@ -270,6 +279,15 @@ const OnchainOperationsSchema = z.preprocess((input) => {
270
279
  const WipOperationsSchema = z.preprocess((input) => {
271
280
  if (typeof input === 'object' && input !== null) {
272
281
  const obj = { ...input };
282
+ if (typeof obj.description === 'string' && !obj.type) {
283
+ try {
284
+ const parsed = JSON.parse(obj.description);
285
+ if (parsed && typeof parsed === 'object' && parsed.type) {
286
+ return parsed;
287
+ }
288
+ }
289
+ catch { }
290
+ }
273
291
  if (typeof obj.options === 'string') {
274
292
  try {
275
293
  obj.options = JSON.parse(obj.options);
@@ -303,9 +321,202 @@ const WipOperationsSchema = z.preprocess((input) => {
303
321
  options: WipToHtmlOptionsSchema.optional().describe("Conversion options"),
304
322
  }).describe("Convert WIP file to HTML format"),
305
323
  ]));
324
+ const OnchainTableDataSchema = z.preprocess((input) => {
325
+ if (typeof input === 'object' && input !== null && !Array.isArray(input)) {
326
+ const obj = { ...input };
327
+ if (typeof obj.description === 'string' && !obj.query_type) {
328
+ try {
329
+ const parsed = JSON.parse(obj.description);
330
+ if (parsed && typeof parsed === 'object' && parsed.query_type) {
331
+ return parsed;
332
+ }
333
+ }
334
+ catch { }
335
+ }
336
+ if (obj.cursor === '')
337
+ obj.cursor = null;
338
+ if (obj.limit === '')
339
+ obj.limit = null;
340
+ return obj;
341
+ }
342
+ return input;
343
+ }, z.union([
344
+ z.discriminatedUnion("query_type", [
345
+ z.object({
346
+ query_type: z.literal("onchain_table"),
347
+ parent: NameOrAddressSchema.describe("Parent object ID whose dynamic fields table to query"),
348
+ cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor from previous page's nextCursor"),
349
+ limit: z.union([z.number(), z.null()]).optional().describe("Max items per page"),
350
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
351
+ network: EntrypointSchema.optional(),
352
+ }).describe("Paginated query of an on-chain object's dynamic fields table β€” returns items with keys, types, and object IDs. Use to explore all entries (e.g., all orders in a Service, all records in a Repository). Returns: TableAnswer | undefined (items[], nextCursor, hasNextPage)"),
353
+ z.object({
354
+ query_type: z.literal("onchain_table_item_repository_data"),
355
+ parent: NameOrAddressSchema.describe("Parent Repository object ID"),
356
+ name: z.string().describe("Name/key of the record to retrieve from the repository"),
357
+ entity: z.union([AccountOrMark_AddressSchema, z.number()]).describe("Entity ID or address that owns/identifies the record"),
358
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
359
+ network: EntrypointSchema.optional(),
360
+ }).describe("Query a specific record from a Repository's on-chain key-value database by name and entity. Use to read stored data records. Returns: TableItem_RepositoryData | undefined"),
361
+ z.object({
362
+ query_type: z.literal("onchain_table_item_permission_perm"),
363
+ parent: NameOrAddressSchema.describe("Parent Permission object ID"),
364
+ address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User address or Guard ID whose permissions to check"),
365
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
366
+ network: EntrypointSchema.optional(),
367
+ }).describe("Query a permission entry from a Permission object's perm table β€” checks what operations a user/guard is allowed to perform. Use to verify access rights. Returns: TableItem_PermissionPerm | undefined"),
368
+ z.object({
369
+ query_type: z.literal("onchain_table_item_entity_registrar"),
370
+ address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User address to look up in the global EntityRegistrar"),
371
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
372
+ network: EntrypointSchema.optional(),
373
+ }).describe("Query an entity's registration record from the global EntityRegistrar β€” verifies if an address is registered on the blockchain. Use to check registration status and details. Returns: TableItem_EntityRegistrar | undefined"),
374
+ z.object({
375
+ query_type: z.literal("onchain_table_item_entity_linker"),
376
+ address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("Entity address whose community votes/endorsements to query"),
377
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
378
+ network: EntrypointSchema.optional(),
379
+ }).describe("Query community votes/endorsements for an entity from the global EntityLinker β€” shows how others have voted on this entity. Use to check reputation and community trust. Returns: TableItem_EntityLinker | undefined"),
380
+ z.object({
381
+ query_type: z.literal("onchain_table_item_reward_record"),
382
+ parent: NameOrAddressSchema.describe("Parent Reward object ID"),
383
+ address: AccountOrMark_AddressSchema.describe("User address that claimed the reward"),
384
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
385
+ network: EntrypointSchema.optional(),
386
+ }).describe("Query a reward claim record from a Reward object's table β€” checks if a user has claimed a specific incentive. Use to verify reward distribution status. Returns: TableItem_RewardRecord | undefined"),
387
+ ]),
388
+ z.discriminatedUnion("query_type", [
389
+ z.object({
390
+ query_type: z.literal("onchain_table_item_demand_presenter"),
391
+ parent: NameOrAddressSchema.describe("Parent Demand object ID"),
392
+ address: AccountOrMark_AddressSchema.describe("Presenter address that submitted the demand"),
393
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
394
+ network: EntrypointSchema.optional(),
395
+ }).describe("Query a demand submission from a Demand object's table β€” Demands are service requests submitted by users. Use to check a specific demand's details. Returns: TableItem_DemandPresenter | undefined"),
396
+ z.object({
397
+ query_type: z.literal("onchain_table_item_treasury_history"),
398
+ parent: NameOrAddressSchema.describe("Parent Treasury object ID"),
399
+ address: AccountOrMark_AddressSchema.describe("Payment ID whose treasury record to look up"),
400
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
401
+ network: EntrypointSchema.optional(),
402
+ }).describe("Query a payment record from a Treasury's history table by payment ID β€” Treasury manages funds and payment tracking. Use to look up payment details and status. Returns: TableItem_TreasuryHistory | undefined"),
403
+ z.object({
404
+ query_type: z.literal("onchain_table_item_machine_node"),
405
+ parent: NameOrAddressSchema.describe("Parent Machine object ID"),
406
+ key: z.string().describe("Node name (string key) to query in the Machine's workflow definition"),
407
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
408
+ network: EntrypointSchema.optional(),
409
+ }).describe("Query a workflow node definition from a Machine object's table by node name β€” Machines define workflow templates. Use to inspect a specific node's configuration and logic. Returns: TableItem_MachineNode | undefined"),
410
+ z.object({
411
+ query_type: z.literal("onchain_table_item_progress_history"),
412
+ parent: NameOrAddressSchema.describe("Parent Progress object ID"),
413
+ u64: z.union([z.number(), z.string()]).describe("Sequence number (u64) of the progress step to query"),
414
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
415
+ network: EntrypointSchema.optional(),
416
+ }).describe("Query a progress step record from a Progress object's table by sequence number β€” Progress tracks order/workflow execution. Use to check the status of a specific execution step. Returns: TableItem_ProgressHistory | undefined"),
417
+ z.object({
418
+ query_type: z.literal("onchain_table_item_address_mark"),
419
+ parent: NameOrAddressSchema.describe("Parent AddressMark object ID"),
420
+ address: AccountOrMark_AddressSchema.describe("Address whose PUBLIC on-chain name/tags to look up"),
421
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
422
+ network: EntrypointSchema.optional(),
423
+ }).describe("Query a PUBLIC on-chain name/tag mark for an address β€” unlike local marks, these are published on-chain. Use to look up public labels attached to any address. Returns: TableItem_AddressMark | undefined"),
424
+ ]),
425
+ ]));
426
+ const OnchainTableDataResultSchema = z.object({
427
+ result: z.union([
428
+ z.object({ query_type: z.literal("onchain_table"), result: z.union([TableAnswerSchema, z.undefined()]) }),
429
+ z.object({ query_type: z.literal("onchain_table_item_repository_data"), result: z.union([TableItem_RepositoryDataSchema, z.undefined()]) }),
430
+ z.object({ query_type: z.literal("onchain_table_item_permission_perm"), result: z.union([TableItem_PermissionPermSchema, z.undefined()]) }),
431
+ z.object({ query_type: z.literal("onchain_table_item_entity_registrar"), result: z.union([TableItem_EntityRegistrarSchema, z.undefined()]) }),
432
+ z.object({ query_type: z.literal("onchain_table_item_entity_linker"), result: z.union([TableItem_EntityLinkerSchema, z.undefined()]) }),
433
+ z.object({ query_type: z.literal("onchain_table_item_reward_record"), result: z.union([TableItem_RewardRecordSchema, z.undefined()]) }),
434
+ z.object({ query_type: z.literal("onchain_table_item_demand_presenter"), result: z.union([TableItem_DemandPresenterSchema, z.undefined()]) }),
435
+ z.object({ query_type: z.literal("onchain_table_item_treasury_history"), result: z.union([TableItem_TreasuryHistorySchema, z.undefined()]) }),
436
+ z.object({ query_type: z.literal("onchain_table_item_machine_node"), result: z.union([TableItem_MachineNodeSchema, z.undefined()]) }),
437
+ z.object({ query_type: z.literal("onchain_table_item_progress_history"), result: z.union([TableItem_ProgressHistorySchema, z.undefined()]) }),
438
+ z.object({ query_type: z.literal("onchain_table_item_address_mark"), result: z.union([TableItem_AddressMarkSchema, z.undefined()]) }),
439
+ ])
440
+ });
441
+ async function handleOnchainTableData(args) {
442
+ const validated = strictParse(OnchainTableDataSchema, args, "onchain_table_data input");
443
+ let result;
444
+ switch (validated.query_type) {
445
+ case "onchain_table": {
446
+ const queryResult = await query_table({ parent: validated.parent, cursor: validated.cursor, limit: validated.limit, no_cache: validated.no_cache, network: validated.network });
447
+ result = { query_type: "onchain_table", result: queryResult };
448
+ break;
449
+ }
450
+ case "onchain_table_item_repository_data": {
451
+ const queryResult = await queryTableItem_RepositoryData({ parent: validated.parent, name: validated.name, entity: validated.entity, no_cache: validated.no_cache, network: validated.network });
452
+ result = { query_type: "onchain_table_item_repository_data", result: queryResult };
453
+ break;
454
+ }
455
+ case "onchain_table_item_permission_perm": {
456
+ const queryResult = await queryTableItem_PermissionPerm({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
457
+ result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
458
+ break;
459
+ }
460
+ case "onchain_table_item_reward_record": {
461
+ const queryResult = await queryTableItem_RewardRecord({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
462
+ result = { query_type: "onchain_table_item_reward_record", result: queryResult };
463
+ break;
464
+ }
465
+ case "onchain_table_item_demand_presenter": {
466
+ const queryResult = await queryTableItem_DemandPresenter({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
467
+ result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
468
+ break;
469
+ }
470
+ case "onchain_table_item_treasury_history": {
471
+ const queryResult = await queryTableItem_TreasuryHistory({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
472
+ result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
473
+ break;
474
+ }
475
+ case "onchain_table_item_machine_node": {
476
+ const queryResult = await queryTableItem_MachineNode({ parent: validated.parent, key: validated.key, no_cache: validated.no_cache, network: validated.network });
477
+ result = { query_type: "onchain_table_item_machine_node", result: queryResult };
478
+ break;
479
+ }
480
+ case "onchain_table_item_progress_history": {
481
+ const queryResult = await queryTableItem_ProgressHistory({ parent: validated.parent, u64: validated.u64, no_cache: validated.no_cache, network: validated.network });
482
+ result = { query_type: "onchain_table_item_progress_history", result: queryResult };
483
+ break;
484
+ }
485
+ case "onchain_table_item_address_mark": {
486
+ const queryResult = await queryTableItem_AddressMark({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
487
+ result = { query_type: "onchain_table_item_address_mark", result: queryResult };
488
+ break;
489
+ }
490
+ case "onchain_table_item_entity_registrar": {
491
+ const queryResult = await queryTableItem_EntityRegistrar({ address: validated.address, no_cache: validated.no_cache, network: validated.network });
492
+ result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
493
+ break;
494
+ }
495
+ case "onchain_table_item_entity_linker": {
496
+ const queryResult = await queryTableItem_EntityLinker({ address: validated.address, no_cache: validated.no_cache, network: validated.network });
497
+ result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
498
+ break;
499
+ }
500
+ default:
501
+ throw new Error(`Unknown table query type. Valid query_types are: "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"`);
502
+ }
503
+ return {
504
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
505
+ structuredContent: { result },
506
+ };
507
+ }
306
508
  const WatchQueryOperationsSchema = z.preprocess((input) => {
307
509
  if (typeof input === 'object' && input !== null) {
308
510
  const obj = { ...input };
511
+ if (typeof obj.description === 'string' && !obj.query_type) {
512
+ try {
513
+ const parsed = JSON.parse(obj.description);
514
+ if (parsed && typeof parsed === 'object' && parsed.query_type) {
515
+ return parsed;
516
+ }
517
+ }
518
+ catch { }
519
+ }
309
520
  for (const key of ['filter', 'objects', 'env', 'token_type']) {
310
521
  if (typeof obj[key] === 'string') {
311
522
  try {
@@ -317,98 +528,71 @@ const WatchQueryOperationsSchema = z.preprocess((input) => {
317
528
  return obj;
318
529
  }
319
530
  return input;
320
- }, z.discriminatedUnion("query_type", [
321
- z.object({
322
- query_type: z.literal("local_mark_list"),
323
- filter: LocalMarkFilterSchema.optional().describe("Local mark filter"),
324
- }).describe("Query local ID/USER address book with optional filter"),
325
- z.object({
326
- query_type: z.literal("account_list"),
327
- filter: AccountFilterSchema.optional().describe("Account filter"),
328
- }).describe("Query account list with optional filter"),
329
- z.object({
330
- query_type: z.literal("local_info_list"),
331
- filter: LocalInfoFilterSchema.optional().describe("Local info filter"),
332
- }).describe("Query local info list with optional filter"),
333
- z.object({
334
- query_type: z.literal("token_list"),
335
- filter: TokenDataFilterSchema.optional(),
336
- }).describe("Query token list with optional filter"),
337
- z.object({
338
- query_type: z.literal("account_balance"),
339
- name_or_address: NameOrAddressSchema.optional().describe("Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."),
340
- token_type: TokenTypeSchema.optional().describe("Token type; default token type is 0x2::wow::WOW"),
341
- }).describe("Query account balance or coin objects by the token type"),
342
- z.object({
343
- query_type: z.literal("onchain_personal_profile"),
344
- account: NameOrAddressSchema.optional().describe("Account name or ID to query. Use empty string '' for the default account."),
345
- }).describe("Query PUBLIC on-chain personal profile for any account address"),
346
- z.object({
347
- query_type: z.literal("onchain_objects"),
348
- objects: z.array(NameOrAddressSchema).describe("List of object IDs to query"),
349
- }).describe("Query on-chain objects"),
350
- z.object({
351
- query_type: z.literal("onchain_table"),
352
- parent: NameOrAddressSchema,
353
- object_type: ObjectTypeSchema,
354
- }).describe("Query on-chain table data of the specified object"),
355
- z.object({
356
- query_type: z.literal("onchain_table_item_repository_data"),
357
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
358
- name: z.string().describe("Name of the record to query"),
359
- entity: z.union([AccountOrMark_AddressSchema, z.number()]).describe("ID or address of the entity; or address that number is casted to"),
360
- }).describe("Query repository data table item"),
361
- z.object({
362
- query_type: z.literal("onchain_table_item_permission_perm"),
363
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
364
- address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User ID or address, or Guard ID in the permission perm table"),
365
- }).describe("Query permission perm table item"),
366
- z.object({
367
- query_type: z.literal("onchain_table_item_entity_registrar"),
368
- address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User ID or address of the entity"),
369
- }).describe("Query entity registrar table item"),
370
- z.object({
371
- query_type: z.literal("onchain_table_item_entity_linker"),
372
- address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("ID or address that the registrar votes are attached to"),
373
- }).describe("Query entity linker table item"),
374
- z.object({
375
- query_type: z.literal("onchain_table_item_reward_record"),
376
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
377
- address: AccountOrMark_AddressSchema.describe("User ID or address that claims the reward"),
378
- }).describe("Query reward record table item"),
379
- z.object({
380
- query_type: z.literal("onchain_table_item_demand_presenter"),
381
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
382
- address: AccountOrMark_AddressSchema.describe("User ID or address of the Demand presenter"),
383
- }).describe("Query demand presenter table item"),
384
- z.object({
385
- query_type: z.literal("onchain_table_item_treasury_history"),
386
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
387
- address: AccountOrMark_AddressSchema.describe("ID of the payment that the treasury record is attached to"),
388
- }).describe("Query treasury record table item"),
389
- z.object({
390
- query_type: z.literal("onchain_table_item_machine_node"),
391
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
392
- key: z.string().describe("String key of the node name to query"),
393
- }).describe("Query machine node table item"),
394
- z.object({
395
- query_type: z.literal("onchain_table_item_progress_history"),
396
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
397
- u64: z.union([z.number(), z.string()]).describe("U64 value of the record to query"),
398
- }).describe("Query progress history table item"),
399
- z.object({
400
- query_type: z.literal("onchain_table_item_address_mark"),
401
- parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
402
- address: AccountOrMark_AddressSchema.describe("ID or address that the mark name and tags are attached to"),
403
- }).describe("Query address mark table item"),
404
- z.object({
405
- query_type: z.literal("onchain_received"),
406
- object: z.string().describe("Object ID to query"),
407
- all_type: z.boolean().optional().describe("Whether to query all types of received objects"),
408
- }).describe("Query on-chain received balance, payments, and NFTs"),
531
+ }, z.union([
532
+ z.discriminatedUnion("query_type", [
533
+ z.object({
534
+ query_type: z.literal("local_mark_list"),
535
+ filter: LocalMarkFilterSchema.optional().describe("Local mark filter"),
536
+ }).describe("Query your LOCAL address book — maps human-readable names to blockchain addresses with optional tags. Use to resolve names→addresses or find addresses by tag. Returns: MarkData[] (name, address, tags, timestamps)"),
537
+ z.object({
538
+ query_type: z.literal("account_list"),
539
+ filter: AccountFilterSchema.optional().describe("Account filter"),
540
+ }).describe("Query your LOCAL accounts β€” view all accounts stored on this device (addresses, public keys, messenger status, suspension state). Use to discover available accounts before operations. Returns: AccountData[] (name, address, pubkey, suspended, messenger, timestamps)"),
541
+ z.object({
542
+ query_type: z.literal("local_info_list"),
543
+ filter: LocalInfoFilterSchema.optional().describe("Local info filter"),
544
+ }).describe("Query your LOCAL private info β€” sensitive data like delivery addresses, phone numbers, contacts stored ONLY on this device. Use to retrieve saved contact/delivery details. Returns: InfoData[] (name, default value, contents, timestamps)"),
545
+ z.object({
546
+ query_type: z.literal("token_list"),
547
+ filter: TokenDataFilterSchema.optional(),
548
+ }).describe("Query cached token metadata β€” symbol, decimals, icon URL, description for tokens previously fetched from chain. Use to look up token info without an on-chain query. Returns: TokenTypeInfo[] (type, alias, name, symbol, decimals, iconUrl)"),
549
+ z.object({
550
+ query_type: z.literal("account_balance"),
551
+ name_or_address: NameOrAddressSchema.optional().describe("Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."),
552
+ balance: z.boolean().optional().describe("Set to true to query total balance amount for the token type"),
553
+ coin: z.object({
554
+ cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor for listing coin objects"),
555
+ limit: z.union([z.number(), z.null()]).optional().describe("Max coin objects per page"),
556
+ }).optional().describe("Set to query paginated coin objects instead of balance. Use cursor/limit for pagination."),
557
+ token_type: TokenTypeSchema.optional().describe("Token type to query; defaults to 0x2::wow::WOW (platform token)"),
558
+ network: EntrypointSchema.optional(),
559
+ }).describe("Query an account's coin balance OR paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Returns: { address, balance? | coin? }"),
560
+ ]),
561
+ z.discriminatedUnion("query_type", [
562
+ z.object({
563
+ query_type: z.literal("onchain_personal_profile"),
564
+ account: NameOrAddressSchema.optional().describe("Account name or ID to query. Use empty string '' for the default account."),
565
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
566
+ network: EntrypointSchema.optional(),
567
+ }).describe("Query any user's PUBLIC on-chain profile β€” social links, reputation (likes/dislikes), personal info records, voting history, referrer. Use to look up a user's public identity and reputation. Returns: ObjectPersonal | undefined"),
568
+ z.object({
569
+ query_type: z.literal("onchain_objects"),
570
+ objects: z.array(NameOrAddressSchema).describe("List of object IDs (names or addresses) to query in batch"),
571
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
572
+ network: EntrypointSchema.optional(),
573
+ }).describe("Batch query on-chain WOWOK objects by ID or name β€” supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more. Use to inspect one or more objects in a single call. Returns: { objects: ObjectBase[] }"),
574
+ z.object({
575
+ query_type: z.literal("onchain_received"),
576
+ object: z.string().describe("Name or address of the object that received payments/items"),
577
+ all_type: z.boolean().optional().describe("Set to true to query all token types received; defaults to the object's Token type '0x2::payment::CoinWrapper<TOKEN>' (Coins wrapper sent via Payment object). If the object has no Token type, the call will fail."),
578
+ cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor from previous page"),
579
+ limit: z.union([z.number(), z.null()]).optional().describe("Max records per page"),
580
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
581
+ network: EntrypointSchema.optional(),
582
+ }).describe("Query objects (Payments, Tokens, NFTs) received by a specific object. Use to track incoming payments or items sent to an on-chain object. Supports pagination and all_type filter. Returns: ReceivedBalance | ReceivedNormal[]"),
583
+ ]),
409
584
  ]));
410
585
  async function handleOnchainOperations(args) {
411
586
  try {
587
+ if (typeof args === 'object' && args !== null && args.description && !args.operation_type) {
588
+ const hasWrappedParams = typeof args.description === 'string' &&
589
+ (args.description.includes('operation_type') || args.description.includes('data'));
590
+ if (hasWrappedParams) {
591
+ throw new Error("Invalid parameter structure. Parameters should NOT be wrapped in 'description' field.\n" +
592
+ "Correct format: { operation_type: '...', data: {...} }\n" +
593
+ "Incorrect format: { description: '{ operation_type: ... }' }");
594
+ }
595
+ }
412
596
  const validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
413
597
  const env = getEnvConfig(validated.env);
414
598
  switch (validated.operation_type) {
@@ -793,17 +977,17 @@ async function handleWatchQueryOperations(args) {
793
977
  break;
794
978
  }
795
979
  case "account_balance": {
796
- const queryResult = await query_account({ name_or_address: validated.name_or_address, token_type: validated.token_type, balance: true });
980
+ const queryResult = await query_account({ name_or_address: validated.name_or_address, token_type: validated.token_type, balance: validated.balance, coin: validated.coin, network: validated.network });
797
981
  result = { query_type: "account_balance", result: queryResult };
798
982
  break;
799
983
  }
800
984
  case "onchain_personal_profile": {
801
- const queryResult = await query_personal({ account: validated.account });
985
+ const queryResult = await query_personal({ account: validated.account, no_cache: validated.no_cache, network: validated.network });
802
986
  result = { query_type: "onchain_personal_profile", result: queryResult };
803
987
  break;
804
988
  }
805
989
  case "onchain_objects": {
806
- const queryResult = await query_objects({ objects: validated.objects });
990
+ const queryResult = await query_objects({ objects: validated.objects, no_cache: validated.no_cache, network: validated.network });
807
991
  if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
808
992
  queryResult.objects = queryResult.objects.map((obj) => {
809
993
  if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
@@ -824,68 +1008,13 @@ async function handleWatchQueryOperations(args) {
824
1008
  result = { query_type: "onchain_objects", result: queryResult };
825
1009
  break;
826
1010
  }
827
- case "onchain_table": {
828
- const queryResult = await query_table({ parent: validated.parent, object_type: validated.object_type });
829
- result = { query_type: "onchain_table", result: queryResult };
830
- break;
831
- }
832
- case "onchain_table_item_repository_data": {
833
- const queryResult = await queryTableItem_RepositoryData({ parent: validated.parent, name: validated.name, entity: validated.entity });
834
- result = { query_type: "onchain_table_item_repository_data", result: queryResult };
835
- break;
836
- }
837
- case "onchain_table_item_permission_perm": {
838
- const queryResult = await queryTableItem_PermissionPerm({ parent: validated.parent, address: validated.address });
839
- result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
840
- break;
841
- }
842
- case "onchain_table_item_reward_record": {
843
- const queryResult = await queryTableItem_RewardRecord({ parent: validated.parent, address: validated.address });
844
- result = { query_type: "onchain_table_item_reward_record", result: queryResult };
845
- break;
846
- }
847
- case "onchain_table_item_demand_presenter": {
848
- const queryResult = await queryTableItem_DemandPresenter({ parent: validated.parent, address: validated.address });
849
- result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
850
- break;
851
- }
852
- case "onchain_table_item_treasury_history": {
853
- const queryResult = await queryTableItem_TreasuryHistory({ parent: validated.parent, address: validated.address });
854
- result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
855
- break;
856
- }
857
- case "onchain_table_item_machine_node": {
858
- const queryResult = await queryTableItem_MachineNode({ parent: validated.parent, key: validated.key });
859
- result = { query_type: "onchain_table_item_machine_node", result: queryResult };
860
- break;
861
- }
862
- case "onchain_table_item_progress_history": {
863
- const queryResult = await queryTableItem_ProgressHistory({ parent: validated.parent, u64: validated.u64 });
864
- result = { query_type: "onchain_table_item_progress_history", result: queryResult };
865
- break;
866
- }
867
- case "onchain_table_item_address_mark": {
868
- const queryResult = await queryTableItem_AddressMark({ parent: validated.parent, address: validated.address });
869
- result = { query_type: "onchain_table_item_address_mark", result: queryResult };
870
- break;
871
- }
872
- case "onchain_table_item_entity_registrar": {
873
- const queryResult = await queryTableItem_EntityRegistrar({ address: validated.address });
874
- result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
875
- break;
876
- }
877
- case "onchain_table_item_entity_linker": {
878
- const queryResult = await queryTableItem_EntityLinker({ address: validated.address });
879
- result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
880
- break;
881
- }
882
1011
  case "onchain_received": {
883
- const queryResult = await query_received({ object: validated.object, all_type: validated.all_type });
1012
+ const queryResult = await query_received({ object: validated.object, all_type: validated.all_type, cursor: validated.cursor, limit: validated.limit, no_cache: validated.no_cache, network: validated.network });
884
1013
  result = { query_type: "onchain_received", result: queryResult };
885
1014
  break;
886
1015
  }
887
1016
  default:
888
- 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"`);
1017
+ throw new Error(`Unknown query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "onchain_personal_profile", "onchain_objects", "onchain_received". For table queries, use the "onchain_table_data" tool.`);
889
1018
  }
890
1019
  return {
891
1020
  content: [{ type: "text", text: JSON.stringify({ result }) }],
@@ -1209,19 +1338,51 @@ async function main() {
1209
1338
  }, handleMachineNode2File);
1210
1339
  server.registerTool("query_toolkit", {
1211
1340
  title: "πŸ” Data Query Toolkit",
1212
- 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.",
1341
+ description: "WOWOK data query toolkit β€” 8 query types covering local device data and on-chain blockchain data:\n\n"
1342
+ + "LOCAL (device-only, never on-chain):\n"
1343
+ + "1. local_mark_list — Query your LOCAL address book: maps human-readable names to blockchain addresses with optional tags. Use to resolve names→addresses or find addresses by tag.\n"
1344
+ + "2. account_list β€” Query your LOCAL accounts: view all accounts stored on this device (addresses, public keys, messenger status, suspension state). Use to discover available accounts before operations.\n"
1345
+ + "3. local_info_list β€” Query your LOCAL private info: sensitive data like delivery addresses, phone numbers, contacts stored ONLY on this device.\n"
1346
+ + "4. token_list β€” Query cached token metadata: symbol, decimals, icon URL, description for tokens previously fetched from chain. Use to look up token precision/decimals before performing token operations. Returns: TokenTypeInfo[] (type, alias, name, symbol, decimals, iconUrl).\n"
1347
+ + "5. account_balance β€” Query an account's coin balance OR paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Supports multi-token via token_type parameter.\n\n"
1348
+ + "ONCHAIN (blockchain):\n"
1349
+ + "6. onchain_personal_profile β€” Query any user's PUBLIC on-chain profile: social links, reputation (likes/dislikes), personal info records, voting history, referrer.\n"
1350
+ + "7. onchain_objects β€” Batch query on-chain WOWOK objects by ID or name: supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more.\n"
1351
+ + "8. onchain_received β€” Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and all_type filter.\n\n"
1352
+ + "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.",
1213
1353
  inputSchema: WatchQueryOperationsSchema,
1214
- outputSchema: WatchQueryOperationsResultSchema,
1354
+ outputSchema: z.object({
1355
+ result: z.any().describe("Query result β€” type depends on query_type. Local queries return arrays (MarkData[], AccountData[], InfoData[], TokenTypeInfo[]). account_balance returns { address, balance? | coin? }. Onchain queries return typed objects or undefined. onchain_received returns ReceivedBalance | ReceivedNormal[].")
1356
+ }),
1215
1357
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1216
- _meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tables", "tokens", "balance", "profile"]),
1358
+ _meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tokens", "balance", "profile"]),
1217
1359
  }, handleWatchQueryOperations);
1360
+ server.registerTool("onchain_table_data", {
1361
+ title: "πŸ“Š Watch WoWok On-chain Table Data Query",
1362
+ description: "Query dynamic table data of on-chain objects β€” supports paginated table queries and specific table item lookups. Each table item belongs to a parent object type and has a specific meaning:\n\n"
1363
+ + "1. onchain_table β€” Paginated query of ANY object's dynamic fields table (Parent: any object). Returns all entries with keys, types, and object IDs. Use to explore all sub-items of an object.\n"
1364
+ + "2. onchain_table_item_repository_data β€” Query a record from a Repository's on-chain key-value database (Parent: Repository). Key: name + entity (address or number). Returns the stored data record with typed value.\n"
1365
+ + "3. onchain_table_item_permission_perm β€” Query a permission entry from a Permission object's access control table (Parent: Permission). Key: user address or Guard ID. Returns the permission list (perm[]) granted to that user/guard.\n"
1366
+ + "4. onchain_table_item_entity_registrar β€” Query an entity's registration record from the GLOBAL EntityRegistrar (Parent: system EntityRegistrar). Key: user address. Returns registration info: description, referrer, records, mark_object.\n"
1367
+ + "5. onchain_table_item_entity_linker β€” Query community votes/endorsements for an entity from the GLOBAL EntityLinker (Parent: system EntityLinker). Key: entity address. Returns vote records (likes/dislikes) showing community trust.\n"
1368
+ + "6. onchain_table_item_reward_record β€” Query a reward claim record from a Reward object's distribution table (Parent: Reward). Key: recipient address. Returns claim history: guard used, total claimed, per-claim details.\n"
1369
+ + "7. onchain_table_item_demand_presenter β€” Query a demand submission from a Demand object's presenter table (Parent: Demand). Key: presenter address. Returns submission details: recommendation, service, feedback, acceptance score.\n"
1370
+ + "8. onchain_table_item_treasury_history β€” Query a payment record from a Treasury's history table (Parent: Treasury). Key: payment ID (address). Returns payment details: operation type, signer, amount, external guard.\n"
1371
+ + "9. onchain_table_item_machine_node β€” Query a workflow node definition from a Machine object's node table (Parent: Machine). Key: node name (string). Returns node configuration: pairs, forwards, guards, thresholds.\n"
1372
+ + "10. onchain_table_item_progress_history β€” Query a progress step record from a Progress object's history table (Parent: Progress). Key: sequence number (u64). Returns step details: node, next_node, session state, time.\n"
1373
+ + "11. onchain_table_item_address_mark β€” Query a PUBLIC on-chain name/tag mark from an AddressMark object's table (Parent: AddressMark). Key: address. Returns public labels: entity, name, tags[]. Unlike local marks, these are published on-chain.",
1374
+ inputSchema: OnchainTableDataSchema,
1375
+ outputSchema: OnchainTableDataResultSchema,
1376
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1377
+ _meta: createToolMeta("table query", ["on-chain", "table", "dynamic fields", "pagination", "repository", "permission", "reward", "demand", "treasury", "machine", "progress"]),
1378
+ }, handleOnchainTableData);
1218
1379
  server.registerTool("onchain_events", {
1219
- title: "πŸ“… Watch On-chain Events",
1220
- 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.",
1380
+ title: "πŸ“… Watch WoWok On-chain Events",
1381
+ 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.",
1221
1382
  inputSchema: OnchainEventsInputSchema,
1222
1383
  outputSchema: OnchainEventsResultSchema,
1223
1384
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1224
- _meta: createToolMeta("watch events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
1385
+ _meta: createToolMeta("watch wowook events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
1225
1386
  }, handleOnchainEvents);
1226
1387
  server.registerTool("wowok_buildin_info", {
1227
1388
  title: "ℹ️ WoWok Build-in Information",