@wowok/agent-mcp 2.4.1 → 2.4.3

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.
Files changed (74) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.js +11 -1624
  3. package/dist/knowledge/guard-ledger.js +14 -0
  4. package/dist/knowledge/guard-lint.d.ts +1 -0
  5. package/dist/knowledge/guard-lint.js +83 -3
  6. package/dist/knowledge/guard-migration.d.ts +48 -0
  7. package/dist/knowledge/guard-migration.js +228 -0
  8. package/dist/knowledge/guard-risk.d.ts +2 -0
  9. package/dist/knowledge/guard-risk.js +827 -57
  10. package/dist/knowledge/guard-templates.d.ts +1 -0
  11. package/dist/knowledge/guard-templates.js +278 -2
  12. package/dist/project/graph.d.ts +1 -0
  13. package/dist/project/graph.js +27 -1
  14. package/dist/project/index.d.ts +1 -0
  15. package/dist/project/index.js +39 -2
  16. package/dist/project/namespace.d.ts +11 -1
  17. package/dist/project/namespace.js +27 -2
  18. package/dist/project/query.d.ts +2 -0
  19. package/dist/project/query.js +56 -15
  20. package/dist/rules.d.ts +12 -0
  21. package/dist/rules.js +9 -0
  22. package/dist/schema/call/allocation.d.ts +10 -10
  23. package/dist/schema/call/base.js +3 -3
  24. package/dist/schema/call/machine.d.ts +38 -38
  25. package/dist/schema/call/semantic.js +1 -1
  26. package/dist/schema/call/service.d.ts +7 -7
  27. package/dist/schema/operations.d.ts +48 -48
  28. package/dist/schema/query/index.d.ts +146 -146
  29. package/dist/schema/query/index.js +15 -9
  30. package/dist/schema/utils/guard-query-utils.d.ts +7 -0
  31. package/dist/schema/utils/guard-query-utils.js +14 -1
  32. package/dist/schemas/bridge_operation.output.json +1 -1
  33. package/dist/schemas/index.json +1 -1
  34. package/dist/schemas/messenger_operation.output.json +1 -1
  35. package/dist/schemas/onchain_events.output.json +1 -1
  36. package/dist/schemas/onchain_operations.output.json +2 -2
  37. package/dist/schemas/onchain_operations.schema.json +11 -20
  38. package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
  39. package/dist/schemas/onchain_operations_machine.schema.json +2 -5
  40. package/dist/schemas/onchain_operations_service.schema.json +2 -5
  41. package/dist/schemas/onchain_table_data.output.json +6 -12
  42. package/dist/tools/handlers/bridge.d.ts +1 -0
  43. package/dist/tools/handlers/bridge.js +1 -0
  44. package/dist/tools/handlers/config.d.ts +2 -0
  45. package/dist/tools/handlers/config.js +71 -0
  46. package/dist/tools/handlers/file-export.d.ts +3 -0
  47. package/dist/tools/handlers/file-export.js +90 -0
  48. package/dist/tools/handlers/local.d.ts +30 -0
  49. package/dist/tools/handlers/local.js +27 -0
  50. package/dist/tools/handlers/messenger.d.ts +16 -0
  51. package/dist/tools/handlers/messenger.js +187 -0
  52. package/dist/tools/handlers/onchain.d.ts +2 -0
  53. package/dist/tools/handlers/onchain.js +246 -0
  54. package/dist/tools/handlers/project.d.ts +2 -0
  55. package/dist/tools/handlers/project.js +53 -0
  56. package/dist/tools/handlers/query.d.ts +5 -0
  57. package/dist/tools/handlers/query.js +256 -0
  58. package/dist/tools/handlers/schema-query.d.ts +2 -0
  59. package/dist/tools/handlers/schema-query.js +92 -0
  60. package/dist/tools/handlers/trust.d.ts +2 -0
  61. package/dist/tools/handlers/trust.js +194 -0
  62. package/dist/tools/handlers/wip.d.ts +2 -0
  63. package/dist/tools/handlers/wip.js +44 -0
  64. package/dist/tools/index.d.ts +13 -0
  65. package/dist/tools/index.js +479 -0
  66. package/dist/tools/rules-hook.d.ts +2 -0
  67. package/dist/tools/rules-hook.js +22 -0
  68. package/dist/tools/shared.d.ts +29 -0
  69. package/dist/tools/shared.js +130 -0
  70. package/dist/tools/types.d.ts +35 -0
  71. package/dist/tools/types.js +1 -0
  72. package/dist/tools/wrap.d.ts +6 -0
  73. package/dist/tools/wrap.js +55 -0
  74. package/package.json +19 -5
