wowok_agent 2.2.3 → 2.2.4

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
 
@@ -303,6 +303,181 @@ const WipOperationsSchema = z.preprocess((input) => {
303
303
  options: WipToHtmlOptionsSchema.optional().describe("Conversion options"),
304
304
  }).describe("Convert WIP file to HTML format"),
305
305
  ]));
306
+ const OnchainTableDataSchema = z.preprocess((input) => {
307
+ if (typeof input === 'object' && input !== null && !Array.isArray(input)) {
308
+ const obj = { ...input };
309
+ if (obj.cursor === '')
310
+ obj.cursor = null;
311
+ if (obj.limit === '')
312
+ obj.limit = null;
313
+ return obj;
314
+ }
315
+ return input;
316
+ }, z.union([
317
+ z.discriminatedUnion("query_type", [
318
+ z.object({
319
+ query_type: z.literal("onchain_table"),
320
+ parent: NameOrAddressSchema.describe("Parent object ID whose dynamic fields table to query"),
321
+ cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor from previous page's nextCursor"),
322
+ limit: z.union([z.number(), z.null()]).optional().describe("Max items per page"),
323
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
324
+ network: EntrypointSchema.optional(),
325
+ }).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)"),
326
+ z.object({
327
+ query_type: z.literal("onchain_table_item_repository_data"),
328
+ parent: NameOrAddressSchema.describe("Parent Repository object ID"),
329
+ name: z.string().describe("Name/key of the record to retrieve from the repository"),
330
+ entity: z.union([AccountOrMark_AddressSchema, z.number()]).describe("Entity ID or address that owns/identifies the record"),
331
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
332
+ network: EntrypointSchema.optional(),
333
+ }).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"),
334
+ z.object({
335
+ query_type: z.literal("onchain_table_item_permission_perm"),
336
+ parent: NameOrAddressSchema.describe("Parent Permission object ID"),
337
+ address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User address or Guard ID whose permissions to check"),
338
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
339
+ network: EntrypointSchema.optional(),
340
+ }).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"),
341
+ z.object({
342
+ query_type: z.literal("onchain_table_item_entity_registrar"),
343
+ address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User address to look up in the global EntityRegistrar"),
344
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
345
+ network: EntrypointSchema.optional(),
346
+ }).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"),
347
+ z.object({
348
+ query_type: z.literal("onchain_table_item_entity_linker"),
349
+ address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("Entity address whose community votes/endorsements to query"),
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("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"),
353
+ z.object({
354
+ query_type: z.literal("onchain_table_item_reward_record"),
355
+ parent: NameOrAddressSchema.describe("Parent Reward object ID"),
356
+ address: AccountOrMark_AddressSchema.describe("User address that claimed the reward"),
357
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
358
+ network: EntrypointSchema.optional(),
359
+ }).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"),
360
+ ]),
361
+ z.discriminatedUnion("query_type", [
362
+ z.object({
363
+ query_type: z.literal("onchain_table_item_demand_presenter"),
364
+ parent: NameOrAddressSchema.describe("Parent Demand object ID"),
365
+ address: AccountOrMark_AddressSchema.describe("Presenter address that submitted the demand"),
366
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
367
+ network: EntrypointSchema.optional(),
368
+ }).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"),
369
+ z.object({
370
+ query_type: z.literal("onchain_table_item_treasury_history"),
371
+ parent: NameOrAddressSchema.describe("Parent Treasury object ID"),
372
+ address: AccountOrMark_AddressSchema.describe("Payment ID whose treasury record to look up"),
373
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
374
+ network: EntrypointSchema.optional(),
375
+ }).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"),
376
+ z.object({
377
+ query_type: z.literal("onchain_table_item_machine_node"),
378
+ parent: NameOrAddressSchema.describe("Parent Machine object ID"),
379
+ key: z.string().describe("Node name (string key) to query in the Machine's workflow definition"),
380
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
381
+ network: EntrypointSchema.optional(),
382
+ }).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"),
383
+ z.object({
384
+ query_type: z.literal("onchain_table_item_progress_history"),
385
+ parent: NameOrAddressSchema.describe("Parent Progress object ID"),
386
+ u64: z.union([z.number(), z.string()]).describe("Sequence number (u64) of the progress step to query"),
387
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
388
+ network: EntrypointSchema.optional(),
389
+ }).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"),
390
+ z.object({
391
+ query_type: z.literal("onchain_table_item_address_mark"),
392
+ parent: NameOrAddressSchema.describe("Parent AddressMark object ID"),
393
+ address: AccountOrMark_AddressSchema.describe("Address whose PUBLIC on-chain name/tags to look up"),
394
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
395
+ network: EntrypointSchema.optional(),
396
+ }).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"),
397
+ ]),
398
+ ]));
399
+ const OnchainTableDataResultSchema = z.object({
400
+ result: z.union([
401
+ z.object({ query_type: z.literal("onchain_table"), result: z.union([TableAnswerSchema, z.undefined()]) }),
402
+ z.object({ query_type: z.literal("onchain_table_item_repository_data"), result: z.union([TableItem_RepositoryDataSchema, z.undefined()]) }),
403
+ z.object({ query_type: z.literal("onchain_table_item_permission_perm"), result: z.union([TableItem_PermissionPermSchema, z.undefined()]) }),
404
+ z.object({ query_type: z.literal("onchain_table_item_entity_registrar"), result: z.union([TableItem_EntityRegistrarSchema, z.undefined()]) }),
405
+ z.object({ query_type: z.literal("onchain_table_item_entity_linker"), result: z.union([TableItem_EntityLinkerSchema, z.undefined()]) }),
406
+ z.object({ query_type: z.literal("onchain_table_item_reward_record"), result: z.union([TableItem_RewardRecordSchema, z.undefined()]) }),
407
+ z.object({ query_type: z.literal("onchain_table_item_demand_presenter"), result: z.union([TableItem_DemandPresenterSchema, z.undefined()]) }),
408
+ z.object({ query_type: z.literal("onchain_table_item_treasury_history"), result: z.union([TableItem_TreasuryHistorySchema, z.undefined()]) }),
409
+ z.object({ query_type: z.literal("onchain_table_item_machine_node"), result: z.union([TableItem_MachineNodeSchema, z.undefined()]) }),
410
+ z.object({ query_type: z.literal("onchain_table_item_progress_history"), result: z.union([TableItem_ProgressHistorySchema, z.undefined()]) }),
411
+ z.object({ query_type: z.literal("onchain_table_item_address_mark"), result: z.union([TableItem_AddressMarkSchema, z.undefined()]) }),
412
+ ])
413
+ });
414
+ async function handleOnchainTableData(args) {
415
+ const validated = strictParse(OnchainTableDataSchema, args, "onchain_table_data input");
416
+ let result;
417
+ switch (validated.query_type) {
418
+ case "onchain_table": {
419
+ const queryResult = await query_table({ parent: validated.parent, cursor: validated.cursor, limit: validated.limit, no_cache: validated.no_cache, network: validated.network });
420
+ result = { query_type: "onchain_table", result: queryResult };
421
+ break;
422
+ }
423
+ case "onchain_table_item_repository_data": {
424
+ const queryResult = await queryTableItem_RepositoryData({ parent: validated.parent, name: validated.name, entity: validated.entity, no_cache: validated.no_cache, network: validated.network });
425
+ result = { query_type: "onchain_table_item_repository_data", result: queryResult };
426
+ break;
427
+ }
428
+ case "onchain_table_item_permission_perm": {
429
+ const queryResult = await queryTableItem_PermissionPerm({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
430
+ result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
431
+ break;
432
+ }
433
+ case "onchain_table_item_reward_record": {
434
+ const queryResult = await queryTableItem_RewardRecord({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
435
+ result = { query_type: "onchain_table_item_reward_record", result: queryResult };
436
+ break;
437
+ }
438
+ case "onchain_table_item_demand_presenter": {
439
+ const queryResult = await queryTableItem_DemandPresenter({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
440
+ result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
441
+ break;
442
+ }
443
+ case "onchain_table_item_treasury_history": {
444
+ const queryResult = await queryTableItem_TreasuryHistory({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
445
+ result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
446
+ break;
447
+ }
448
+ case "onchain_table_item_machine_node": {
449
+ const queryResult = await queryTableItem_MachineNode({ parent: validated.parent, key: validated.key, no_cache: validated.no_cache, network: validated.network });
450
+ result = { query_type: "onchain_table_item_machine_node", result: queryResult };
451
+ break;
452
+ }
453
+ case "onchain_table_item_progress_history": {
454
+ const queryResult = await queryTableItem_ProgressHistory({ parent: validated.parent, u64: validated.u64, no_cache: validated.no_cache, network: validated.network });
455
+ result = { query_type: "onchain_table_item_progress_history", result: queryResult };
456
+ break;
457
+ }
458
+ case "onchain_table_item_address_mark": {
459
+ const queryResult = await queryTableItem_AddressMark({ parent: validated.parent, address: validated.address, no_cache: validated.no_cache, network: validated.network });
460
+ result = { query_type: "onchain_table_item_address_mark", result: queryResult };
461
+ break;
462
+ }
463
+ case "onchain_table_item_entity_registrar": {
464
+ const queryResult = await queryTableItem_EntityRegistrar({ address: validated.address, no_cache: validated.no_cache, network: validated.network });
465
+ result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
466
+ break;
467
+ }
468
+ case "onchain_table_item_entity_linker": {
469
+ const queryResult = await queryTableItem_EntityLinker({ address: validated.address, no_cache: validated.no_cache, network: validated.network });
470
+ result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
471
+ break;
472
+ }
473
+ default:
474
+ 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"`);
475
+ }
476
+ return {
477
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
478
+ structuredContent: { result },
479
+ };
480
+ }
306
481
  const WatchQueryOperationsSchema = z.preprocess((input) => {
307
482
  if (typeof input === 'object' && input !== null) {
308
483
  const obj = { ...input };
@@ -317,95 +492,59 @@ const WatchQueryOperationsSchema = z.preprocess((input) => {
317
492
  return obj;
318
493
  }
319
494
  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"),
495
+ }, z.union([
496
+ z.discriminatedUnion("query_type", [
497
+ z.object({
498
+ query_type: z.literal("local_mark_list"),
499
+ filter: LocalMarkFilterSchema.optional().describe("Local mark filter"),
500
+ }).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)"),
501
+ z.object({
502
+ query_type: z.literal("account_list"),
503
+ filter: AccountFilterSchema.optional().describe("Account filter"),
504
+ }).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)"),
505
+ z.object({
506
+ query_type: z.literal("local_info_list"),
507
+ filter: LocalInfoFilterSchema.optional().describe("Local info filter"),
508
+ }).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)"),
509
+ z.object({
510
+ query_type: z.literal("token_list"),
511
+ filter: TokenDataFilterSchema.optional(),
512
+ }).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)"),
513
+ z.object({
514
+ query_type: z.literal("account_balance"),
515
+ name_or_address: NameOrAddressSchema.optional().describe("Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."),
516
+ balance: z.boolean().optional().describe("Set to true to query total balance amount for the token type"),
517
+ coin: z.object({
518
+ cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor for listing coin objects"),
519
+ limit: z.union([z.number(), z.null()]).optional().describe("Max coin objects per page"),
520
+ }).optional().describe("Set to query paginated coin objects instead of balance. Use cursor/limit for pagination."),
521
+ token_type: TokenTypeSchema.optional().describe("Token type to query; defaults to 0x2::wow::WOW (platform token)"),
522
+ network: EntrypointSchema.optional(),
523
+ }).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? }"),
524
+ ]),
525
+ z.discriminatedUnion("query_type", [
526
+ z.object({
527
+ query_type: z.literal("onchain_personal_profile"),
528
+ account: NameOrAddressSchema.optional().describe("Account name or ID to query. Use empty string '' for the default account."),
529
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
530
+ network: EntrypointSchema.optional(),
531
+ }).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"),
532
+ z.object({
533
+ query_type: z.literal("onchain_objects"),
534
+ objects: z.array(NameOrAddressSchema).describe("List of object IDs (names or addresses) to query in batch"),
535
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
536
+ network: EntrypointSchema.optional(),
537
+ }).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[] }"),
538
+ z.object({
539
+ query_type: z.literal("onchain_received"),
540
+ object: z.string().describe("Name or address of the object that received payments/items"),
541
+ 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."),
542
+ cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor from previous page"),
543
+ limit: z.union([z.number(), z.null()]).optional().describe("Max records per page"),
544
+ no_cache: z.boolean().optional().describe("Set to true to bypass cache and fetch fresh on-chain data"),
545
+ network: EntrypointSchema.optional(),
546
+ }).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[]"),
547
+ ]),
409
548
  ]));
410
549
  async function handleOnchainOperations(args) {
411
550
  try {
@@ -793,17 +932,17 @@ async function handleWatchQueryOperations(args) {
793
932
  break;
794
933
  }
795
934
  case "account_balance": {
796
- const queryResult = await query_account({ name_or_address: validated.name_or_address, token_type: validated.token_type, balance: true });
935
+ 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
936
  result = { query_type: "account_balance", result: queryResult };
798
937
  break;
799
938
  }
800
939
  case "onchain_personal_profile": {
801
- const queryResult = await query_personal({ account: validated.account });
940
+ const queryResult = await query_personal({ account: validated.account, no_cache: validated.no_cache, network: validated.network });
802
941
  result = { query_type: "onchain_personal_profile", result: queryResult };
803
942
  break;
804
943
  }
805
944
  case "onchain_objects": {
806
- const queryResult = await query_objects({ objects: validated.objects });
945
+ const queryResult = await query_objects({ objects: validated.objects, no_cache: validated.no_cache, network: validated.network });
807
946
  if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
808
947
  queryResult.objects = queryResult.objects.map((obj) => {
809
948
  if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
@@ -824,68 +963,13 @@ async function handleWatchQueryOperations(args) {
824
963
  result = { query_type: "onchain_objects", result: queryResult };
825
964
  break;
826
965
  }
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
966
  case "onchain_received": {
883
- const queryResult = await query_received({ object: validated.object, all_type: validated.all_type });
967
+ 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
968
  result = { query_type: "onchain_received", result: queryResult };
885
969
  break;
886
970
  }
887
971
  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"`);
972
+ 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
973
  }
890
974
  return {
891
975
  content: [{ type: "text", text: JSON.stringify({ result }) }],
@@ -1209,19 +1293,51 @@ async function main() {
1209
1293
  }, handleMachineNode2File);
1210
1294
  server.registerTool("query_toolkit", {
1211
1295
  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.",
1296
+ description: "WOWOK data query toolkit 8 query types covering local device data and on-chain blockchain data:\n\n"
1297
+ + "LOCAL (device-only, never on-chain):\n"
1298
+ + "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"
1299
+ + "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"
1300
+ + "3. local_info_list — Query your LOCAL private info: sensitive data like delivery addresses, phone numbers, contacts stored ONLY on this device.\n"
1301
+ + "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"
1302
+ + "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"
1303
+ + "ONCHAIN (blockchain):\n"
1304
+ + "6. onchain_personal_profile — Query any user's PUBLIC on-chain profile: social links, reputation (likes/dislikes), personal info records, voting history, referrer.\n"
1305
+ + "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"
1306
+ + "8. onchain_received — Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and all_type filter.\n\n"
1307
+ + "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.",
1213
1308
  inputSchema: WatchQueryOperationsSchema,
1214
- outputSchema: WatchQueryOperationsResultSchema,
1309
+ outputSchema: z.object({
1310
+ 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[].")
1311
+ }),
1215
1312
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1216
- _meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tables", "tokens", "balance", "profile"]),
1313
+ _meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tokens", "balance", "profile"]),
1217
1314
  }, handleWatchQueryOperations);
1315
+ server.registerTool("onchain_table_data", {
1316
+ title: "📊 Watch WoWok On-chain Table Data Query",
1317
+ 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"
1318
+ + "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"
1319
+ + "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"
1320
+ + "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"
1321
+ + "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"
1322
+ + "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"
1323
+ + "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"
1324
+ + "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"
1325
+ + "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"
1326
+ + "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"
1327
+ + "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"
1328
+ + "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.",
1329
+ inputSchema: OnchainTableDataSchema,
1330
+ outputSchema: OnchainTableDataResultSchema,
1331
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1332
+ _meta: createToolMeta("table query", ["on-chain", "table", "dynamic fields", "pagination", "repository", "permission", "reward", "demand", "treasury", "machine", "progress"]),
1333
+ }, handleOnchainTableData);
1218
1334
  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.",
1335
+ title: "📅 Watch WoWok On-chain Events",
1336
+ 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
1337
  inputSchema: OnchainEventsInputSchema,
1222
1338
  outputSchema: OnchainEventsResultSchema,
1223
1339
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
1224
- _meta: createToolMeta("watch events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
1340
+ _meta: createToolMeta("watch wowook events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
1225
1341
  }, handleOnchainEvents);
1226
1342
  server.registerTool("wowok_buildin_info", {
1227
1343
  title: "ℹ️ WoWok Build-in Information",