wowok_agent 2.1.9 → 2.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,11 +8,7 @@ import packageJson from "../package.json" with { type: "json" };
8
8
  // Import schema
9
9
  import { CallService_DataSchema, CallMachine_DataSchema, MachineNode2File_InputSchema, MachineNode2File_OutputWrappedSchema, CallProgress_DataSchema, CallPermission_DataSchema, CallGuard_DataSchema, Guard2File_InputSchema, Guard2File_OutputWrappedSchema, CallArbitration_DataSchema, CallRepository_DataSchema, CallContact_DataSchema, CallTreasury_DataSchema, CallReward_DataSchema, CallAllocation_DataSchema, CallPersonal_DataSchema, CallPayment_DataSchema, CallDemand_DataSchema, CallOrder_DataSchema, CallEnvSchema, SubmissionCallSchema, strictParse, CallOutputSchema, handleCallResult, createServerConfig, createCapabilitiesConfig, createToolMeta, transformSubmission, getEnvConfig, WipGenerationOptionsSchema, WipToHtmlOptionsSchema, TokenDataFilterSchema, LocalInfoFilterSchema, LocalMarkFilterSchema, AccountFilterSchema, TokenTypeSchema, OnchainEventsInputSchema, OnchainEventsResultSchema, ProtocolInfoQuerySchema, ProtocolInfoResultSchema, WatchQueryOperationsResultSchema, NameOrAddressSchema, AccountOrMark_AddressSchema, ObjectTypeSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, MessengerOperationInputSchema, } from "./schema/index.js";
10
10
  // Import wowok SDK
11
- import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, guard2file, parseGuardFile, formatGuardParseErrors, machineNode2file, generate_wip, verify_wip, sign_wip, wip2html, account_operation, local_mark_operation, local_info_operation, watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, query_personal, query_objects, query_table, queryProtocolInfo, query_received, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_events, } from "wowok";
12
- // TODO: Uncomment these once agent/mcp can import these properly
13
- // import {
14
- // blacklist, friendslist, guardlist,
15
- // } from "wowok";
11
+ import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, guard2file, parseGuardFile, formatGuardParseErrors, machineNode2file, generateNodeComments, generate_wip, verify_wip, sign_wip, wip2html, account_operation, local_mark_operation, local_info_operation, watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, query_personal, query_objects, query_table, queryProtocolInfo, query_received, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_events, blacklist, friendslist, guardlist, } from "wowok";
16
12
  // Create server instance
17
13
  const server = new McpServer(createServerConfig(packageJson), createCapabilitiesConfig());
18
14
  // ================================================
@@ -160,7 +156,7 @@ const WatchQueryOperationsSchema = z.discriminatedUnion("query_type", [
160
156
  }).describe("Query token list with optional filter"),
161
157
  z.object({
162
158
  query_type: z.literal("account_balance"),
163
- account: NameOrAddressSchema.optional().describe("Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."),
159
+ name_or_address: NameOrAddressSchema.optional().describe("Account name or address. Use empty string '' for the default account. Defaults to '' if omitted."),
164
160
  token_type: TokenTypeSchema.optional().describe("Token type; default token type is 0x2::wow::WOW"),
165
161
  }).describe("Query account balance or coin objects by the token type"),
166
162
  z.object({
@@ -584,7 +580,7 @@ async function handleWatchQueryOperations(args) {
584
580
  break;
585
581
  }
586
582
  case "account_balance": {
587
- const queryResult = await query_account({ name_or_address: validated.account, token_type: validated.token_type, balance: true });
583
+ const queryResult = await query_account({ name_or_address: validated.name_or_address, token_type: validated.token_type, balance: true });
588
584
  result = { query_type: "account_balance", result: queryResult };
589
585
  break;
590
586
  }
@@ -595,6 +591,24 @@ async function handleWatchQueryOperations(args) {
595
591
  }
596
592
  case "onchain_objects": {
597
593
  const queryResult = await query_objects({ objects: validated.objects });
594
+ // 为 Guard 对象添加指令树说明
595
+ if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
596
+ queryResult.objects = queryResult.objects.map((obj) => {
597
+ if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
598
+ try {
599
+ const nodeComments = generateNodeComments(obj.data.root);
600
+ return {
601
+ ...obj,
602
+ _guard_node_comments: nodeComments
603
+ };
604
+ }
605
+ catch (e) {
606
+ return obj;
607
+ }
608
+ }
609
+ return obj;
610
+ });
611
+ }
598
612
  result = { query_type: "onchain_objects", result: queryResult };
599
613
  break;
600
614
  }
@@ -700,12 +714,36 @@ async function handleMessengerOperation(args) {
700
714
  }
701
715
  case "send_message": {
702
716
  const sendResult = await send_message(validated.from, validated.to, validated.content, validated.options);
703
- result = { operation: "send_message", result: sendResult };
717
+ // Filter out leafHash from merkleData to match schema
718
+ const filteredResult = {
719
+ ...sendResult,
720
+ merkleData: sendResult.merkleData ? {
721
+ leafIndex: sendResult.merkleData.leafIndex,
722
+ prevRoot: sendResult.merkleData.prevRoot,
723
+ newRoot: sendResult.merkleData.newRoot,
724
+ serverSignature: sendResult.merkleData.serverSignature,
725
+ serverTimestamp: sendResult.merkleData.serverTimestamp,
726
+ serverPublicKey: sendResult.merkleData.serverPublicKey,
727
+ } : undefined,
728
+ };
729
+ result = { operation: "send_message", result: filteredResult };
704
730
  break;
705
731
  }
