wowok_agent 1.6.6 â 2.1.9
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/README.md +20 -40
- package/dist/index.d.ts +6 -27
- package/dist/index.js +1026 -27
- package/dist/schema/call/allocation.d.ts +8 -0
- package/dist/schema/call/allocation.js +27 -0
- package/dist/schema/call/arbitration.d.ts +27 -0
- package/dist/schema/call/arbitration.js +106 -0
- package/dist/schema/call/base.d.ts +41 -0
- package/dist/schema/call/base.js +152 -0
- package/dist/schema/call/contact.d.ts +9 -0
- package/dist/schema/call/contact.js +41 -0
- package/dist/schema/call/demand.d.ts +10 -0
- package/dist/schema/call/demand.js +51 -0
- package/dist/schema/call/guard.d.ts +15 -0
- package/dist/schema/call/guard.js +67 -0
- package/dist/schema/call/handler.d.ts +80 -0
- package/dist/schema/call/handler.js +177 -0
- package/dist/schema/call/index.d.ts +18 -0
- package/dist/schema/call/index.js +19 -0
- package/dist/schema/call/machine.d.ts +23 -0
- package/dist/schema/call/machine.js +164 -0
- package/dist/schema/call/order.d.ts +11 -0
- package/dist/schema/call/order.js +39 -0
- package/dist/schema/call/payment.d.ts +7 -0
- package/dist/schema/call/payment.js +20 -0
- package/dist/schema/call/permission.d.ts +27 -0
- package/dist/schema/call/permission.js +118 -0
- package/dist/schema/call/personal.d.ts +27 -0
- package/dist/schema/call/personal.js +81 -0
- package/dist/schema/call/progress.d.ts +6 -0
- package/dist/schema/call/progress.js +37 -0
- package/dist/schema/call/proof.d.ts +7 -0
- package/dist/schema/call/proof.js +27 -0
- package/dist/schema/call/repository.d.ts +15 -0
- package/dist/schema/call/repository.js +85 -0
- package/dist/schema/call/reward.d.ts +7 -0
- package/dist/schema/call/reward.js +46 -0
- package/dist/schema/call/service.d.ts +7 -0
- package/dist/schema/call/service.js +87 -0
- package/dist/schema/call/treasury.d.ts +6 -0
- package/dist/schema/call/treasury.js +76 -0
- package/dist/schema/common/index.d.ts +57 -0
- package/dist/schema/common/index.js +331 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/index.js +8 -0
- package/dist/schema/local/index.d.ts +120 -0
- package/dist/schema/local/index.js +913 -0
- package/dist/schema/local/wip.d.ts +33 -0
- package/dist/schema/local/wip.js +229 -0
- package/dist/schema/messenger/index.d.ts +34 -0
- package/dist/schema/messenger/index.js +407 -0
- package/dist/schema/query/index.d.ts +240 -0
- package/dist/schema/query/index.js +1313 -0
- package/dist/schema/utils/guard-parser.d.ts +20 -0
- package/dist/schema/utils/guard-parser.js +410 -0
- package/dist/schema/utils/guard-query-utils.d.ts +5 -0
- package/dist/schema/utils/guard-query-utils.js +22 -0
- package/dist/schema/utils/node-parser.d.ts +59 -0
- package/dist/schema/utils/node-parser.js +382 -0
- package/dist/schema/utils/permission-index-utils.d.ts +2 -0
- package/dist/schema/utils/permission-index-utils.js +10 -0
- package/package.json +31 -49
- package/LICENSE +0 -201
- package/dist/call/arbitration.d.ts +0 -57
- package/dist/call/arbitration.d.ts.map +0 -1
- package/dist/call/arbitration.js +0 -245
- package/dist/call/arbitration.js.map +0 -1
- package/dist/call/base.d.ts +0 -85
- package/dist/call/base.d.ts.map +0 -1
- package/dist/call/base.js +0 -231
- package/dist/call/base.js.map +0 -1
- package/dist/call/call.d.ts +0 -95
- package/dist/call/call.d.ts.map +0 -1
- package/dist/call/call.js +0 -149
- package/dist/call/call.js.map +0 -1
- package/dist/call/demand.d.ts +0 -46
- package/dist/call/demand.d.ts.map +0 -1
- package/dist/call/demand.js +0 -201
- package/dist/call/demand.js.map +0 -1
- package/dist/call/guard.d.ts +0 -53
- package/dist/call/guard.d.ts.map +0 -1
- package/dist/call/guard.js +0 -386
- package/dist/call/guard.js.map +0 -1
- package/dist/call/machine.d.ts +0 -97
- package/dist/call/machine.d.ts.map +0 -1
- package/dist/call/machine.js +0 -342
- package/dist/call/machine.js.map +0 -1
- package/dist/call/object_permission.d.ts +0 -14
- package/dist/call/object_permission.d.ts.map +0 -1
- package/dist/call/object_permission.js +0 -59
- package/dist/call/object_permission.js.map +0 -1
- package/dist/call/permission.d.ts +0 -63
- package/dist/call/permission.d.ts.map +0 -1
- package/dist/call/permission.js +0 -137
- package/dist/call/permission.js.map +0 -1
- package/dist/call/personal.d.ts +0 -47
- package/dist/call/personal.d.ts.map +0 -1
- package/dist/call/personal.js +0 -119
- package/dist/call/personal.js.map +0 -1
- package/dist/call/repository.d.ts +0 -117
- package/dist/call/repository.d.ts.map +0 -1
- package/dist/call/repository.js +0 -408
- package/dist/call/repository.js.map +0 -1
- package/dist/call/service.d.ts +0 -115
- package/dist/call/service.d.ts.map +0 -1
- package/dist/call/service.js +0 -550
- package/dist/call/service.js.map +0 -1
- package/dist/call/treasury.d.ts +0 -46
- package/dist/call/treasury.d.ts.map +0 -1
- package/dist/call/treasury.js +0 -222
- package/dist/call/treasury.js.map +0 -1
- package/dist/common.d.ts +0 -12
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -71
- package/dist/common.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/local/.d.ts +0 -20
- package/dist/local/.d.ts.map +0 -1
- package/dist/local/.js +0 -76
- package/dist/local/.js.map +0 -1
- package/dist/local/account.d.ts +0 -42
- package/dist/local/account.d.ts.map +0 -1
- package/dist/local/account.js +0 -335
- package/dist/local/account.js.map +0 -1
- package/dist/local/cache.d.ts +0 -32
- package/dist/local/cache.d.ts.map +0 -1
- package/dist/local/cache.js +0 -77
- package/dist/local/cache.js.map +0 -1
- package/dist/local/coin.d.ts +0 -22
- package/dist/local/coin.d.ts.map +0 -1
- package/dist/local/coin.js +0 -123
- package/dist/local/coin.js.map +0 -1
- package/dist/local/config.d.ts +0 -20
- package/dist/local/config.d.ts.map +0 -1
- package/dist/local/config.js +0 -75
- package/dist/local/config.js.map +0 -1
- package/dist/local/index.d.ts +0 -110
- package/dist/local/index.d.ts.map +0 -1
- package/dist/local/index.js +0 -122
- package/dist/local/index.js.map +0 -1
- package/dist/local/local.d.ts +0 -55
- package/dist/local/local.d.ts.map +0 -1
- package/dist/local/local.js +0 -248
- package/dist/local/local.js.map +0 -1
- package/dist/query/events.d.ts +0 -65
- package/dist/query/events.d.ts.map +0 -1
- package/dist/query/events.js +0 -75
- package/dist/query/events.js.map +0 -1
- package/dist/query/objects.d.ts +0 -346
- package/dist/query/objects.d.ts.map +0 -1
- package/dist/query/objects.js +0 -472
- package/dist/query/objects.js.map +0 -1
- package/dist/query/permission.d.ts +0 -15
- package/dist/query/permission.d.ts.map +0 -1
- package/dist/query/permission.js +0 -45
- package/dist/query/permission.js.map +0 -1
- package/dist/query/received.d.ts +0 -16
- package/dist/query/received.d.ts.map +0 -1
- package/dist/query/received.js +0 -16
- package/dist/query/received.js.map +0 -1
- package/dist/schema/call.d.ts +0 -13005
- package/dist/schema/call.d.ts.map +0 -1
- package/dist/schema/call.js +0 -997
- package/dist/schema/call.js.map +0 -1
- package/dist/schema/const.d.ts +0 -254
- package/dist/schema/const.d.ts.map +0 -1
- package/dist/schema/const.js +0 -305
- package/dist/schema/const.js.map +0 -1
- package/dist/schema/local.d.ts +0 -702
- package/dist/schema/local.d.ts.map +0 -1
- package/dist/schema/local.js +0 -150
- package/dist/schema/local.js.map +0 -1
- package/dist/schema/query.d.ts +0 -1465
- package/dist/schema/query.d.ts.map +0 -1
- package/dist/schema/query.js +0 -224
- package/dist/schema/query.js.map +0 -1
- package/dist/schema/util.d.ts +0 -71
- package/dist/schema/util.d.ts.map +0 -1
- package/dist/schema/util.js +0 -139
- package/dist/schema/util.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,27 +1,1026 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
import { resolve } from "path";
|
|
7
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
8
|
+
// Import schema
|
|
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
|
+
// 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";
|
|
16
|
+
// Create server instance
|
|
17
|
+
const server = new McpServer(createServerConfig(packageJson), createCapabilitiesConfig());
|
|
18
|
+
// ================================================
|
|
19
|
+
// Schema Definitions
|
|
20
|
+
// ================================================
|
|
21
|
+
// On-chain Operations Schema (Merged from Merchant and Personal Operations)
|
|
22
|
+
const OnchainOperationsSchema = z.discriminatedUnion("operation_type", [
|
|
23
|
+
// Merchant Operations
|
|
24
|
+
z.object({
|
|
25
|
+
operation_type: z.literal("service"),
|
|
26
|
+
data: CallService_DataSchema,
|
|
27
|
+
env: CallEnvSchema.optional(),
|
|
28
|
+
submission: SubmissionCallSchema.optional(),
|
|
29
|
+
}).describe("đĒ Service Object: Create and manage product/service listings with transparent promises, bind workflow templates to order processing, set pricing, issue discount coupons to customers, and establish quality standards, etc.."),
|
|
30
|
+
z.object({
|
|
31
|
+
operation_type: z.literal("machine"),
|
|
32
|
+
data: CallMachine_DataSchema,
|
|
33
|
+
json_or_markdown_file: z.string().optional().describe("Path to a JSON or Markdown file containing the node definition. File content will be parsed and used to set nodes. If parsing fails, error will include line number and node information."),
|
|
34
|
+
env: CallEnvSchema.optional(),
|
|
35
|
+
submission: SubmissionCallSchema.optional(),
|
|
36
|
+
}).describe("âī¸ Machine Object: Design and deploy automated workflow templates (Machines) that define how services are delivered, etc.."),
|
|
37
|
+
z.object({
|
|
38
|
+
operation_type: z.literal("progress"),
|
|
39
|
+
data: CallProgress_DataSchema,
|
|
40
|
+
env: CallEnvSchema.optional(),
|
|
41
|
+
submission: SubmissionCallSchema.optional(),
|
|
42
|
+
}).describe("đ Progress Object: Track and manage active workflows in real-time."),
|
|
43
|
+
z.object({
|
|
44
|
+
operation_type: z.literal("repository"),
|
|
45
|
+
data: CallRepository_DataSchema,
|
|
46
|
+
env: CallEnvSchema.optional(),
|
|
47
|
+
submission: SubmissionCallSchema.optional(),
|
|
48
|
+
}).describe("đĻ Repository Object: Read/write database with consensus field + address as key, strongly-typed data as value."),
|
|
49
|
+
z.object({
|
|
50
|
+
operation_type: z.literal("arbitration"),
|
|
51
|
+
data: CallArbitration_DataSchema,
|
|
52
|
+
env: CallEnvSchema.optional(),
|
|
53
|
+
submission: SubmissionCallSchema.optional(),
|
|
54
|
+
}).describe("âī¸ Arbitration Object: Access a transparent on-chain arbitration system for resolving order conflicts."),
|
|
55
|
+
z.object({
|
|
56
|
+
operation_type: z.literal("contact"),
|
|
57
|
+
data: CallContact_DataSchema,
|
|
58
|
+
env: CallEnvSchema.optional(),
|
|
59
|
+
submission: SubmissionCallSchema.optional(),
|
|
60
|
+
}).describe("đŦ Contact Object: Manage on-chain instant messaging contact profiles."),
|
|
61
|
+
z.object({
|
|
62
|
+
operation_type: z.literal("treasury"),
|
|
63
|
+
data: CallTreasury_DataSchema,
|
|
64
|
+
env: CallEnvSchema.optional(),
|
|
65
|
+
submission: SubmissionCallSchema.optional(),
|
|
66
|
+
}).describe("đ° Treasury Object: Create and manage treasury for team funds with deposit/withdrawal rules, etc.."),
|
|
67
|
+
z.object({
|
|
68
|
+
operation_type: z.literal("reward"),
|
|
69
|
+
data: CallReward_DataSchema,
|
|
70
|
+
env: CallEnvSchema.optional(),
|
|
71
|
+
submission: SubmissionCallSchema.optional(),
|
|
72
|
+
}).describe("đ Reward Object: Create reward pools and set claim conditions by Guard verification."),
|
|
73
|
+
z.object({
|
|
74
|
+
operation_type: z.literal("allocation"),
|
|
75
|
+
data: CallAllocation_DataSchema,
|
|
76
|
+
env: CallEnvSchema.optional(),
|
|
77
|
+
submission: SubmissionCallSchema.optional(),
|
|
78
|
+
}).describe("đ¤ Allocation Object: Create distribution plans to auto-distribute funds to multiple recipients."),
|
|
79
|
+
z.object({
|
|
80
|
+
operation_type: z.literal("permission"),
|
|
81
|
+
data: CallPermission_DataSchema,
|
|
82
|
+
env: CallEnvSchema.optional(),
|
|
83
|
+
}).describe("đ Permission Object: Define who can perform which operations on WoWok objects. Important Note: If needed, you should first query 'guard instructions' through the 'wowok_buildin_info' tool."),
|
|
84
|
+
z.object({
|
|
85
|
+
operation_type: z.literal("guard"),
|
|
86
|
+
data: CallGuard_DataSchema,
|
|
87
|
+
env: CallEnvSchema.optional(),
|
|
88
|
+
}).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."),
|
|
89
|
+
// Personal Operations
|
|
90
|
+
z.object({
|
|
91
|
+
operation_type: z.literal("personal"),
|
|
92
|
+
data: CallPersonal_DataSchema,
|
|
93
|
+
env: CallEnvSchema.optional(),
|
|
94
|
+
}).describe("đ Public Identity Profile: Establish and manage your on-chain public identity. â ī¸ CRITICAL: Everything here is PERMANENTLY PUBLIC on the blockchain!"),
|
|
95
|
+
z.object({
|
|
96
|
+
operation_type: z.literal("payment"),
|
|
97
|
+
data: CallPayment_DataSchema,
|
|
98
|
+
env: CallEnvSchema.optional(),
|
|
99
|
+
}).describe("đ° Payment Object: Send instant, irreversible coin transfers to any wallet address."),
|
|
100
|
+
z.object({
|
|
101
|
+
operation_type: z.literal("demand"),
|
|
102
|
+
data: CallDemand_DataSchema,
|
|
103
|
+
env: CallEnvSchema.optional(),
|
|
104
|
+
submission: SubmissionCallSchema.optional(),
|
|
105
|
+
}).describe("đ¯ Demand Object: Post service requests with reward pools on-chain."),
|
|
106
|
+
z.object({
|
|
107
|
+
operation_type: z.literal("order"),
|
|
108
|
+
data: CallOrder_DataSchema,
|
|
109
|
+
env: CallEnvSchema.optional(),
|
|
110
|
+
submission: SubmissionCallSchema.optional(),
|
|
111
|
+
}).describe("đĻ Order Object: Manage the order lifecycle, Including operating order arbitration (Arb Object associated with the order), advancing progress (Progress Object associated with the order), extracting order refunds/payments, setting agents, etc."),
|
|
112
|
+
z.object({
|
|
113
|
+
operation_type: z.literal("gen_passport"),
|
|
114
|
+
guard: z.string().describe("Guard object ID to verify and generate passport from"),
|
|
115
|
+
info: SubmissionCallSchema.optional().describe("Optional submission data. If not provided, will attempt to get existing submissions from the guard."),
|
|
116
|
+
env: CallEnvSchema.optional(),
|
|
117
|
+
}).describe("đ Generate Verified Passport Object: Create immutable verified credentials after Guard validation passes."),
|
|
118
|
+
]);
|
|
119
|
+
// WIP Operations Schema
|
|
120
|
+
const WipOperationsSchema = z.discriminatedUnion("type", [
|
|
121
|
+
z.object({
|
|
122
|
+
type: z.literal("generate"),
|
|
123
|
+
options: WipGenerationOptionsSchema.describe("WIP generation options"),
|
|
124
|
+
outputPath: z.string().describe("Output file path (.wip file). If file exists, it will be overwritten"),
|
|
125
|
+
}).describe("Generate WIP file from markdown text and optional images"),
|
|
126
|
+
z.object({
|
|
127
|
+
type: z.literal("verify"),
|
|
128
|
+
wipFilePath: z.string().describe("WIP file path to verify. Supports: 1) Local file path (e.g., '/path/to/file.wip', 'C:\\Users\\name\\doc.wip'), 2) Network URL (e.g., 'https://example.com/doc.wip', 'http://site.com/file.wip'), 3) Data URL (e.g., 'data:application/json;base64,eyJ3aXAiOi...')"),
|
|
129
|
+
hash_equal: z.string().optional().describe("Optional expected hash value. If provided, the function will first verify if the file's hash matches this value. If not matched, returns hash mismatch error."),
|
|
130
|
+
}).describe("Verify WIP file integrity and signatures"),
|
|
131
|
+
z.object({
|
|
132
|
+
type: z.literal("sign"),
|
|
133
|
+
wipFilePath: z.string().describe("WIP file path to sign. Supports: 1) Local file path (e.g., '/path/to/file.wip'), 2) Network URL (e.g., 'https://example.com/doc.wip'). The file will be loaded, validated, and signed"),
|
|
134
|
+
account: z.string().optional().describe("Signing account (account name or address). If not specified, uses default account"),
|
|
135
|
+
outputPath: z.string().optional().describe("Output file path. If not specified, adds 'signed_' prefix to original file name (e.g., 'doc.wip' becomes 'signed_doc.wip')"),
|
|
136
|
+
}).describe("Sign WIP file with account"),
|
|
137
|
+
z.object({
|
|
138
|
+
type: z.literal("wip2html"),
|
|
139
|
+
wipPath: z.string().describe("WIP file path or directory path. Supports: 1) Single WIP file (e.g., '/path/to/file.wip'), 2) Directory containing .wip files (e.g., '/path/to/wips/'), 3) Network URL (e.g., 'https://example.com/doc.wip'). When directory is provided, all .wip files in the directory will be converted to HTML"),
|
|
140
|
+
options: WipToHtmlOptionsSchema.optional().describe("Conversion options"),
|
|
141
|
+
}).describe("Convert WIP file to HTML format"),
|
|
142
|
+
]);
|
|
143
|
+
// Watch Query Operations Schema
|
|
144
|
+
const WatchQueryOperationsSchema = z.discriminatedUnion("query_type", [
|
|
145
|
+
z.object({
|
|
146
|
+
query_type: z.literal("local_mark_list"),
|
|
147
|
+
filter: LocalMarkFilterSchema.optional().describe("Local mark filter"),
|
|
148
|
+
}).describe("Query local ID/USER address book with optional filter"),
|
|
149
|
+
z.object({
|
|
150
|
+
query_type: z.literal("account_list"),
|
|
151
|
+
filter: AccountFilterSchema.optional().describe("Account filter"),
|
|
152
|
+
}).describe("Query account list with optional filter"),
|
|
153
|
+
z.object({
|
|
154
|
+
query_type: z.literal("local_info_list"),
|
|
155
|
+
filter: LocalInfoFilterSchema.optional().describe("Local info filter"),
|
|
156
|
+
}).describe("Query local info list with optional filter"),
|
|
157
|
+
z.object({
|
|
158
|
+
query_type: z.literal("token_list"),
|
|
159
|
+
filter: TokenDataFilterSchema.optional(),
|
|
160
|
+
}).describe("Query token list with optional filter"),
|
|
161
|
+
z.object({
|
|
162
|
+
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."),
|
|
164
|
+
token_type: TokenTypeSchema.optional().describe("Token type; default token type is 0x2::wow::WOW"),
|
|
165
|
+
}).describe("Query account balance or coin objects by the token type"),
|
|
166
|
+
z.object({
|
|
167
|
+
query_type: z.literal("onchain_personal_profile"),
|
|
168
|
+
account: NameOrAddressSchema.optional().describe("Account name or ID to query. Use empty string '' for the default account."),
|
|
169
|
+
}).describe("Query PUBLIC on-chain personal profile for any account address"),
|
|
170
|
+
z.object({
|
|
171
|
+
query_type: z.literal("onchain_objects"),
|
|
172
|
+
objects: z.array(NameOrAddressSchema).describe("List of object IDs to query"),
|
|
173
|
+
}).describe("Query on-chain objects"),
|
|
174
|
+
z.object({
|
|
175
|
+
query_type: z.literal("onchain_table"),
|
|
176
|
+
parent: NameOrAddressSchema,
|
|
177
|
+
object_type: ObjectTypeSchema,
|
|
178
|
+
}).describe("Query on-chain table data of the specified object"),
|
|
179
|
+
z.object({
|
|
180
|
+
query_type: z.literal("onchain_table_item_repository_data"),
|
|
181
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
182
|
+
name: z.string().describe("Name of the record to query"),
|
|
183
|
+
entity: z.union([AccountOrMark_AddressSchema, z.number()]).describe("ID or address of the entity; or address that number is casted to"),
|
|
184
|
+
}).describe("Query repository data table item"),
|
|
185
|
+
z.object({
|
|
186
|
+
query_type: z.literal("onchain_table_item_permission_perm"),
|
|
187
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
188
|
+
address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User ID or address, or Guard ID in the permission perm table"),
|
|
189
|
+
}).describe("Query permission perm table item"),
|
|
190
|
+
z.object({
|
|
191
|
+
query_type: z.literal("onchain_table_item_entity_registrar"),
|
|
192
|
+
address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("User ID or address of the entity"),
|
|
193
|
+
}).describe("Query entity registrar table item"),
|
|
194
|
+
z.object({
|
|
195
|
+
query_type: z.literal("onchain_table_item_entity_linker"),
|
|
196
|
+
address: z.union([AccountOrMark_AddressSchema, z.string()]).describe("ID or address that the registrar votes are attached to"),
|
|
197
|
+
}).describe("Query entity linker table item"),
|
|
198
|
+
z.object({
|
|
199
|
+
query_type: z.literal("onchain_table_item_reward_record"),
|
|
200
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
201
|
+
address: AccountOrMark_AddressSchema.describe("User ID or address that claims the reward"),
|
|
202
|
+
}).describe("Query reward record table item"),
|
|
203
|
+
z.object({
|
|
204
|
+
query_type: z.literal("onchain_table_item_demand_presenter"),
|
|
205
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
206
|
+
address: AccountOrMark_AddressSchema.describe("User ID or address of the Demand presenter"),
|
|
207
|
+
}).describe("Query demand presenter table item"),
|
|
208
|
+
z.object({
|
|
209
|
+
query_type: z.literal("onchain_table_item_treasury_history"),
|
|
210
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
211
|
+
address: AccountOrMark_AddressSchema.describe("ID of the payment that the treasury record is attached to"),
|
|
212
|
+
}).describe("Query treasury record table item"),
|
|
213
|
+
z.object({
|
|
214
|
+
query_type: z.literal("onchain_table_item_machine_node"),
|
|
215
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
216
|
+
key: z.string().describe("String key of the node name to query"),
|
|
217
|
+
}).describe("Query machine node table item"),
|
|
218
|
+
z.object({
|
|
219
|
+
query_type: z.literal("onchain_table_item_progress_history"),
|
|
220
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
221
|
+
u64: z.union([z.number(), z.string()]).describe("U64 value of the record to query"),
|
|
222
|
+
}).describe("Query progress history table item"),
|
|
223
|
+
z.object({
|
|
224
|
+
query_type: z.literal("onchain_table_item_address_mark"),
|
|
225
|
+
parent: NameOrAddressSchema.describe("Parent object ID of the data table to query"),
|
|
226
|
+
address: AccountOrMark_AddressSchema.describe("ID or address that the mark name and tags are attached to"),
|
|
227
|
+
}).describe("Query address mark table item"),
|
|
228
|
+
z.object({
|
|
229
|
+
query_type: z.literal("onchain_received"),
|
|
230
|
+
object: z.string().describe("Object ID to query"),
|
|
231
|
+
all_type: z.boolean().optional().describe("Whether to query all types of received objects"),
|
|
232
|
+
}).describe("Query on-chain received balance, payments, and NFTs"),
|
|
233
|
+
]);
|
|
234
|
+
// ================================================
|
|
235
|
+
// Handler Functions
|
|
236
|
+
// ================================================
|
|
237
|
+
async function handleOnchainOperations(args) {
|
|
238
|
+
console.log("=== handleOnchainOperations ===");
|
|
239
|
+
console.log("args:", JSON.stringify(args, null, 2));
|
|
240
|
+
try {
|
|
241
|
+
const validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
|
|
242
|
+
console.log("validated:", JSON.stringify(validated, null, 2));
|
|
243
|
+
const env = getEnvConfig(validated.env);
|
|
244
|
+
switch (validated.operation_type) {
|
|
245
|
+
// Merchant Operations
|
|
246
|
+
case "service": {
|
|
247
|
+
const callService = new CallService(validated.data);
|
|
248
|
+
const result = validated.submission
|
|
249
|
+
? await callService.call_with_submission(env, transformSubmission(validated.submission))
|
|
250
|
+
: await callService.call(env);
|
|
251
|
+
return handleCallResult(result);
|
|
252
|
+
}
|
|
253
|
+
case "machine": {
|
|
254
|
+
// Handle json_or_markdown_file if provided
|
|
255
|
+
if (validated.json_or_markdown_file !== undefined) {
|
|
256
|
+
let fileContent;
|
|
257
|
+
try {
|
|
258
|
+
const filePath = resolve(validated.json_or_markdown_file);
|
|
259
|
+
fileContent = readFileSync(filePath, 'utf-8');
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
throw new Error(`Failed to read file '${validated.json_or_markdown_file}': ${e.message}`);
|
|
263
|
+
}
|
|
264
|
+
const parseResult = parseMachineNodesFromText(fileContent);
|
|
265
|
+
if (!parseResult.success) {
|
|
266
|
+
const errorMessages = formatMachineNodeErrors(parseResult.errors);
|
|
267
|
+
throw new Error(`Machine node validation failed for file '${validated.json_or_markdown_file}':\n\n${errorMessages}`);
|
|
268
|
+
}
|
|
269
|
+
if (!parseResult.data) {
|
|
270
|
+
throw new Error(`No nodes found in file '${validated.json_or_markdown_file}'`);
|
|
271
|
+
}
|
|
272
|
+
// Set the parsed nodes in the data
|
|
273
|
+
validated.data.node = {
|
|
274
|
+
op: "set",
|
|
275
|
+
nodes: parseResult.data,
|
|
276
|
+
bReplace: true
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const callMachine = new CallMachine(validated.data);
|
|
280
|
+
const result = validated.submission
|
|
281
|
+
? await callMachine.call_with_submission(env, transformSubmission(validated.submission))
|
|
282
|
+
: await callMachine.call(env);
|
|
283
|
+
return handleCallResult(result);
|
|
284
|
+
}
|
|
285
|
+
case "progress": {
|
|
286
|
+
const callProgress = new CallProgress(validated.data);
|
|
287
|
+
const result = validated.submission
|
|
288
|
+
? await callProgress.call_with_submission(env, transformSubmission(validated.submission))
|
|
289
|
+
: await callProgress.call(env);
|
|
290
|
+
return handleCallResult(result);
|
|
291
|
+
}
|
|
292
|
+
case "repository": {
|
|
293
|
+
const callRepository = new CallRepository(validated.data);
|
|
294
|
+
const result = validated.submission
|
|
295
|
+
? await callRepository.call_with_submission(env, transformSubmission(validated.submission))
|
|
296
|
+
: await callRepository.call(env);
|
|
297
|
+
return handleCallResult(result);
|
|
298
|
+
}
|
|
299
|
+
case "arbitration": {
|
|
300
|
+
const callArbitration = new CallArbitration(validated.data);
|
|
301
|
+
const result = validated.submission
|
|
302
|
+
? await callArbitration.call_with_submission(env, transformSubmission(validated.submission))
|
|
303
|
+
: await callArbitration.call(env);
|
|
304
|
+
return handleCallResult(result);
|
|
305
|
+
}
|
|
306
|
+
case "contact": {
|
|
307
|
+
const callContact = new CallContact(validated.data);
|
|
308
|
+
const result = validated.submission
|
|
309
|
+
? await callContact.call_with_submission(env, transformSubmission(validated.submission))
|
|
310
|
+
: await callContact.call(env);
|
|
311
|
+
return handleCallResult(result);
|
|
312
|
+
}
|
|
313
|
+
case "treasury": {
|
|
314
|
+
const callTreasury = new CallTreasury(validated.data);
|
|
315
|
+
const result = validated.submission
|
|
316
|
+
? await callTreasury.call_with_submission(env, transformSubmission(validated.submission))
|
|
317
|
+
: await callTreasury.call(env);
|
|
318
|
+
return handleCallResult(result);
|
|
319
|
+
}
|
|
320
|
+
case "reward": {
|
|
321
|
+
const callReward = new CallReward(validated.data);
|
|
322
|
+
const result = validated.submission
|
|
323
|
+
? await callReward.call_with_submission(env, transformSubmission(validated.submission))
|
|
324
|
+
: await callReward.call(env);
|
|
325
|
+
return handleCallResult(result);
|
|
326
|
+
}
|
|
327
|
+
case "allocation": {
|
|
328
|
+
const callAllocation = new CallAllocation(validated.data);
|
|
329
|
+
const result = validated.submission
|
|
330
|
+
? await callAllocation.call_with_submission(env, transformSubmission(validated.submission))
|
|
331
|
+
: await callAllocation.call(env);
|
|
332
|
+
return handleCallResult(result);
|
|
333
|
+
}
|
|
334
|
+
case "permission": {
|
|
335
|
+
const callPermission = new CallPermission(validated.data);
|
|
336
|
+
const result = await callPermission.call(env);
|
|
337
|
+
return handleCallResult(result);
|
|
338
|
+
}
|
|
339
|
+
case "guard": {
|
|
340
|
+
const validatedData = validated.data;
|
|
341
|
+
// å¤į root.type === "file" įæ
åĩīŧäģæäģļå čŊŊ Guard åŽäš
|
|
342
|
+
if (validatedData.root?.type === "file") {
|
|
343
|
+
const filePath = resolve(validatedData.root.file_path);
|
|
344
|
+
let fileContent;
|
|
345
|
+
try {
|
|
346
|
+
fileContent = readFileSync(filePath, 'utf-8');
|
|
347
|
+
}
|
|
348
|
+
catch (e) {
|
|
349
|
+
throw new Error(`Failed to read Guard definition file '${validatedData.root.file_path}': ${e.message}`);
|
|
350
|
+
}
|
|
351
|
+
// äŊŋ፠SDK į parseGuardFile įģä¸č§Ŗæīŧæ¯æ JSON å Markdownīŧ
|
|
352
|
+
const parseResult = parseGuardFile(fileContent, validatedData.root.format);
|
|
353
|
+
if (!parseResult.success) {
|
|
354
|
+
const errorMessages = formatGuardParseErrors(parseResult.errors);
|
|
355
|
+
throw new Error(`Guard validation failed for file '${validatedData.root.file_path}':\n\n${errorMessages}`);
|
|
356
|
+
}
|
|
357
|
+
const fileData = parseResult.data;
|
|
358
|
+
// ååšļæäģļæ°æŽå፿ˇæäžįčĻįåæŽĩ
|
|
359
|
+
// ፿ˇæäžįåæŽĩäŧå
įē§éĢäēæäģļå
厚
|
|
360
|
+
validatedData.root = { type: "node", node: fileData.root };
|
|
361
|
+
if (fileData.table !== undefined && validatedData.table === undefined) {
|
|
362
|
+
validatedData.table = fileData.table;
|
|
363
|
+
}
|
|
364
|
+
if (fileData.description !== undefined && validatedData.description === undefined) {
|
|
365
|
+
validatedData.description = fileData.description;
|
|
366
|
+
}
|
|
367
|
+
if (fileData.rely !== undefined && validatedData.rely === undefined) {
|
|
368
|
+
validatedData.rely = fileData.rely;
|
|
369
|
+
}
|
|
370
|
+
if (fileData.namedNew !== undefined && validatedData.namedNew === undefined) {
|
|
371
|
+
validatedData.namedNew = fileData.namedNew;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// čŊŦæĸ root æ ŧåŧīŧåĻæ root.type === "node"īŧæå node åæŽĩäŊä¸ēåŽé
į root
|
|
375
|
+
// å ä¸ē SDK ææį´æĨį GuardNodeīŧč䏿¯å
čŖ
įģæ { type: "node", node: GuardNode }
|
|
376
|
+
if (validatedData.root && typeof validatedData.root === 'object') {
|
|
377
|
+
const rootObj = validatedData.root;
|
|
378
|
+
if (rootObj.type === 'node' && rootObj.node) {
|
|
379
|
+
validatedData.root = rootObj.node;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// éĒč¯åŋ
éįåæŽĩ
|
|
383
|
+
if (!validatedData.table || validatedData.table.length === 0) {
|
|
384
|
+
throw new Error("Guard 'table' field is required and cannot be empty");
|
|
385
|
+
}
|
|
386
|
+
if (!validatedData.root) {
|
|
387
|
+
throw new Error("Guard 'root' field is required");
|
|
388
|
+
}
|
|
389
|
+
const callGuard = new CallGuard(validatedData);
|
|
390
|
+
const result = await callGuard.call(env);
|
|
391
|
+
return handleCallResult(result);
|
|
392
|
+
}
|
|
393
|
+
// Personal Operations
|
|
394
|
+
case "personal": {
|
|
395
|
+
const callPersonal = new CallPersonal(validated.data);
|
|
396
|
+
const result = await callPersonal.call(env);
|
|
397
|
+
return handleCallResult(result);
|
|
398
|
+
}
|
|
399
|
+
case "payment": {
|
|
400
|
+
const callPayment = new CallPayment(validated.data);
|
|
401
|
+
const result = await callPayment.call(env);
|
|
402
|
+
return handleCallResult(result);
|
|
403
|
+
}
|
|
404
|
+
case "demand": {
|
|
405
|
+
const callDemand = new CallDemand(validated.data);
|
|
406
|
+
const result = validated.submission
|
|
407
|
+
? await callDemand.call_with_submission(env, transformSubmission(validated.submission))
|
|
408
|
+
: await callDemand.call(env);
|
|
409
|
+
return handleCallResult(result);
|
|
410
|
+
}
|
|
411
|
+
case "order": {
|
|
412
|
+
const callOrder = new CallOrder(validated.data);
|
|
413
|
+
const result = validated.submission
|
|
414
|
+
? await callOrder.call_with_submission(env, transformSubmission(validated.submission))
|
|
415
|
+
: await callOrder.call(env);
|
|
416
|
+
return handleCallResult(result);
|
|
417
|
+
}
|
|
418
|
+
case "gen_passport": {
|
|
419
|
+
const result = await gen_passport(env, validated.guard, validated.info);
|
|
420
|
+
return handleCallResult(result);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
throw new Error(`Unknown on-chain operation type: ${validated.operation_type}`);
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
427
|
+
return {
|
|
428
|
+
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
429
|
+
structuredContent: {
|
|
430
|
+
message: `Error: ${errorMessage}`,
|
|
431
|
+
result: {
|
|
432
|
+
type: "error",
|
|
433
|
+
error: errorMessage,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
async function handleAccountOperation(args) {
|
|
440
|
+
try {
|
|
441
|
+
const validated = strictParse(AccountOperationSchema, args, "account_operation input");
|
|
442
|
+
const result = await account_operation(validated);
|
|
443
|
+
return {
|
|
444
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
445
|
+
structuredContent: {
|
|
446
|
+
result: {
|
|
447
|
+
status: "success",
|
|
448
|
+
data: result,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
455
|
+
return {
|
|
456
|
+
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
457
|
+
structuredContent: {
|
|
458
|
+
result: {
|
|
459
|
+
status: "error",
|
|
460
|
+
error: errorMessage,
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async function handleMarkOperation(args) {
|
|
467
|
+
try {
|
|
468
|
+
const validated = strictParse(LocalMarkOperationSchema, args, "local_mark_operation input");
|
|
469
|
+
const result = await local_mark_operation(validated);
|
|
470
|
+
return {
|
|
471
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
472
|
+
structuredContent: {
|
|
473
|
+
result: {
|
|
474
|
+
status: "success",
|
|
475
|
+
data: result,
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
catch (error) {
|
|
481
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
482
|
+
return {
|
|
483
|
+
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
484
|
+
structuredContent: {
|
|
485
|
+
result: {
|
|
486
|
+
status: "error",
|
|
487
|
+
error: errorMessage,
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
async function handleInfoOperation(args) {
|
|
494
|
+
try {
|
|
495
|
+
const validated = strictParse(LocalInfoOperationSchema, args, "local_info_operation input");
|
|
496
|
+
const result = await local_info_operation(validated);
|
|
497
|
+
return {
|
|
498
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
499
|
+
structuredContent: {
|
|
500
|
+
result: {
|
|
501
|
+
status: "success",
|
|
502
|
+
data: result,
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
catch (error) {
|
|
508
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
509
|
+
return {
|
|
510
|
+
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
511
|
+
structuredContent: {
|
|
512
|
+
result: {
|
|
513
|
+
status: "error",
|
|
514
|
+
error: errorMessage,
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
async function handleWipOperations(args) {
|
|
521
|
+
const validated = strictParse(WipOperationsSchema, args, "wip_file input");
|
|
522
|
+
let structuredContent;
|
|
523
|
+
switch (validated.type) {
|
|
524
|
+
case "generate": {
|
|
525
|
+
const result = await generate_wip(validated.options, validated.outputPath);
|
|
526
|
+
structuredContent = { result: { type: "generate", filePath: result } };
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
case "verify": {
|
|
530
|
+
const result = await verify_wip(validated.wipFilePath, validated.hash_equal);
|
|
531
|
+
structuredContent = { result: { type: "verify", ...result } };
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
case "sign": {
|
|
535
|
+
const result = await sign_wip(validated.wipFilePath, validated.account, validated.outputPath);
|
|
536
|
+
structuredContent = { result: { type: "sign", filePath: result } };
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
case "wip2html": {
|
|
540
|
+
const result = await wip2html(validated.wipPath, validated.options);
|
|
541
|
+
let output = { type: "wip2html" };
|
|
542
|
+
if (typeof result === "string") {
|
|
543
|
+
output.html = result;
|
|
544
|
+
}
|
|
545
|
+
else if (Array.isArray(result)) {
|
|
546
|
+
output.files = result;
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
output.html = String(result);
|
|
550
|
+
}
|
|
551
|
+
structuredContent = { result: output };
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
default:
|
|
555
|
+
throw new Error("Unknown WIP operation type");
|
|
556
|
+
}
|
|
557
|
+
return {
|
|
558
|
+
content: [{ type: "text", text: JSON.stringify(structuredContent) }],
|
|
559
|
+
structuredContent,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
async function handleWatchQueryOperations(args) {
|
|
563
|
+
const validated = strictParse(WatchQueryOperationsSchema, args, "watch_and_query input");
|
|
564
|
+
let result;
|
|
565
|
+
switch (validated.query_type) {
|
|
566
|
+
case "local_mark_list": {
|
|
567
|
+
const queryResult = await query_local_mark_list(validated.filter || {});
|
|
568
|
+
result = { query_type: "local_mark_list", result: queryResult };
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
case "account_list": {
|
|
572
|
+
const queryResult = await query_account_list(validated.filter);
|
|
573
|
+
result = { query_type: "account_list", result: queryResult };
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
case "local_info_list": {
|
|
577
|
+
const queryResult = await query_local_info_list(validated.filter);
|
|
578
|
+
result = { query_type: "local_info_list", result: queryResult };
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
case "token_list": {
|
|
582
|
+
const queryResult = await query_local_token_list(validated.filter || {});
|
|
583
|
+
result = { query_type: "token_list", result: queryResult };
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
case "account_balance": {
|
|
587
|
+
const queryResult = await query_account({ name_or_address: validated.account, token_type: validated.token_type, balance: true });
|
|
588
|
+
result = { query_type: "account_balance", result: queryResult };
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
case "onchain_personal_profile": {
|
|
592
|
+
const queryResult = await query_personal({ account: validated.account });
|
|
593
|
+
result = { query_type: "onchain_personal_profile", result: queryResult };
|
|
594
|
+
break;
|
|
595
|
+
}
|
|
596
|
+
case "onchain_objects": {
|
|
597
|
+
const queryResult = await query_objects({ objects: validated.objects });
|
|
598
|
+
result = { query_type: "onchain_objects", result: queryResult };
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
case "onchain_table": {
|
|
602
|
+
const queryResult = await query_table({ parent: validated.parent, object_type: validated.object_type });
|
|
603
|
+
result = { query_type: "onchain_table", result: queryResult };
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
case "onchain_table_item_repository_data": {
|
|
607
|
+
const queryResult = await queryTableItem_RepositoryData({ parent: validated.parent, name: validated.name, entity: validated.entity });
|
|
608
|
+
result = { query_type: "onchain_table_item_repository_data", result: queryResult };
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
case "onchain_table_item_permission_perm": {
|
|
612
|
+
const queryResult = await queryTableItem_PermissionPerm({ parent: validated.parent, address: validated.address });
|
|
613
|
+
result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
case "onchain_table_item_reward_record": {
|
|
617
|
+
const queryResult = await queryTableItem_RewardRecord({ parent: validated.parent, address: validated.address });
|
|
618
|
+
result = { query_type: "onchain_table_item_reward_record", result: queryResult };
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
case "onchain_table_item_demand_presenter": {
|
|
622
|
+
const queryResult = await queryTableItem_DemandPresenter({ parent: validated.parent, address: validated.address });
|
|
623
|
+
result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
case "onchain_table_item_treasury_history": {
|
|
627
|
+
const queryResult = await queryTableItem_TreasuryHistory({ parent: validated.parent, address: validated.address });
|
|
628
|
+
result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
case "onchain_table_item_machine_node": {
|
|
632
|
+
const queryResult = await queryTableItem_MachineNode({ parent: validated.parent, key: validated.key });
|
|
633
|
+
result = { query_type: "onchain_table_item_machine_node", result: queryResult };
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
case "onchain_table_item_progress_history": {
|
|
637
|
+
const queryResult = await queryTableItem_ProgressHistory({ parent: validated.parent, u64: validated.u64 });
|
|
638
|
+
result = { query_type: "onchain_table_item_progress_history", result: queryResult };
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
case "onchain_table_item_address_mark": {
|
|
642
|
+
const queryResult = await queryTableItem_AddressMark({ parent: validated.parent, address: validated.address });
|
|
643
|
+
result = { query_type: "onchain_table_item_address_mark", result: queryResult };
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
case "onchain_table_item_entity_registrar": {
|
|
647
|
+
const queryResult = await queryTableItem_EntityRegistrar({ address: validated.address });
|
|
648
|
+
result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
case "onchain_table_item_entity_linker": {
|
|
652
|
+
const queryResult = await queryTableItem_EntityLinker({ address: validated.address });
|
|
653
|
+
result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
case "onchain_received": {
|
|
657
|
+
const queryResult = await query_received({ object: validated.object, all_type: validated.all_type });
|
|
658
|
+
result = { query_type: "onchain_received", result: queryResult };
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
default:
|
|
662
|
+
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"`);
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
666
|
+
structuredContent: { result },
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
async function handleWowokInfo(args) {
|
|
670
|
+
const validated = strictParse(ProtocolInfoQuerySchema, args, "wowok_buildin_info input");
|
|
671
|
+
const queryResult = await queryProtocolInfo(validated);
|
|
672
|
+
return {
|
|
673
|
+
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
674
|
+
structuredContent: { result: queryResult },
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
async function handleOnchainEvents(args) {
|
|
678
|
+
const validated = strictParse(OnchainEventsInputSchema, args, "onchain_events input");
|
|
679
|
+
const queryResult = await query_events({
|
|
680
|
+
type: validated.type,
|
|
681
|
+
cursor: validated.cursor ?? null,
|
|
682
|
+
limit: validated.limit ?? null,
|
|
683
|
+
order: validated.order ?? null,
|
|
684
|
+
no_cache: validated.no_cache,
|
|
685
|
+
network: validated.network,
|
|
686
|
+
});
|
|
687
|
+
return {
|
|
688
|
+
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
689
|
+
structuredContent: { result: queryResult },
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
async function handleMessengerOperation(args) {
|
|
693
|
+
const validated = strictParse(MessengerOperationInputSchema, args, "messenger_operation input");
|
|
694
|
+
let result;
|
|
695
|
+
switch (validated.operation) {
|
|
696
|
+
case "watch_conversations": {
|
|
697
|
+
const conversations = await watch_conversations(validated.account);
|
|
698
|
+
result = { operation: "watch_conversations", result: conversations };
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
case "send_message": {
|
|
702
|
+
const sendResult = await send_message(validated.from, validated.to, validated.content, validated.options);
|
|
703
|
+
result = { operation: "send_message", result: sendResult };
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
case "send_file": {
|
|
707
|
+
const sendResult = await send_file(validated.from, validated.to, validated.filePath, validated.options);
|
|
708
|
+
result = { operation: "send_file", result: sendResult };
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
case "watch_messages": {
|
|
712
|
+
const messages = await watch_messages(validated.filter);
|
|
713
|
+
result = { operation: "watch_messages", result: messages };
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
case "extract_zip_messages": {
|
|
717
|
+
const extractedPaths = await extract_zip_messages(validated.account, validated.messages, validated.outputDir);
|
|
718
|
+
result = { operation: "extract_zip_messages", result: extractedPaths };
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
case "generate_wts": {
|
|
722
|
+
const wtsResult = await generate_wts(validated.params);
|
|
723
|
+
result = { operation: "generate_wts", result: wtsResult };
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
case "verify_wts": {
|
|
727
|
+
const verifyResult = await verify_wts(validated.wtsFilePath);
|
|
728
|
+
result = { operation: "verify_wts", result: verifyResult };
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
case "sign_wts": {
|
|
732
|
+
const signedPath = await sign_wts(validated.wtsFilePath, validated.account, validated.outputPath);
|
|
733
|
+
result = { operation: "sign_wts", result: signedPath };
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
case "wts2html": {
|
|
737
|
+
const htmlResult = await wts2html(validated.wtsPath, validated.options);
|
|
738
|
+
result = { operation: "wts2html", result: htmlResult };
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
case "proof_message": {
|
|
742
|
+
const proofResult = await proof_message(validated.account, validated.messageId, validated.network);
|
|
743
|
+
result = { operation: "proof_message", result: proofResult };
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
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.");
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
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.");
|
|
764
|
+
break;
|
|
765
|
+
}
|
|
766
|
+
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.");
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
default:
|
|
777
|
+
throw new Error(`Unknown messenger operation: ${validated.operation}`);
|
|
778
|
+
}
|
|
779
|
+
return {
|
|
780
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
781
|
+
structuredContent: result,
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
// ================================================
|
|
785
|
+
// Guard2File Tool Handler
|
|
786
|
+
// ================================================
|
|
787
|
+
async function handleGuard2File(args) {
|
|
788
|
+
const validated = strictParse(Guard2File_InputSchema, args, "guard2file input");
|
|
789
|
+
const env = getEnvConfig(validated.env);
|
|
790
|
+
try {
|
|
791
|
+
// Call guard2file function from SDK
|
|
792
|
+
await guard2file(validated.guard, validated.file_path, validated.format || "json", env.network);
|
|
793
|
+
// Return success result
|
|
794
|
+
const result = {
|
|
795
|
+
result: {
|
|
796
|
+
status: "success",
|
|
797
|
+
data: {
|
|
798
|
+
file_path: resolve(validated.file_path),
|
|
799
|
+
format: validated.format || "json",
|
|
800
|
+
guard_object: validated.guard,
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
};
|
|
804
|
+
return {
|
|
805
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
806
|
+
structuredContent: result,
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
catch (error) {
|
|
810
|
+
// Return error result
|
|
811
|
+
const result = {
|
|
812
|
+
result: {
|
|
813
|
+
status: "error",
|
|
814
|
+
error: error.message,
|
|
815
|
+
},
|
|
816
|
+
};
|
|
817
|
+
return {
|
|
818
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
819
|
+
structuredContent: result,
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
// ================================================
|
|
824
|
+
// MachineNode2File Tool Handler
|
|
825
|
+
// ================================================
|
|
826
|
+
async function handleMachineNode2File(args) {
|
|
827
|
+
const validated = strictParse(MachineNode2File_InputSchema, args, "machineNode2file input");
|
|
828
|
+
const env = getEnvConfig(validated.env);
|
|
829
|
+
try {
|
|
830
|
+
// Call machineNode2file function from SDK
|
|
831
|
+
await machineNode2file(validated.machine, validated.file_path, validated.format || "json", env.network);
|
|
832
|
+
// Return success result
|
|
833
|
+
const result = {
|
|
834
|
+
result: {
|
|
835
|
+
status: "success",
|
|
836
|
+
data: {
|
|
837
|
+
file_path: resolve(validated.file_path),
|
|
838
|
+
format: validated.format || "json",
|
|
839
|
+
machine_object: validated.machine,
|
|
840
|
+
node_count: 0, // SDK function doesn't return node count, but we can add it later
|
|
841
|
+
},
|
|
842
|
+
},
|
|
843
|
+
};
|
|
844
|
+
return {
|
|
845
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
846
|
+
structuredContent: result,
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
catch (error) {
|
|
850
|
+
// Return error result
|
|
851
|
+
const result = {
|
|
852
|
+
result: {
|
|
853
|
+
status: "error",
|
|
854
|
+
error: error.message,
|
|
855
|
+
},
|
|
856
|
+
};
|
|
857
|
+
return {
|
|
858
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
859
|
+
structuredContent: result,
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
// ================================================
|
|
864
|
+
// Schema Query Tool Handler
|
|
865
|
+
// ================================================
|
|
866
|
+
// Export Schema Definitions for Tool Schema Query
|
|
867
|
+
// ================================================
|
|
868
|
+
export { OnchainOperationsSchema, WipOperationsSchema, WatchQueryOperationsSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, ProtocolInfoQuerySchema, CallOutputSchema, MessengerOperationInputSchema, MessengerOperationOutputSchema };
|
|
869
|
+
// ================================================
|
|
870
|
+
// Main Function - Register All Tools
|
|
871
|
+
// ================================================
|
|
872
|
+
async function main() {
|
|
873
|
+
// Unified On-chain Operations Tool (Merged from Merchant and Personal Operations)
|
|
874
|
+
server.registerTool("onchain_operations", {
|
|
875
|
+
title: "âī¸ On-chain Operations",
|
|
876
|
+
description: "On-chain operations for WoWok object: service (marketplace listings), machine (workflow templates), progress (order tracking), repository (on-chain database), arbitration (dispute resolution), contact (IM management), treasury (team funds), reward (incentive pools), allocation (auto-distribution), permission (access control), guard (programmable trust rules), personal (public profile), payment (direct coin transfers), demand (service requests), order (order management), gen_passport (verified credentials).",
|
|
877
|
+
inputSchema: OnchainOperationsSchema,
|
|
878
|
+
outputSchema: CallOutputSchema,
|
|
879
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
880
|
+
_meta: createToolMeta("operation", ["service", "machine", "progress", "repository", "arbitration", "contact", "treasury", "reward", "allocation", "permission", "guard", "personal", "payment", "demand", "order", "gen_passport", "on-chain", "blockchain"]),
|
|
881
|
+
}, handleOnchainOperations);
|
|
882
|
+
// Account Operation Tool (Local)
|
|
883
|
+
server.registerTool("account_operation", {
|
|
884
|
+
title: "đ LOCAL ONLY: Account - Wallet Management",
|
|
885
|
+
description: "đ 100% LOCAL, NEVER ON-CHAIN đ Manage WoWok accounts locally on device: generate, suspend, resume, faucet-test, operate assets, sign data, etc.",
|
|
886
|
+
inputSchema: AccountOperationSchema,
|
|
887
|
+
outputSchema: AccountOperationOutputWrappedSchema,
|
|
888
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
889
|
+
_meta: createToolMeta("operation", ["account", "local", "private", "wallet", "off-chain"]),
|
|
890
|
+
}, handleAccountOperation);
|
|
891
|
+
// Local Mark Operation Tool
|
|
892
|
+
server.registerTool("local_mark_operation", {
|
|
893
|
+
title: "đ LOCAL ONLY: LocalMark - Address Book Management",
|
|
894
|
+
description: "100% LOCAL, NEVER ON-CHAIN đ Manage ID names and tags stored ONLY on your local device for easy identification of user address or object IDs by name.",
|
|
895
|
+
inputSchema: LocalMarkOperationSchema,
|
|
896
|
+
outputSchema: LocalMarkOperationOutputWrappedSchema,
|
|
897
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
898
|
+
_meta: createToolMeta("operation", ["mark", "local", "private", "address-book", "off-chain"]),
|
|
899
|
+
}, handleMarkOperation);
|
|
900
|
+
// Local Info Operation Tool
|
|
901
|
+
server.registerTool("local_info_operation", {
|
|
902
|
+
title: "đ LOCAL ONLY: LocalInfo - Private Data Management",
|
|
903
|
+
description: "100% LOCAL, NEVER ON-CHAIN đ Manage sensitive personal information stored ONLY on your device: delivery addresses, phone numbers, contacts.",
|
|
904
|
+
inputSchema: LocalInfoOperationSchema,
|
|
905
|
+
outputSchema: LocalInfoOperationOutputWrappedSchema,
|
|
906
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
907
|
+
_meta: createToolMeta("operation", ["info", "local", "private", "data-management", "off-chain"]),
|
|
908
|
+
}, handleInfoOperation);
|
|
909
|
+
// WIP File Operations Tool
|
|
910
|
+
server.registerTool("wip_file", {
|
|
911
|
+
title: "đ¤ Witness Information Promise File Operations",
|
|
912
|
+
description: "generate (create WIP files from markdown and images), verify (integrity check), sign (add signatures), or wip2html (convert to HTML).",
|
|
913
|
+
inputSchema: WipOperationsSchema,
|
|
914
|
+
outputSchema: z.object({
|
|
915
|
+
result: WipOperationOutputSchema,
|
|
916
|
+
}),
|
|
917
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
918
|
+
_meta: createToolMeta("operation", ["wip", "promise", "file-generation", "verification", "signature", "local"]),
|
|
919
|
+
}, handleWipOperations);
|
|
920
|
+
// Messenger Operations Tool
|
|
921
|
+
server.registerTool("messenger_operation", {
|
|
922
|
+
title: "đŦ Messenger Operations",
|
|
923
|
+
description: "WoWok encrypted messenger operations: watch conversations, send message, send file, watch messages, extract zip messages, generate WTS, verify WTS, sign WTS, WTS to HTML, proof message on-chain, manage blacklist, friendslist, and guardlist.",
|
|
924
|
+
inputSchema: MessengerOperationInputSchema,
|
|
925
|
+
outputSchema: MessengerOperationOutputSchema,
|
|
926
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
927
|
+
_meta: createToolMeta("operation", ["messenger", "message", "file", "wts", "blacklist", "friendslist", "guardlist", "proof", "communication"]),
|
|
928
|
+
}, handleMessengerOperation);
|
|
929
|
+
// Guard2File Tool - Export Guard to JSON/Markdown file
|
|
930
|
+
server.registerTool("guard2file", {
|
|
931
|
+
title: "đ Guard to File - Export Guard Definition",
|
|
932
|
+
description: "Export a Guard object's definition from the blockchain to a local JSON or Markdown file for editing and creating new Guard objects. Note: To query on-chain object information, use the 'query_toolkit' tool instead.",
|
|
933
|
+
inputSchema: Guard2File_InputSchema,
|
|
934
|
+
outputSchema: Guard2File_OutputWrappedSchema,
|
|
935
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
936
|
+
_meta: createToolMeta("generate file", ["guard", "export", "file", "json", "markdown", "on-chain"]),
|
|
937
|
+
}, handleGuard2File);
|
|
938
|
+
// MachineNode2File Tool - Export Machine nodes to JSON/Markdown file
|
|
939
|
+
server.registerTool("machineNode2file", {
|
|
940
|
+
title: "âī¸ Machine Node to File - Export Machine Node Definition",
|
|
941
|
+
description: "Export a Machine object's node definition from the blockchain to a local JSON or Markdown file for editing and creating new Machine objects. Note: To query on-chain object information, use the 'query_toolkit' tool instead.",
|
|
942
|
+
inputSchema: MachineNode2File_InputSchema,
|
|
943
|
+
outputSchema: MachineNode2File_OutputWrappedSchema,
|
|
944
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
945
|
+
_meta: createToolMeta("generate file", ["machine", "export", "file", "json", "markdown", "on-chain", "workflow"]),
|
|
946
|
+
}, handleMachineNode2File);
|
|
947
|
+
server.registerTool("query_toolkit", {
|
|
948
|
+
title: "đ Data Query Toolkit",
|
|
949
|
+
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.",
|
|
950
|
+
inputSchema: WatchQueryOperationsSchema,
|
|
951
|
+
outputSchema: WatchQueryOperationsResultSchema,
|
|
952
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
953
|
+
_meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tables", "tokens", "balance", "profile"]),
|
|
954
|
+
}, handleWatchQueryOperations);
|
|
955
|
+
server.registerTool("onchain_events", {
|
|
956
|
+
title: "đ
Watch On-chain Events",
|
|
957
|
+
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.",
|
|
958
|
+
inputSchema: OnchainEventsInputSchema,
|
|
959
|
+
outputSchema: OnchainEventsResultSchema,
|
|
960
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
961
|
+
_meta: createToolMeta("watch events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
|
|
962
|
+
}, handleOnchainEvents);
|
|
963
|
+
server.registerTool("wowok_buildin_info", {
|
|
964
|
+
title: "âšī¸ WoWok Build-in Information",
|
|
965
|
+
description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'guard instructions', 'current network', or 'value types'.",
|
|
966
|
+
inputSchema: ProtocolInfoQuerySchema,
|
|
967
|
+
outputSchema: ProtocolInfoResultSchema,
|
|
968
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
969
|
+
_meta: createToolMeta("WoWok info", ["build-in", "constants", "permissions", "guard", "network", "value-types"]),
|
|
970
|
+
}, handleWowokInfo);
|
|
971
|
+
// Documents and Learn Tool - Provide documentation URL for users and AI
|
|
972
|
+
server.registerTool("documents_and_learn", {
|
|
973
|
+
title: "đ Documents and Learn",
|
|
974
|
+
description: "Access WoWok documentation and learning resources. Provides official documentation URL for users and AI to get more information about WoWok protocol, components, and usage.",
|
|
975
|
+
inputSchema: z.object({
|
|
976
|
+
topic: z.string().optional().describe("Optional topic to search for in documentation (e.g., 'guard', 'service', 'messenger', 'stage-01-introduction')"),
|
|
977
|
+
}),
|
|
978
|
+
outputSchema: z.object({
|
|
979
|
+
documentation_url: z.string().describe("Official WoWok documentation URL on GitHub"),
|
|
980
|
+
topic: z.string().optional().describe("Requested topic if specified"),
|
|
981
|
+
message: z.string().describe("Welcome message with documentation information"),
|
|
982
|
+
}),
|
|
983
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
984
|
+
_meta: createToolMeta("documentation", ["docs", "learn", "tutorial", "guide", "help", "reference"]),
|
|
985
|
+
}, async (args) => {
|
|
986
|
+
const GITHUB_BASE_URL = "https://github.com/wowok-ai/docs/blob/main/docs";
|
|
987
|
+
if (!args.topic) {
|
|
988
|
+
// No topic specified, return base documentation URL
|
|
989
|
+
const url = GITHUB_BASE_URL;
|
|
990
|
+
return {
|
|
991
|
+
content: [
|
|
992
|
+
{
|
|
993
|
+
type: "text",
|
|
994
|
+
text: `Welcome to WoWok Documentation! Access comprehensive guides, tutorials, and API references at: ${url}`,
|
|
995
|
+
},
|
|
996
|
+
],
|
|
997
|
+
structuredContent: {
|
|
998
|
+
documentation_url: url,
|
|
999
|
+
},
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
// Topic specified, construct URL
|
|
1003
|
+
const url = `${GITHUB_BASE_URL}/${args.topic}.md`;
|
|
1004
|
+
return {
|
|
1005
|
+
content: [
|
|
1006
|
+
{
|
|
1007
|
+
type: "text",
|
|
1008
|
+
text: `Documentation for "${args.topic}"\nGitHub URL: ${url}`,
|
|
1009
|
+
},
|
|
1010
|
+
],
|
|
1011
|
+
structuredContent: {
|
|
1012
|
+
documentation_url: url,
|
|
1013
|
+
topic: args.topic,
|
|
1014
|
+
},
|
|
1015
|
+
};
|
|
1016
|
+
});
|
|
1017
|
+
// Connect to transport
|
|
1018
|
+
const transport = new StdioServerTransport();
|
|
1019
|
+
await server.connect(transport);
|
|
1020
|
+
// Cleanup on exit
|
|
1021
|
+
process.on("SIGINT", async () => {
|
|
1022
|
+
await server.close();
|
|
1023
|
+
process.exit(0);
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
main().catch(console.error);
|