@@ -0,0 +1,256 @@
1
+ import { strictParse, WatchQueryOperationsSchema, OnchainTableDataSchema, OnchainEventsInputSchema, ProtocolInfoQuerySchema, } from "../../schema/index.js";
2
+ import { query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, GetLocalNamesByAddresses, query_personal, query_objects, query_table, query_tableItem, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_received, queryProtocolInfo, query_events, generateNodeComments, } from "@wowok/wowok";
3
+ import { buildDataSemantic, } from "../../schema/call/semantic.js";
4
+ import { normalizeAccountOrMark } from "./messenger.js";
5
+ export async function handleWatchQueryOperations(args) {
6
+ const validated = strictParse(WatchQueryOperationsSchema, args, "watch_and_query input");
7
+ let result;
8
+ switch (validated.query_type) {
9
+ case "local_mark_list": {
10
+ const queryResult = await query_local_mark_list(validated.filter || {});
11
+ result = { query_type: "local_mark_list", result: queryResult };
12
+ break;
13
+ }
14
+ case "account_list": {
15
+ const queryResult = await query_account_list(validated.filter);
16
+ result = { query_type: "account_list", result: queryResult };
17
+ break;
18
+ }
19
+ case "local_info_list": {
20
+ const queryResult = await query_local_info_list(validated.filter);
21
+ result = { query_type: "local_info_list", result: queryResult };
22
+ break;
23
+ }
24
+ case "token_list": {
25
+ const queryResult = await query_local_token_list(validated.filter || {});
26
+ result = { query_type: "token_list", result: queryResult };
27
+ break;
28
+ }
29
+ case "account_balance": {
30
+ const queryResult = await query_account({
31
+ name_or_address: validated.name_or_address,
32
+ token_type: validated.token_type,
33
+ balance: validated.balance,
34
+ coin: validated.coin,
35
+ network: validated.network,
36
+ });
37
+ result = { query_type: "account_balance", result: queryResult };
38
+ break;
39
+ }
40
+ case "local_names": {
41
+ const queryResult = await GetLocalNamesByAddresses(validated.addresses);
42
+ result = { query_type: "local_names", result: queryResult };
43
+ break;
44
+ }
45
+ case "onchain_personal_profile": {
46
+ const queryResult = await query_personal({
47
+ account: validated.account,
48
+ no_cache: validated.no_cache,
49
+ network: validated.network,
50
+ });
51
+ result = { query_type: "onchain_personal_profile", result: queryResult };
52
+ break;
53
+ }
54
+ case "onchain_objects": {
55
+ const queryResult = await query_objects({
56
+ objects: validated.objects,
57
+ no_cache: validated.no_cache,
58
+ network: validated.network,
59
+ });
60
+ if (queryResult && queryResult.objects && Array.isArray(queryResult.objects)) {
61
+ queryResult.objects = queryResult.objects.map((obj) => {
62
+ if (obj && obj.data && obj.data.type === "Guard" && obj.data.root) {
63
+ try {
64
+ const nodeComments = generateNodeComments(obj.data.root);
65
+ return {
66
+ ...obj,
67
+ _guard_node_comments: nodeComments,
68
+ };
69
+ }
70
+ catch (e) {
71
+ return obj;
72
+ }
73
+ }
74
+ return obj;
75
+ });
76
+ }
77
+ result = { query_type: "onchain_objects", result: queryResult };
78
+ break;
79
+ }
80
+ case "onchain_received": {
81
+ const queryResult = await query_received({
82
+ name_or_address: normalizeAccountOrMark(validated.name_or_address),
83
+ type: validated.type,
84
+ cursor: validated.cursor,
85
+ limit: validated.limit,
86
+ no_cache: validated.no_cache,
87
+ network: validated.network,
88
+ });
89
+ result = { query_type: "onchain_received", result: queryResult };
90
+ break;
91
+ }
92
+ default:
93
+ throw new Error(`Unknown query type. Valid query_types are: "local_mark_list", "account_list", "local_info_list", "token_list", "account_balance", "local_names", "onchain_personal_profile", "onchain_objects", "onchain_received". For table queries, use the "onchain_table_data" tool.`);
94
+ }
95
+ return {
96
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
97
+ structuredContent: {
98
+ result,
99
+ semantic: buildDataSemantic(result, {
100
+ operation_type: "query_toolkit",
101
+ data: validated,
102
+ }),
103
+ },
104
+ };
105
+ }
106
+ export async function handleOnchainTableData(args) {
107
+ const validated = strictParse(OnchainTableDataSchema, args, "onchain_table_data input");
108
+ let result;
109
+ switch (validated.query_type) {
110
+ case "onchain_table": {
111
+ const queryResult = await query_table({
112
+ parent: validated.parent,
113
+ cursor: validated.cursor,
114
+ limit: validated.limit,
115
+ no_cache: validated.no_cache,
116
+ network: validated.network,
117
+ });
118
+ result = { query_type: "onchain_table", result: queryResult };
119
+ break;
120
+ }
121
+ case "onchain_table_item_repository_data": {
122
+ const queryResult = await queryTableItem_RepositoryData({
123
+ parent: validated.parent, name: validated.name, entity: validated.entity,
124
+ no_cache: validated.no_cache, network: validated.network,
125
+ });
126
+ result = { query_type: "onchain_table_item_repository_data", result: queryResult };
127
+ break;
128
+ }
129
+ case "onchain_table_item_permission_perm": {
130
+ const queryResult = await queryTableItem_PermissionPerm({
131
+ parent: validated.parent, address: validated.address,
132
+ no_cache: validated.no_cache, network: validated.network,
133
+ });
134
+ result = { query_type: "onchain_table_item_permission_perm", result: queryResult };
135
+ break;
136
+ }
137
+ case "onchain_table_item_reward_record": {
138
+ const queryResult = await queryTableItem_RewardRecord({
139
+ parent: validated.parent, address: validated.address,
140
+ no_cache: validated.no_cache, network: validated.network,
141
+ });
142
+ result = { query_type: "onchain_table_item_reward_record", result: queryResult };
143
+ break;
144
+ }
145
+ case "onchain_table_item_demand_presenter": {
146
+ const queryResult = await queryTableItem_DemandPresenter({
147
+ parent: validated.parent, address: validated.address,
148
+ no_cache: validated.no_cache, network: validated.network,
149
+ });
150
+ result = { query_type: "onchain_table_item_demand_presenter", result: queryResult };
151
+ break;
152
+ }
153
+ case "onchain_table_item_treasury_history": {
154
+ const queryResult = await queryTableItem_TreasuryHistory({
155
+ parent: validated.parent, address: validated.address,
156
+ no_cache: validated.no_cache, network: validated.network,
157
+ });
158
+ result = { query_type: "onchain_table_item_treasury_history", result: queryResult };
159
+ break;
160
+ }
161
+ case "onchain_table_item_machine_node": {
162
+ const queryResult = await queryTableItem_MachineNode({
163
+ parent: validated.parent, key: validated.key,
164
+ no_cache: validated.no_cache, network: validated.network,
165
+ });
166
+ result = { query_type: "onchain_table_item_machine_node", result: queryResult };
167
+ break;
168
+ }
169
+ case "onchain_table_item_progress_history": {
170
+ const queryResult = await queryTableItem_ProgressHistory({
171
+ parent: validated.parent, u64: validated.u64,
172
+ no_cache: validated.no_cache, network: validated.network,
173
+ });
174
+ result = { query_type: "onchain_table_item_progress_history", result: queryResult };
175
+ break;
176
+ }
177
+ case "onchain_table_item_address_mark": {
178
+ const queryResult = await queryTableItem_AddressMark({
179
+ parent: validated.parent, address: validated.address,
180
+ no_cache: validated.no_cache, network: validated.network,
181
+ });
182
+ result = { query_type: "onchain_table_item_address_mark", result: queryResult };
183
+ break;
184
+ }
185
+ case "onchain_table_item_entity_registrar": {
186
+ const queryResult = await queryTableItem_EntityRegistrar({
187
+ address: validated.address,
188
+ no_cache: validated.no_cache, network: validated.network,
189
+ });
190
+ result = { query_type: "onchain_table_item_entity_registrar", result: queryResult };
191
+ break;
192
+ }
193
+ case "onchain_table_item_entity_linker": {
194
+ const queryResult = await queryTableItem_EntityLinker({
195
+ address: validated.address,
196
+ no_cache: validated.no_cache, network: validated.network,
197
+ });
198
+ result = { query_type: "onchain_table_item_entity_linker", result: queryResult };
199
+ break;
200
+ }
201
+ case "onchain_table_item_generic": {
202
+ const queryResult = await query_tableItem({
203
+ parent: validated.parent,
204
+ key: { type: validated.key_type, value: validated.key_value },
205
+ no_cache: validated.no_cache,
206
+ network: validated.network,
207
+ });
208
+ result = { query_type: "onchain_table_item_generic", result: queryResult };
209
+ break;
210
+ }
211
+ default:
212
+ 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", "onchain_table_item_generic"`);
213
+ }
214
+ return {
215
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
216
+ structuredContent: {
217
+ result,
218
+ semantic: buildDataSemantic(result, {
219
+ operation_type: "onchain_table_data",
220
+ data: validated,
221
+ }),
222
+ },
223
+ };
224
+ }
225
+ export async function handleOnchainEvents(args) {
226
+ const validated = strictParse(OnchainEventsInputSchema, args, "onchain_events input");
227
+ const queryResult = await query_events({
228
+ type: validated.type,
229
+ cursor: validated.cursor ? {
230
+ eventSeq: String(validated.cursor.eventSeq),
231
+ txDigest: validated.cursor.txDigest,
232
+ } : null,
233
+ limit: validated.limit ?? null,
234
+ order: validated.order ?? null,
235
+ no_cache: validated.no_cache,
236
+ network: validated.network,
237
+ });
238
+ return {
239
+ content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
240
+ structuredContent: {
241
+ result: queryResult,
242
+ semantic: buildDataSemantic(queryResult, {
243
+ operation_type: "onchain_events",
244
+ data: validated,
245
+ }),
246
+ },
247
+ };
248
+ }
249
+ export async function handleWowokInfo(args) {
250
+ const validated = strictParse(ProtocolInfoQuerySchema, args, "wowok_buildin_info input");
251
+ const queryResult = await queryProtocolInfo(validated);
252
+ return {
253
+ content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
254
+ structuredContent: { result: queryResult },
255
+ };
256
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function handleSchemaQuery(args: any): Promise<ToolDispatchResult>;
@@ -0,0 +1,92 @@
1
+ import { processSchemaQuery, } from "../../schema-query/index.js";
2
+ export async function handleSchemaQuery(args) {
3
+ const request = {
4
+ action: args.action,
5
+ name: args.name,
6
+ query: args.query,
7
+ };
8
+ const response = processSchemaQuery(request);
9
+ let textContent = response.message;
10
+ const data = response.data;
11
+ if (response.success && data) {
12
+ switch (args.action) {
13
+ case "list":
14
+ if (Array.isArray(data) && data.length > 0) {
15
+ textContent += "\n\nAll available schemas:\n";
16
+ for (const item of data) {
17
+ textContent += `\n • ${item.name}`;
18
+ if (item.title) {
19
+ textContent += ` - ${item.title}`;
20
+ }
21
+ if (item.description) {
22
+ textContent += `\n ${item.description.slice(0, 100)}...`;
23
+ }
24
+ textContent += "\n";
25
+ }
26
+ }
27
+ break;
28
+ case "list_operations":
29
+ if (Array.isArray(data) && data.length > 0) {
30
+ textContent += "\n\nOn-chain operation schemas:\n";
31
+ for (const item of data) {
32
+ textContent += `\n • ${item.name}`;
33
+ if (item.title) {
34
+ textContent += ` - ${item.title}`;
35
+ }
36
+ if (item.description) {
37
+ textContent += `\n ${item.description.slice(0, 100)}...`;
38
+ }
39
+ textContent += "\n";
40
+ }
41
+ }
42
+ break;
43
+ case "get":
44
+ if (data) {
45
+ textContent += "\n\n## JSON Schema\n\n";
46
+ textContent += "```json\n";
47
+ textContent += JSON.stringify(data, null, 2);
48
+ textContent += "\n```\n";
49
+ }
50
+ break;
51
+ case "get_output":
52
+ if (data) {
53
+ textContent += "\n\n## Output JSON Schema\n\n";
54
+ textContent += "```json\n";
55
+ textContent += JSON.stringify(data, null, 2);
56
+ textContent += "\n```\n";
57
+ }
58
+ break;
59
+ case "search":
60
+ if (Array.isArray(data) && data.length > 0) {
61
+ textContent += `\n\nFound ${data.length} schemas matching '${args.query}':\n`;
62
+ for (const item of data) {
63
+ textContent += `\n • ${item.name}`;
64
+ if (item.title) {
65
+ textContent += ` - ${item.title}`;
66
+ }
67
+ if (item.description) {
68
+ textContent += `\n ${item.description.slice(0, 100)}...`;
69
+ }
70
+ textContent += "\n";
71
+ }
72
+ }
73
+ else {
74
+ textContent += "\n\nNo schemas found. Try 'list' to browse all available schemas, or use a broader search term.";
75
+ }
76
+ break;
77
+ }
78
+ }
79
+ if (response.suggestions && response.suggestions.length > 0) {
80
+ textContent += "\n\n💡 Suggestions:\n";
81
+ for (const suggestion of response.suggestions) {
82
+ textContent += ` • ${suggestion}\n`;
83
+ }
84
+ }
85
+ return {
86
+ content: [{
87
+ type: "text",
88
+ text: textContent,
89
+ }],
90
+ structuredContent: response,
91
+ };
92
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function handleTrustScore(args: any): Promise<ToolDispatchResult>;
@@ -0,0 +1,194 @@
1
+ import { strictParse, TrustScoreInputSchema, } from "../../schema/index.js";
2
+ import { query_objects, } from "@wowok/wowok";
3
+ import { computeServiceTrustScore, } from "../../knowledge/index.js";
4
+ import { assembleInfoPuzzle, assessRisk, } from "../../customer/index.js";
5
+ function extractTrustMetrics(serviceObj) {
6
+ const data = serviceObj?.data ?? serviceObj ?? {};
7
+ const sales = Array.isArray(data.sales) ? data.sales : [];
8
+ const activeSales = sales.filter((s) => s && !s.suspension);
9
+ void activeSales;
10
+ const compensationFund = data.compensation_fund;
11
+ const compBalance = (() => {
12
+ if (compensationFund === null || compensationFund === undefined)
13
+ return undefined;
14
+ if (typeof compensationFund === "bigint")
15
+ return compensationFund;
16
+ if (typeof compensationFund === "number")
17
+ return BigInt(compensationFund);
18
+ if (typeof compensationFund === "string") {
19
+ try {
20
+ return BigInt(compensationFund);
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ if (typeof compensationFund === "object") {
27
+ const bal = compensationFund.balance;
28
+ if (bal === null || bal === undefined)
29
+ return undefined;
30
+ try {
31
+ return BigInt(bal);
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ return undefined;
38
+ })();
39
+ return {
40
+ arbitrationCases: Array.isArray(data.arbitrations) ? data.arbitrations.length : undefined,
41
+ compensationFundBalance: compBalance,
42
+ hasMachineBound: typeof data.machine === "string" && data.machine.length > 0,
43
+ hasBuyGuard: typeof data.buy_guard === "string" && data.buy_guard.length > 0,
44
+ };
45
+ }
46
+ function buildPuzzleRawData(serviceObj, orderAmount, trustScore, serviceOwner) {
47
+ const data = serviceObj?.data ?? serviceObj ?? {};
48
+ const sales = Array.isArray(data.sales) ? data.sales : [];
49
+ const order_allocators = data.order_allocators
50
+ ? Array.isArray(data.order_allocators.allocators)
51
+ ? data.order_allocators
52
+ : { allocators: data.order_allocators }
53
+ : undefined;
54
+ const serviceRaw = {
55
+ name: data.name ?? serviceObj?.id,
56
+ bPublished: data.bPublished,
57
+ bPaused: data.bPaused,
58
+ price: sales[0]?.price != null ? String(sales[0].price) : "0",
59
+ priceRaw: sales[0]?.price != null ? BigInt(sales[0].price) : 0n,
60
+ token_type: sales[0]?.price_type ?? (compensation_fund_token(data) ?? "0x2::wow::WOW"),
61
+ sales,
62
+ machine: data.machine ?? undefined,
63
+ buy_guard: data.buy_guard ?? undefined,
64
+ customer_required: data.customer_required,
65
+ arbitrations: data.arbitrations,
66
+ compensation_fund: data.compensation_fund
67
+ ? { balance: extractBalance(data.compensation_fund) }
68
+ : undefined,
69
+ compensation_lock_duration: typeof data.setting_lock_duration === "number"
70
+ ? data.setting_lock_duration
71
+ : undefined,
72
+ um: data.um ?? undefined,
73
+ order_allocators: order_allocators ? [order_allocators] : undefined,
74
+ };
75
+ return {
76
+ service: serviceRaw,
77
+ order_amount: orderAmount,
78
+ trust_score: trustScore,
79
+ service_owner: serviceOwner,
80
+ };
81
+ }
82
+ function compensation_fund_token(data) {
83
+ if (data?.compensation_fund && typeof data.compensation_fund === "object") {
84
+ return data.compensation_fund.token_type;
85
+ }
86
+ return undefined;
87
+ }
88
+ function extractBalance(b) {
89
+ if (b === null || b === undefined)
90
+ return 0n;
91
+ if (typeof b === "bigint")
92
+ return b;
93
+ if (typeof b === "number")
94
+ return BigInt(b);
95
+ if (typeof b === "string") {
96
+ try {
97
+ return BigInt(b);
98
+ }
99
+ catch {
100
+ return 0n;
101
+ }
102
+ }
103
+ if (typeof b === "object") {
104
+ const bal = b.balance;
105
+ if (bal === null || bal === undefined)
106
+ return 0n;
107
+ try {
108
+ return BigInt(bal);
109
+ }
110
+ catch {
111
+ return 0n;
112
+ }
113
+ }
114
+ return 0n;
115
+ }
116
+ export async function handleTrustScore(args) {
117
+ const validated = strictParse(TrustScoreInputSchema, args, "trust_score input");
118
+ const depth = (validated.depth ?? "evaluate");
119
+ const queryResult = await query_objects({
120
+ objects: [validated.service],
121
+ no_cache: validated.no_cache,
122
+ network: validated.network,
123
+ });
124
+ const objects = queryResult?.objects;
125
+ if (!objects || !Array.isArray(objects) || objects.length === 0) {
126
+ throw new Error(`Service object not found for '${validated.service}'. ` +
127
+ `Verify the ID/name and network, or use query_toolkit with query_type='onchain_objects' to debug.`);
128
+ }
129
+ const serviceObj = objects[0];
130
+ const objType = serviceObj?.data?.object_type ?? serviceObj?.object_type ?? serviceObj?.type;
131
+ if (objType && typeof objType === "string" && !objType.includes("Service")) {
132
+ throw new Error(`Object '${validated.service}' is not a Service (type: ${objType}). ` +
133
+ `trust_score only evaluates Service objects.`);
134
+ }
135
+ const metrics = extractTrustMetrics(serviceObj);
136
+ const trustScore = computeServiceTrustScore(metrics);
137
+ const sales = Array.isArray(serviceObj?.data?.sales) ? serviceObj.data.sales : [];
138
+ const activeSale = sales.find((s) => s && !s.suspension) ?? sales[0];
139
+ const salePriceRaw = activeSale?.price != null ? BigInt(activeSale.price) : 0n;
140
+ const orderAmount = validated.order_amount != null
141
+ ? BigInt(validated.order_amount)
142
+ : salePriceRaw;
143
+ let riskScore = undefined;
144
+ let infoPuzzle = undefined;
145
+ if (depth === "evaluate" || depth === "preorder") {
146
+ const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
147
+ infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
148
+ riskScore = assessRisk(infoPuzzle);
149
+ }
150
+ const result = {
151
+ service_id: validated.service,
152
+ service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
153
+ service_basics: {
154
+ bPublished: serviceObj?.data?.bPublished ?? false,
155
+ bPaused: serviceObj?.data?.bPaused ?? false,
156
+ sales_count: sales.filter((s) => s && !s.suspension).length,
157
+ has_machine: !!serviceObj?.data?.machine,
158
+ has_buy_guard: !!serviceObj?.data?.buy_guard,
159
+ has_um_contact: !!serviceObj?.data?.um,
160
+ arbitrations_count: Array.isArray(serviceObj?.data?.arbitrations)
161
+ ? serviceObj.data.arbitrations.length
162
+ : 0,
163
+ },
164
+ trust_score: {
165
+ score: trustScore.score,
166
+ level: trustScore.level,
167
+ summary: trustScore.summary,
168
+ warnings: trustScore.warnings,
169
+ breakdown: trustScore.breakdown,
170
+ },
171
+ order_amount: orderAmount.toString(),
172
+ depth,
173
+ ...(riskScore ? {
174
+ risk_score: {
175
+ total: riskScore.total,
176
+ level: riskScore.level,
177
+ red_flags: riskScore.red_flags,
178
+ advice: riskScore.advice,
179
+ dimensions: riskScore.dimensions,
180
+ },
181
+ } : {}),
182
+ ...(infoPuzzle ? {
183
+ info_puzzle: {
184
+ completeness: infoPuzzle.completeness,
185
+ gaps: infoPuzzle.gaps,
186
+ assembled_at: infoPuzzle.assembled_at,
187
+ },
188
+ } : {}),
189
+ };
190
+ return {
191
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
192
+ structuredContent: { result },
193
+ };
194
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function handleWipOperations(args: any): Promise<ToolDispatchResult>;
@@ -0,0 +1,44 @@
1
+ import { strictParse, WipOperationsSchema, } from "../../schema/index.js";
2
+ import { generate_wip, verify_wip, sign_wip, wip2html, } from "@wowok/wowok";
3
+ export async function handleWipOperations(args) {
4
+ const validated = strictParse(WipOperationsSchema, args, "wip_file input");
5
+ let structuredContent;
6
+ switch (validated.type) {
7
+ case "generate": {
8
+ const result = await generate_wip(validated.options, validated.outputPath);
9
+ structuredContent = { result: { type: "generate", filePath: result } };
10
+ break;
11
+ }
12
+ case "verify": {
13
+ const result = await verify_wip(validated.wipFilePath, validated.hash_equal, validated.requireSignature);
14
+ structuredContent = { result: { type: "verify", ...result } };
15
+ break;
16
+ }
17
+ case "sign": {
18
+ const result = await sign_wip(validated.wipFilePath, validated.account, validated.outputPath);
19
+ structuredContent = { result: { type: "sign", filePath: result } };
20
+ break;
21
+ }
22
+ case "wip2html": {
23
+ const result = await wip2html(validated.wipPath, validated.options);
24
+ let output = { type: "wip2html" };
25
+ if (typeof result === "string") {
26
+ output.html = result;
27
+ }
28
+ else if (Array.isArray(result)) {
29
+ output.files = result;
30
+ }
31
+ else {
32
+ output.html = String(result);
33
+ }
34
+ structuredContent = { result: output };
35
+ break;
36
+ }
37
+ default:
38
+ throw new Error("Unknown WIP operation type");
39
+ }
40
+ return {
41
+ content: [{ type: "text", text: JSON.stringify(structuredContent) }],
42
+ structuredContent,
43
+ };
44
+ }
@@ -0,0 +1,13 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { ToolEntry, ToolDispatchResult, DispatchOptions } from "./types.js";
3
+ export declare const TOOL_REGISTRY: ToolEntry[];
4
+ export declare const TOOL_REGISTRY_MAP: Map<string, ToolEntry>;
5
+ export declare function dispatchToolCall(name: string, args: any, options?: DispatchOptions): Promise<ToolDispatchResult>;
6
+ export interface ToolListEntry {
7
+ name: string;
8
+ title: string;
9
+ description: string;
10
+ inputSchema: Record<string, unknown>;
11
+ }
12
+ export declare function listTools(): ToolListEntry[];
13
+ export declare function registerAllTools(server: McpServer): void;