706
732
  case "send_file": {
707
733
  const sendResult = await send_file(validated.from, validated.to, validated.filePath, validated.options);
708
- result = { operation: "send_file", result: sendResult };
734
+ // Filter out leafHash from merkleData to match schema
735
+ const filteredResult = {
736
+ ...sendResult,
737
+ merkleData: sendResult.merkleData ? {
738
+ leafIndex: sendResult.merkleData.leafIndex,
739
+ prevRoot: sendResult.merkleData.prevRoot,
740
+ newRoot: sendResult.merkleData.newRoot,
741
+ serverSignature: sendResult.merkleData.serverSignature,
742
+ serverTimestamp: sendResult.merkleData.serverTimestamp,
743
+ serverPublicKey: sendResult.merkleData.serverPublicKey,
744
+ } : undefined,
745
+ };
746
+ result = { operation: "send_file", result: filteredResult };
709
747
  break;
710
748
  }
711
749
  case "watch_messages": {
@@ -744,33 +782,27 @@ async function handleMessengerOperation(args) {
744
782
  break;
745
783
  }
746
784
  case "blacklist": {
747
- // TODO: Uncomment once blacklist is properly imported
748
- // const blacklistResult = await blacklist({
749
- // account: validated.account,
750
- // ...validated.blacklist
751
- // } as any);
752
- // result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
753
- throw new Error("Blacklist operation is temporarily unavailable. Please re-install agent/mcp dependencies.");
785
+ const blacklistResult = await blacklist({
786
+ account: validated.account,
787
+ ...validated.blacklist
788
+ });
789
+ result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
754
790
  break;
755
791
  }
756
792
  case "friendslist": {
757
- // TODO: Uncomment once friendslist is properly imported
758
- // const friendslistResult = await friendslist({
759
- // account: validated.account,
760
- // ...validated.friendslist
761
- // } as any);
762
- // result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
763
- throw new Error("Friendslist operation is temporarily unavailable. Please re-install agent/mcp dependencies.");
793
+ const friendslistResult = await friendslist({
794
+ account: validated.account,
795
+ ...validated.friendslist
796
+ });
797
+ result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
764
798
  break;
765
799
  }
766
800
  case "guardlist": {
767
- // TODO: Uncomment once guardlist is properly imported
768
- // const guardlistResult = await guardlist({
769
- // account: validated.account,
770
- // ...validated.guardlist
771
- // } as any);
772
- // result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
773
- throw new Error("Guardlist operation is temporarily unavailable. Please re-install agent/mcp dependencies.");
801
+ const guardlistResult = await guardlist({
802
+ account: validated.account,
803
+ ...validated.guardlist
804
+ });
805
+ result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
774
806
  break;
775
807
  }
776
808
  default:
@@ -778,7 +810,7 @@ async function handleMessengerOperation(args) {
778
810
  }
779
811
  return {
780
812
  content: [{ type: "text", text: JSON.stringify(result) }],
781
- structuredContent: result,
813
+ structuredContent: { result },
782
814
  };
783
815
  }
784
816
  // ================================================
@@ -978,7 +1010,8 @@ async function main() {
978
1010
  outputSchema: z.object({
979
1011
  documentation_url: z.string().describe("Official WoWok documentation URL on GitHub"),
980
1012
  topic: z.string().optional().describe("Requested topic if specified"),
981
- message: z.string().describe("Welcome message with documentation information"),
1013
+ original_topic: z.string().optional().describe("Original topic input by user (before normalization)"),
1014
+ message: z.string().describe("Welcome message with documentation information. Always included in response."),
982
1015
  }),
983
1016
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
984
1017
  _meta: createToolMeta("documentation", ["docs", "learn", "tutorial", "guide", "help", "reference"]),
@@ -987,30 +1020,36 @@ async function main() {
987
1020
  if (!args.topic) {
988
1021
  // No topic specified, return base documentation URL
989
1022
  const url = GITHUB_BASE_URL;
1023
+ const message = `Welcome to WoWok Documentation! Access comprehensive guides, tutorials, and API references at: ${url}`;
990
1024
  return {
991
1025
  content: [
992
1026
  {
993
1027
  type: "text",
994
- text: `Welcome to WoWok Documentation! Access comprehensive guides, tutorials, and API references at: ${url}`,
1028
+ text: message,
995
1029
  },
996
1030
  ],
997
1031
  structuredContent: {
998
1032
  documentation_url: url,
1033
+ message: message,
999
1034
  },
1000
1035
  };
1001
1036
  }
1002
- // Topic specified, construct URL
1003
- const url = `${GITHUB_BASE_URL}/${args.topic}.md`;
1037
+ // Topic specified, normalize to lowercase for case-insensitive matching
1038
+ const normalizedTopic = args.topic.toLowerCase().trim();
1039
+ const url = `${GITHUB_BASE_URL}/${normalizedTopic}.md`;
1040
+ const message = `Documentation for "${normalizedTopic}"\nGitHub URL: ${url}`;
1004
1041
  return {
1005
1042
  content: [
1006
1043
  {
1007
1044
  type: "text",
1008
- text: `Documentation for "${args.topic}"\nGitHub URL: ${url}`,
1045
+ text: message,
1009
1046
  },
1010
1047
  ],
1011
1048
  structuredContent: {
1012
1049
  documentation_url: url,
1013
- topic: args.topic,
1050
+ topic: normalizedTopic,
1051
+ original_topic: args.topic,
1052
+ message: message,
1014
1053
  },
1015
1054
  };
1016
1055
  });