@wowok/agent-mcp 2.3.12 β 2.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harness/checkpoint.d.ts +8 -0
- package/dist/harness/checkpoint.js +129 -0
- package/dist/harness/index.d.ts +33 -0
- package/dist/harness/index.js +75 -0
- package/dist/harness/plan.d.ts +18 -0
- package/dist/harness/plan.js +252 -0
- package/dist/harness/recover.d.ts +17 -0
- package/dist/harness/recover.js +139 -0
- package/dist/harness/types.d.ts +137 -0
- package/dist/harness/types.js +1 -0
- package/dist/harness/verify.d.ts +42 -0
- package/dist/harness/verify.js +237 -0
- package/dist/index.js +134 -52
- package/dist/loop-engineering/aggregate.d.ts +50 -0
- package/dist/loop-engineering/aggregate.js +132 -0
- package/dist/loop-engineering/diagnose.d.ts +21 -0
- package/dist/loop-engineering/diagnose.js +179 -0
- package/dist/loop-engineering/improve.d.ts +26 -0
- package/dist/loop-engineering/improve.js +178 -0
- package/dist/loop-engineering/index.d.ts +4 -0
- package/dist/loop-engineering/index.js +4 -0
- package/dist/loop-engineering/pipeline.d.ts +17 -0
- package/dist/loop-engineering/pipeline.js +56 -0
- package/dist/mode-market/index.d.ts +3 -0
- package/dist/mode-market/index.js +3 -0
- package/dist/mode-market/registry.d.ts +53 -0
- package/dist/mode-market/registry.js +124 -0
- package/dist/mode-market/review.d.ts +27 -0
- package/dist/mode-market/review.js +214 -0
- package/dist/mode-market/submission.d.ts +25 -0
- package/dist/mode-market/submission.js +85 -0
- package/dist/schema/call/allocation.d.ts +40 -40
- package/dist/schema/call/arbitration.d.ts +90 -90
- package/dist/schema/call/base.d.ts +1054 -0
- package/dist/schema/call/base.js +100 -22
- package/dist/schema/call/bridge-handler.js +36 -18
- package/dist/schema/call/bridge.d.ts +115 -115
- package/dist/schema/call/handler.d.ts +2 -1
- package/dist/schema/call/handler.js +94 -3
- package/dist/schema/call/index.d.ts +1 -0
- package/dist/schema/call/index.js +1 -0
- package/dist/schema/call/machine.d.ts +144 -144
- package/dist/schema/call/order.d.ts +12 -12
- package/dist/schema/call/progress.d.ts +6 -6
- package/dist/schema/call/proof.js +7 -6
- package/dist/schema/call/reward.d.ts +6 -6
- package/dist/schema/call/semantic.d.ts +23 -0
- package/dist/schema/call/semantic.js +764 -0
- package/dist/schema/call/service.d.ts +142 -142
- package/dist/schema/call/treasury.d.ts +204 -204
- package/dist/schema/local/index.d.ts +113 -2
- package/dist/schema/local/index.js +11 -1
- package/dist/schema/messenger/index.d.ts +435 -95
- package/dist/schema/messenger/index.js +20 -8
- package/dist/schema/operations.d.ts +988 -495
- package/dist/schema/operations.js +14 -3
- package/dist/schema/query/index.d.ts +346 -342
- package/dist/schema/query/index.js +4 -1
- package/dist/schemas/account_operation.output.json +3 -0
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +3 -0
- package/dist/schemas/local_mark_operation.output.json +3 -0
- package/dist/schemas/messenger_operation.output.json +21 -0
- package/dist/schemas/messenger_operation.schema.json +43 -8
- package/dist/schemas/onchain_events.output.json +3 -0
- package/dist/schemas/onchain_operations.output.json +464 -21
- package/dist/schemas/onchain_operations.schema.json +21 -17
- package/dist/schemas/onchain_operations_allocation.schema.json +11 -9
- package/dist/schemas/onchain_operations_arbitration.schema.json +11 -9
- package/dist/schemas/onchain_operations_contact.schema.json +11 -9
- package/dist/schemas/onchain_operations_demand.schema.json +11 -9
- package/dist/schemas/onchain_operations_gen_passport.schema.json +21 -17
- package/dist/schemas/onchain_operations_guard.schema.json +11 -9
- package/dist/schemas/onchain_operations_machine.schema.json +11 -9
- package/dist/schemas/onchain_operations_order.schema.json +11 -9
- package/dist/schemas/onchain_operations_payment.schema.json +11 -9
- package/dist/schemas/onchain_operations_permission.schema.json +11 -9
- package/dist/schemas/onchain_operations_personal.schema.json +11 -9
- package/dist/schemas/onchain_operations_progress.schema.json +11 -9
- package/dist/schemas/onchain_operations_repository.schema.json +11 -9
- package/dist/schemas/onchain_operations_reward.schema.json +11 -9
- package/dist/schemas/onchain_operations_service.schema.json +11 -9
- package/dist/schemas/onchain_operations_treasury.schema.json +11 -9
- package/dist/schemas/onchain_table_data.output.json +3 -0
- package/dist/schemas/query_toolkit.schema.json +5 -1
- package/dist/telemetry/index.d.ts +19 -0
- package/dist/telemetry/index.js +112 -0
- package/dist/telemetry/redact.d.ts +2 -0
- package/dist/telemetry/redact.js +23 -0
- package/dist/telemetry/storage.d.ts +8 -0
- package/dist/telemetry/storage.js +80 -0
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -7,7 +7,27 @@ import { resolve } from "path";
|
|
|
7
7
|
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
8
8
|
import { MachineNode2File_InputSchema, MachineNode2File_OutputWrappedSchema, Guard2File_InputSchema, Guard2File_OutputWrappedSchema, strictParse, CallOutputSchema, handleCallResult, createServerConfig, createCapabilitiesConfig, createToolMeta, transformSubmission, getEnvConfig, OnchainEventsInputSchema, OnchainEventsResultSchema, ProtocolInfoQuerySchema, ProtocolInfoResultSchema, AccountOperationOutputWrappedSchema, LocalMarkOperationOutputWrappedSchema, LocalInfoOperationOutputWrappedSchema, WipOperationOutputSchema, MessengerOperationOutputSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, parseMachineNodesFromText, formatNodeErrors as formatMachineNodeErrors, MessengerOperationInputSchema, BridgeOperationsSchema, BridgeCallOutputSchema, OnchainOperationsSchema, WipOperationsSchema, OnchainTableDataSchema, OnchainTableDataResultSchema, WatchQueryOperationsSchema, } from "./schema/index.js";
|
|
9
9
|
import { handleBridgeOperations } from "./schema/call/bridge-handler.js";
|
|
10
|
-
import {
|
|
10
|
+
import { buildDataSemantic, classifyError } from "./schema/call/semantic.js";
|
|
11
|
+
import { getHarness } from "./harness/index.js";
|
|
12
|
+
const HARNESS_ENABLED = process.env.WOWOK_HARNESS_ENABLED === "1" || process.env.WOWOK_HARNESS_ENABLED === "true";
|
|
13
|
+
function withHarness(base, operation, intent) {
|
|
14
|
+
if (!HARNESS_ENABLED)
|
|
15
|
+
return base;
|
|
16
|
+
try {
|
|
17
|
+
const harness = getHarness();
|
|
18
|
+
const expected = harness.expect(operation, intent, base.operation_type, base.data);
|
|
19
|
+
return {
|
|
20
|
+
...base,
|
|
21
|
+
harness,
|
|
22
|
+
expected,
|
|
23
|
+
operation_id: `${base.operation_type}_${Date.now()}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return base;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
import { CallService, CallMachine, CallProgress, CallPermission, CallGuard, CallArbitration, CallRepository, CallContact, CallTreasury, CallReward, CallAllocation, CallPersonal, CallPayment, CallDemand, CallOrder, gen_passport, CallProof, gen_proof, guard2file, parseGuardFile, formatGuardParseErrors, machineNode2file, generateNodeComments, generate_wip, verify_wip, sign_wip, wip2html, account_operation, local_mark_operation, local_info_operation, watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, pull_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, mark_messages_as_viewed, mark_conversation_as_viewed, query_local_mark_list, query_account_list, query_local_info_list, query_local_token_list, query_account, GetLocalNamesByAddresses, query_personal, query_objects, query_table, query_tableItem, queryProtocolInfo, query_received, queryTableItem_RepositoryData, queryTableItem_PermissionPerm, queryTableItem_RewardRecord, queryTableItem_DemandPresenter, queryTableItem_TreasuryHistory, queryTableItem_MachineNode, queryTableItem_ProgressHistory, queryTableItem_AddressMark, queryTableItem_EntityRegistrar, queryTableItem_EntityLinker, query_events, blacklist, friendslist, guardlist, settings, AmountType, } from "@wowok/wowok";
|
|
11
31
|
import { areSchemasAvailable, getSchemaIndex, processSchemaQuery, } from "./schema-query/index.js";
|
|
12
32
|
const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
|
|
13
33
|
|
|
@@ -117,6 +137,13 @@ Token amounts are HIGHLY SENSITIVE. Always:
|
|
|
117
137
|
- machineNode2file
|
|
118
138
|
`;
|
|
119
139
|
const server = new McpServer(createServerConfig(packageJson, SERVER_DESCRIPTION), createCapabilitiesConfig());
|
|
140
|
+
import { withTelemetry, setTelemetryEnabled } from "./telemetry/index.js";
|
|
141
|
+
if (process.env.WOWOK_TELEMETRY === "false" || process.env.WOWOK_TELEMETRY === "0") {
|
|
142
|
+
setTelemetryEnabled(false);
|
|
143
|
+
}
|
|
144
|
+
function reg(name, config, handler) {
|
|
145
|
+
server.registerTool(name, config, withTelemetry(name, handler));
|
|
146
|
+
}
|
|
120
147
|
function convertAmountType(type) {
|
|
121
148
|
if (typeof type === "number")
|
|
122
149
|
return type;
|
|
@@ -223,10 +250,17 @@ async function handleOnchainTableData(args) {
|
|
|
223
250
|
}
|
|
224
251
|
return {
|
|
225
252
|
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
226
|
-
structuredContent: {
|
|
253
|
+
structuredContent: {
|
|
254
|
+
result,
|
|
255
|
+
semantic: buildDataSemantic(result, {
|
|
256
|
+
operation_type: "onchain_table_data",
|
|
257
|
+
data: validated,
|
|
258
|
+
}),
|
|
259
|
+
},
|
|
227
260
|
};
|
|
228
261
|
}
|
|
229
262
|
async function handleOnchainOperations(args) {
|
|
263
|
+
let validated;
|
|
230
264
|
try {
|
|
231
265
|
if (typeof args === 'object' && args !== null && args.description && !args.operation_type) {
|
|
232
266
|
const hasWrappedParams = typeof args.description === 'string' &&
|
|
@@ -237,7 +271,7 @@ async function handleOnchainOperations(args) {
|
|
|
237
271
|
"Incorrect format: { description: '{ operation_type: ... }' }");
|
|
238
272
|
}
|
|
239
273
|
}
|
|
240
|
-
|
|
274
|
+
validated = strictParse(OnchainOperationsSchema, args, "onchain_operations input");
|
|
241
275
|
const env = getEnvConfig(validated.env);
|
|
242
276
|
switch (validated.operation_type) {
|
|
243
277
|
case "service": {
|
|
@@ -245,7 +279,9 @@ async function handleOnchainOperations(args) {
|
|
|
245
279
|
const result = validated.submission
|
|
246
280
|
? await callService.call_with_submission(env, await transformSubmission(validated.submission))
|
|
247
281
|
: await callService.call(env);
|
|
248
|
-
|
|
282
|
+
const data = validated.data;
|
|
283
|
+
const intent = data?.publish ? "publish service" : data?.bPublished !== undefined ? "modify service" : "create service";
|
|
284
|
+
return handleCallResult(result, withHarness({ operation_type: validated.operation_type, data }, "service", intent));
|
|
249
285
|
}
|
|
250
286
|
case "machine": {
|
|
251
287
|
if (validated.data.node && typeof validated.data.node === 'object' && 'json_or_markdown_file' in validated.data.node) {
|
|
@@ -276,42 +312,42 @@ async function handleOnchainOperations(args) {
|
|
|
276
312
|
const result = validated.submission
|
|
277
313
|
? await callMachine.call_with_submission(env, await transformSubmission(validated.submission))
|
|
278
314
|
: await callMachine.call(env);
|
|
279
|
-
return handleCallResult(result);
|
|
315
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
280
316
|
}
|
|
281
317
|
case "progress": {
|
|
282
318
|
const callProgress = new CallProgress(validated.data);
|
|
283
319
|
const result = validated.submission
|
|
284
320
|
? await callProgress.call_with_submission(env, await transformSubmission(validated.submission))
|
|
285
321
|
: await callProgress.call(env);
|
|
286
|
-
return handleCallResult(result);
|
|
322
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
287
323
|
}
|
|
288
324
|
case "repository": {
|
|
289
325
|
const callRepository = new CallRepository(validated.data);
|
|
290
326
|
const result = validated.submission
|
|
291
327
|
? await callRepository.call_with_submission(env, await transformSubmission(validated.submission))
|
|
292
328
|
: await callRepository.call(env);
|
|
293
|
-
return handleCallResult(result);
|
|
329
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
294
330
|
}
|
|
295
331
|
case "arbitration": {
|
|
296
332
|
const callArbitration = new CallArbitration(validated.data);
|
|
297
333
|
const result = validated.submission
|
|
298
334
|
? await callArbitration.call_with_submission(env, await transformSubmission(validated.submission))
|
|
299
335
|
: await callArbitration.call(env);
|
|
300
|
-
return handleCallResult(result);
|
|
336
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
301
337
|
}
|
|
302
338
|
case "contact": {
|
|
303
339
|
const callContact = new CallContact(validated.data);
|
|
304
340
|
const result = validated.submission
|
|
305
341
|
? await callContact.call_with_submission(env, await transformSubmission(validated.submission))
|
|
306
342
|
: await callContact.call(env);
|
|
307
|
-
return handleCallResult(result);
|
|
343
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
308
344
|
}
|
|
309
345
|
case "treasury": {
|
|
310
346
|
const callTreasury = new CallTreasury(validated.data);
|
|
311
347
|
const result = validated.submission
|
|
312
348
|
? await callTreasury.call_with_submission(env, await transformSubmission(validated.submission))
|
|
313
349
|
: await callTreasury.call(env);
|
|
314
|
-
return handleCallResult(result);
|
|
350
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
315
351
|
}
|
|
316
352
|
case "reward": {
|
|
317
353
|
const transformedData = transformRewardData(validated.data);
|
|
@@ -319,19 +355,19 @@ async function handleOnchainOperations(args) {
|
|
|
319
355
|
const result = validated.submission
|
|
320
356
|
? await callReward.call_with_submission(env, await transformSubmission(validated.submission))
|
|
321
357
|
: await callReward.call(env);
|
|
322
|
-
return handleCallResult(result);
|
|
358
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
323
359
|
}
|
|
324
360
|
case "allocation": {
|
|
325
361
|
const callAllocation = new CallAllocation(validated.data);
|
|
326
362
|
const result = validated.submission
|
|
327
363
|
? await callAllocation.call_with_submission(env, await transformSubmission(validated.submission))
|
|
328
364
|
: await callAllocation.call(env);
|
|
329
|
-
return handleCallResult(result);
|
|
365
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
330
366
|
}
|
|
331
367
|
case "permission": {
|
|
332
368
|
const callPermission = new CallPermission(validated.data);
|
|
333
369
|
const result = await callPermission.call(env);
|
|
334
|
-
return handleCallResult(result);
|
|
370
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
335
371
|
}
|
|
336
372
|
case "guard": {
|
|
337
373
|
const validatedData = validated.data;
|
|
@@ -378,7 +414,7 @@ async function handleOnchainOperations(args) {
|
|
|
378
414
|
}
|
|
379
415
|
const callGuard = new CallGuard(validatedData);
|
|
380
416
|
const result = await callGuard.call(env);
|
|
381
|
-
return handleCallResult(result);
|
|
417
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
382
418
|
}
|
|
383
419
|
case "personal": {
|
|
384
420
|
const transformPersonalData = (data) => {
|
|
@@ -431,52 +467,56 @@ async function handleOnchainOperations(args) {
|
|
|
431
467
|
const transformedData = transformPersonalData(validated.data);
|
|
432
468
|
const callPersonal = new CallPersonal(transformedData);
|
|
433
469
|
const result = await callPersonal.call(env);
|
|
434
|
-
return handleCallResult(result);
|
|
470
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
435
471
|
}
|
|
436
472
|
case "payment": {
|
|
437
473
|
const callPayment = new CallPayment(validated.data);
|
|
438
474
|
const result = await callPayment.call(env);
|
|
439
|
-
return handleCallResult(result);
|
|
475
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
440
476
|
}
|
|
441
477
|
case "demand": {
|
|
442
478
|
const callDemand = new CallDemand(validated.data);
|
|
443
479
|
const result = validated.submission
|
|
444
480
|
? await callDemand.call_with_submission(env, await transformSubmission(validated.submission))
|
|
445
481
|
: await callDemand.call(env);
|
|
446
|
-
return handleCallResult(result);
|
|
482
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
447
483
|
}
|
|
448
484
|
case "order": {
|
|
449
485
|
const callOrder = new CallOrder(validated.data);
|
|
450
486
|
const result = validated.submission
|
|
451
487
|
? await callOrder.call_with_submission(env, await transformSubmission(validated.submission))
|
|
452
488
|
: await callOrder.call(env);
|
|
453
|
-
return handleCallResult(result);
|
|
489
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
454
490
|
}
|
|
455
491
|
case "gen_passport": {
|
|
456
492
|
const result = await gen_passport(env, validated.guard, validated.info);
|
|
457
|
-
return handleCallResult(result);
|
|
493
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
494
|
+
}
|
|
495
|
+
case "proof": {
|
|
496
|
+
const callProof = new CallProof(validated.data);
|
|
497
|
+
const result = validated.submission
|
|
498
|
+
? await callProof.call_with_submission(env, await transformSubmission(validated.submission))
|
|
499
|
+
: await callProof.call(env);
|
|
500
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
501
|
+
}
|
|
502
|
+
case "gen_proof": {
|
|
503
|
+
const result = await gen_proof(env, validated.proof, validated.server_pubkey, validated.server_signature, validated.proof_type, validated.description, validated.item_count, validated.about_address);
|
|
504
|
+
return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data });
|
|
458
505
|
}
|
|
459
506
|
}
|
|
460
507
|
throw new Error(`Unknown on-chain operation type: ${validated.operation_type}`);
|
|
461
508
|
}
|
|
462
509
|
catch (error) {
|
|
463
510
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
464
|
-
return {
|
|
465
|
-
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
466
|
-
structuredContent: {
|
|
467
|
-
message: `Error: ${errorMessage}`,
|
|
468
|
-
result: {
|
|
469
|
-
type: "error",
|
|
470
|
-
error: errorMessage,
|
|
471
|
-
},
|
|
472
|
-
},
|
|
473
|
-
};
|
|
511
|
+
return handleCallResult({ error: errorMessage }, validated ? { operation_type: validated.operation_type, data: validated.data } : undefined);
|
|
474
512
|
}
|
|
475
513
|
}
|
|
476
514
|
async function handleAccountOperation(args) {
|
|
515
|
+
let validated;
|
|
477
516
|
try {
|
|
478
|
-
|
|
517
|
+
validated = strictParse(AccountOperationSchema, args, "account_operation input");
|
|
479
518
|
const result = await account_operation(validated);
|
|
519
|
+
const ctx = { operation_type: "account_" + validated.operation_type, data: validated };
|
|
480
520
|
return {
|
|
481
521
|
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
482
522
|
structuredContent: {
|
|
@@ -484,26 +524,35 @@ async function handleAccountOperation(args) {
|
|
|
484
524
|
status: "success",
|
|
485
525
|
data: result,
|
|
486
526
|
},
|
|
527
|
+
semantic: buildDataSemantic(result, ctx),
|
|
487
528
|
},
|
|
488
529
|
};
|
|
489
530
|
}
|
|
490
531
|
catch (error) {
|
|
491
532
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
533
|
+
const ctx = validated ? { operation_type: "account_" + validated.operation_type, data: validated } : undefined;
|
|
534
|
+
const classified = classifyError(errorMessage);
|
|
492
535
|
return {
|
|
493
536
|
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
494
537
|
structuredContent: {
|
|
495
538
|
result: {
|
|
496
539
|
status: "error",
|
|
497
540
|
error: errorMessage,
|
|
541
|
+
error_code: classified.error_code,
|
|
542
|
+
retryable: classified.retryable,
|
|
543
|
+
recovery_hint: classified.recovery_hint,
|
|
498
544
|
},
|
|
545
|
+
semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
|
|
499
546
|
},
|
|
500
547
|
};
|
|
501
548
|
}
|
|
502
549
|
}
|
|
503
550
|
async function handleMarkOperation(args) {
|
|
551
|
+
let validated;
|
|
504
552
|
try {
|
|
505
|
-
|
|
553
|
+
validated = strictParse(LocalMarkOperationSchema, args, "local_mark_operation input");
|
|
506
554
|
const result = await local_mark_operation(validated);
|
|
555
|
+
const ctx = { operation_type: "mark_" + validated.operation_type, data: validated };
|
|
507
556
|
return {
|
|
508
557
|
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
509
558
|
structuredContent: {
|
|
@@ -511,26 +560,35 @@ async function handleMarkOperation(args) {
|
|
|
511
560
|
status: "success",
|
|
512
561
|
data: result,
|
|
513
562
|
},
|
|
563
|
+
semantic: buildDataSemantic(result, ctx),
|
|
514
564
|
},
|
|
515
565
|
};
|
|
516
566
|
}
|
|
517
567
|
catch (error) {
|
|
518
568
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
569
|
+
const ctx = validated ? { operation_type: "mark_" + validated.operation_type, data: validated } : undefined;
|
|
570
|
+
const classified = classifyError(errorMessage);
|
|
519
571
|
return {
|
|
520
572
|
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
521
573
|
structuredContent: {
|
|
522
574
|
result: {
|
|
523
575
|
status: "error",
|
|
524
576
|
error: errorMessage,
|
|
577
|
+
error_code: classified.error_code,
|
|
578
|
+
retryable: classified.retryable,
|
|
579
|
+
recovery_hint: classified.recovery_hint,
|
|
525
580
|
},
|
|
581
|
+
semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
|
|
526
582
|
},
|
|
527
583
|
};
|
|
528
584
|
}
|
|
529
585
|
}
|
|
530
586
|
async function handleInfoOperation(args) {
|
|
587
|
+
let validated;
|
|
531
588
|
try {
|
|
532
|
-
|
|
589
|
+
validated = strictParse(LocalInfoOperationSchema, args, "local_info_operation input");
|
|
533
590
|
const result = await local_info_operation(validated);
|
|
591
|
+
const ctx = { operation_type: "local_info", data: validated };
|
|
534
592
|
return {
|
|
535
593
|
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
536
594
|
structuredContent: {
|
|
@@ -538,18 +596,25 @@ async function handleInfoOperation(args) {
|
|
|
538
596
|
status: "success",
|
|
539
597
|
data: result,
|
|
540
598
|
},
|
|
599
|
+
semantic: buildDataSemantic(result, ctx),
|
|
541
600
|
},
|
|
542
601
|
};
|
|
543
602
|
}
|
|
544
603
|
catch (error) {
|
|
545
604
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
605
|
+
const ctx = validated ? { operation_type: "local_info", data: validated } : undefined;
|
|
606
|
+
const classified = classifyError(errorMessage);
|
|
546
607
|
return {
|
|
547
608
|
content: [{ type: "text", text: `Error: ${errorMessage}` }],
|
|
548
609
|
structuredContent: {
|
|
549
610
|
result: {
|
|
550
611
|
status: "error",
|
|
551
612
|
error: errorMessage,
|
|
613
|
+
error_code: classified.error_code,
|
|
614
|
+
retryable: classified.retryable,
|
|
615
|
+
recovery_hint: classified.recovery_hint,
|
|
552
616
|
},
|
|
617
|
+
semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
|
|
553
618
|
},
|
|
554
619
|
};
|
|
555
620
|
}
|
|
@@ -674,7 +739,13 @@ async function handleWatchQueryOperations(args) {
|
|
|
674
739
|
}
|
|
675
740
|
return {
|
|
676
741
|
content: [{ type: "text", text: JSON.stringify({ result }) }],
|
|
677
|
-
structuredContent: {
|
|
742
|
+
structuredContent: {
|
|
743
|
+
result,
|
|
744
|
+
semantic: buildDataSemantic(result, {
|
|
745
|
+
operation_type: "query_toolkit",
|
|
746
|
+
data: validated,
|
|
747
|
+
}),
|
|
748
|
+
},
|
|
678
749
|
};
|
|
679
750
|
}
|
|
680
751
|
async function handleWowokInfo(args) {
|
|
@@ -700,7 +771,13 @@ async function handleOnchainEvents(args) {
|
|
|
700
771
|
});
|
|
701
772
|
return {
|
|
702
773
|
content: [{ type: "text", text: JSON.stringify({ result: queryResult }) }],
|
|
703
|
-
structuredContent: {
|
|
774
|
+
structuredContent: {
|
|
775
|
+
result: queryResult,
|
|
776
|
+
semantic: buildDataSemantic(queryResult, {
|
|
777
|
+
operation_type: "onchain_events",
|
|
778
|
+
data: validated,
|
|
779
|
+
}),
|
|
780
|
+
},
|
|
704
781
|
};
|
|
705
782
|
}
|
|
706
783
|
function normalizeAccountOrMark(input) {
|
|
@@ -852,6 +929,11 @@ async function handleMessengerOperation(args) {
|
|
|
852
929
|
result = { operation: "mark_conversation_as_viewed", result: markedCount };
|
|
853
930
|
break;
|
|
854
931
|
}
|
|
932
|
+
case "pull_messages": {
|
|
933
|
+
const messages = await pull_messages(validated.account, validated.limit);
|
|
934
|
+
result = { operation: "pull_messages", result: messages };
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
855
937
|
default:
|
|
856
938
|
throw new Error(`Unknown messenger operation: ${validated.operation}`);
|
|
857
939
|
}
|
|
@@ -938,15 +1020,15 @@ async function main() {
|
|
|
938
1020
|
else {
|
|
939
1021
|
console.error("Schema files not available. Run 'npm run generate:schemas' to generate them.");
|
|
940
1022
|
}
|
|
941
|
-
|
|
1023
|
+
reg("onchain_operations", {
|
|
942
1024
|
title: "βοΈ On-chain Operations",
|
|
943
|
-
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).",
|
|
1025
|
+
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), proof (on-chain proof objects), gen_proof (generate proof shortcut).",
|
|
944
1026
|
inputSchema: OnchainOperationsSchema,
|
|
945
1027
|
outputSchema: CallOutputSchema,
|
|
946
1028
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
947
|
-
_meta: createToolMeta("operation", ["service", "machine", "progress", "repository", "arbitration", "contact", "treasury", "reward", "allocation", "permission", "guard", "personal", "payment", "demand", "order", "gen_passport", "on-chain", "blockchain"]),
|
|
1029
|
+
_meta: createToolMeta("operation", ["service", "machine", "progress", "repository", "arbitration", "contact", "treasury", "reward", "allocation", "permission", "guard", "personal", "payment", "demand", "order", "gen_passport", "proof", "gen_proof", "on-chain", "blockchain"]),
|
|
948
1030
|
}, handleOnchainOperations);
|
|
949
|
-
|
|
1031
|
+
reg("account_operation", {
|
|
950
1032
|
title: "π LOCAL ONLY: Account - Wallet Management",
|
|
951
1033
|
description: "π 100% LOCAL, NEVER ON-CHAIN π Manage WoWok accounts locally on device: generate, suspend, resume, faucet-test, operate assets, sign data, etc.",
|
|
952
1034
|
inputSchema: AccountOperationSchema,
|
|
@@ -954,7 +1036,7 @@ async function main() {
|
|
|
954
1036
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
955
1037
|
_meta: createToolMeta("operation", ["account", "local", "private", "wallet", "off-chain"]),
|
|
956
1038
|
}, handleAccountOperation);
|
|
957
|
-
|
|
1039
|
+
reg("local_mark_operation", {
|
|
958
1040
|
title: "π LOCAL ONLY: LocalMark - Address Book Management",
|
|
959
1041
|
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.",
|
|
960
1042
|
inputSchema: LocalMarkOperationSchema,
|
|
@@ -962,7 +1044,7 @@ async function main() {
|
|
|
962
1044
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
963
1045
|
_meta: createToolMeta("operation", ["mark", "local", "private", "address-book", "off-chain"]),
|
|
964
1046
|
}, handleMarkOperation);
|
|
965
|
-
|
|
1047
|
+
reg("local_info_operation", {
|
|
966
1048
|
title: "π LOCAL ONLY: LocalInfo - Private Data Management",
|
|
967
1049
|
description: "100% LOCAL, NEVER ON-CHAIN π Manage sensitive personal information stored ONLY on your device: delivery addresses, phone numbers, contacts.",
|
|
968
1050
|
inputSchema: LocalInfoOperationSchema,
|
|
@@ -970,7 +1052,7 @@ async function main() {
|
|
|
970
1052
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
971
1053
|
_meta: createToolMeta("operation", ["info", "local", "private", "data-management", "off-chain"]),
|
|
972
1054
|
}, handleInfoOperation);
|
|
973
|
-
|
|
1055
|
+
reg("wip_file", {
|
|
974
1056
|
title: "π€ Witness Immutable Promise File Operations",
|
|
975
1057
|
description: "generate (create WIP files from markdown and images), verify (integrity check), sign (add signatures), or wip2html (convert to HTML).",
|
|
976
1058
|
inputSchema: WipOperationsSchema,
|
|
@@ -980,15 +1062,15 @@ async function main() {
|
|
|
980
1062
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
981
1063
|
_meta: createToolMeta("operation", ["wip", "promise", "file-generation", "verification", "signature", "local"]),
|
|
982
1064
|
}, handleWipOperations);
|
|
983
|
-
|
|
1065
|
+
reg("messenger_operation", {
|
|
984
1066
|
title: "π¬ Messenger Operations",
|
|
985
|
-
description: "WoWok encrypted messenger operations: watch conversations (with unread filtering, preview messages), send message, send file, watch messages (with viewed status filtering), extract zip messages, generate WTS, verify WTS, sign WTS, WTS to HTML, proof message on-chain, manage blacklist, friendslist, guardlist, settings, mark messages as viewed,
|
|
1067
|
+
description: "WoWok encrypted messenger operations: watch conversations (with unread filtering, preview messages), send message, send file, watch messages (with viewed status filtering), extract zip messages, generate WTS, verify WTS, sign WTS, WTS to HTML, proof message on-chain, manage blacklist, friendslist, guardlist, settings, mark messages as viewed, mark conversation as viewed, and pull messages from server.",
|
|
986
1068
|
inputSchema: MessengerOperationInputSchema,
|
|
987
1069
|
outputSchema: MessengerOperationOutputSchema,
|
|
988
1070
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
|
|
989
1071
|
_meta: createToolMeta("operation", ["messenger", "message", "file", "wts", "blacklist", "friendslist", "guardlist", "settings", "proof", "communication"]),
|
|
990
1072
|
}, handleMessengerOperation);
|
|
991
|
-
|
|
1073
|
+
reg("guard2file", {
|
|
992
1074
|
title: "π Guard to File - Export Guard Definition",
|
|
993
1075
|
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.",
|
|
994
1076
|
inputSchema: Guard2File_InputSchema,
|
|
@@ -996,7 +1078,7 @@ async function main() {
|
|
|
996
1078
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
997
1079
|
_meta: createToolMeta("generate file", ["guard", "export", "file", "json", "markdown", "on-chain"]),
|
|
998
1080
|
}, handleGuard2File);
|
|
999
|
-
|
|
1081
|
+
reg("machineNode2file", {
|
|
1000
1082
|
title: "βοΈ Machine Node to File - Export Machine Node Definition",
|
|
1001
1083
|
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.",
|
|
1002
1084
|
inputSchema: MachineNode2File_InputSchema,
|
|
@@ -1004,12 +1086,12 @@ async function main() {
|
|
|
1004
1086
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1005
1087
|
_meta: createToolMeta("generate file", ["machine", "export", "file", "json", "markdown", "on-chain", "workflow"]),
|
|
1006
1088
|
}, handleMachineNode2File);
|
|
1007
|
-
|
|
1089
|
+
reg("query_toolkit", {
|
|
1008
1090
|
title: "π Data Query Toolkit",
|
|
1009
1091
|
description: "WOWOK data query toolkit β 9 query types covering local device data and on-chain blockchain data:\n\n"
|
|
1010
1092
|
+ "LOCAL (device-only, never on-chain):\n"
|
|
1011
1093
|
+ "1. local_mark_list β Query your LOCAL address book: maps human-readable names to blockchain addresses with optional tags. Use to resolve namesβaddresses or find addresses by tag.\n"
|
|
1012
|
-
+ "2. account_list β Query your LOCAL accounts
|
|
1094
|
+
+ "2. account_list β Query your LOCAL accounts (addresses, messenger status, suspension state). Use filter.includePubkey=true to also include public keys. Use to discover available accounts before operations.\n"
|
|
1013
1095
|
+ "3. local_info_list β Query your LOCAL private info: sensitive data like delivery addresses, phone numbers, contacts stored ONLY on this device.\n"
|
|
1014
1096
|
+ "4. token_list β Query cached token metadata: symbol, decimals, icon URL, description for tokens previously fetched from chain. Use to look up token precision/decimals before performing token operations. Returns: TokenTypeInfo[] (type, alias, name, symbol, decimals, iconUrl).\n"
|
|
1015
1097
|
+ "5. account_balance β Query an account's coin balance OR paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Supports multi-token via token_type parameter.\n"
|
|
@@ -1026,7 +1108,7 @@ async function main() {
|
|
|
1026
1108
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1027
1109
|
_meta: createToolMeta("query", ["watch", "query", "on-chain", "local", "events", "objects", "tokens", "balance", "profile"]),
|
|
1028
1110
|
}, handleWatchQueryOperations);
|
|
1029
|
-
|
|
1111
|
+
reg("onchain_table_data", {
|
|
1030
1112
|
title: "π Watch WoWok On-chain Table Data Query",
|
|
1031
1113
|
description: "Query dynamic table data of on-chain objects β supports paginated table queries and specific table item lookups. Each table item belongs to a parent object type and has a specific meaning:\n\n"
|
|
1032
1114
|
+ "1. onchain_table β Paginated query of ANY object's dynamic fields table (Parent: any object). Returns all entries with keys, types, and object IDs. Use to explore all sub-items of an object.\n"
|
|
@@ -1046,7 +1128,7 @@ async function main() {
|
|
|
1046
1128
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1047
1129
|
_meta: createToolMeta("table query", ["on-chain", "table", "dynamic fields", "pagination", "repository", "permission", "reward", "demand", "treasury", "machine", "progress"]),
|
|
1048
1130
|
}, handleOnchainTableData);
|
|
1049
|
-
|
|
1131
|
+
reg("onchain_events", {
|
|
1050
1132
|
title: "π
Watch WoWok On-chain Events",
|
|
1051
1133
|
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.",
|
|
1052
1134
|
inputSchema: OnchainEventsInputSchema,
|
|
@@ -1054,7 +1136,7 @@ async function main() {
|
|
|
1054
1136
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1055
1137
|
_meta: createToolMeta("watch wowook events", ["events", "on-chain", "arbitration", "order", "progress", "demand", "entity"]),
|
|
1056
1138
|
}, handleOnchainEvents);
|
|
1057
|
-
|
|
1139
|
+
reg("wowok_buildin_info", {
|
|
1058
1140
|
title: "βΉοΈ WoWok Build-in Information",
|
|
1059
1141
|
description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'guard instructions', 'current network', 'value types', or 'mainnet bridge tokens'. For 'mainnet bridge tokens': returns cross-chain bridge tokens (ETH, WETH, WBTC, USDC, USDT) with each token's symbol, WOW-side type tag (wowTypeTag), EVM address, decimals, and description. The wowTypeTag (format {address}::{module}::{struct}) can be used directly as the `type_parameter` of Service / Treasury / Reward / Allocation objects to set their payment token β e.g. use USDT's wowTypeTag to create a Service that accepts USDT payments.",
|
|
1060
1142
|
inputSchema: ProtocolInfoQuerySchema,
|
|
@@ -1062,7 +1144,7 @@ async function main() {
|
|
|
1062
1144
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
1063
1145
|
_meta: createToolMeta("WoWok info", ["build-in", "constants", "permissions", "guard", "network", "value-types", "bridge-tokens"]),
|
|
1064
1146
|
}, handleWowokInfo);
|
|
1065
|
-
|
|
1147
|
+
reg("schema_query", {
|
|
1066
1148
|
title: "π Schema Query",
|
|
1067
1149
|
description: "Look up JSON Schemas for WoWok MCP tools and on-chain operations. " +
|
|
1068
1150
|
"This is the authoritative reference for exact parameter structures, types, and required fields. " +
|
|
@@ -1179,7 +1261,7 @@ async function main() {
|
|
|
1179
1261
|
structuredContent: response,
|
|
1180
1262
|
};
|
|
1181
1263
|
});
|
|
1182
|
-
|
|
1264
|
+
reg("bridge_operation", {
|
|
1183
1265
|
title: "π Bridge - Cross-Chain Operations",
|
|
1184
1266
|
description: "π Simplified cross-chain bridge between WOW and EVM (Ethereum mainnet). Only WOW mainnet provides cross-chain functionality.\n\n" +
|
|
1185
1267
|
"Key concepts (transparent to user):\n" +
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TelemetryEvent } from "../telemetry/index.js";
|
|
2
|
+
export interface ToolStats {
|
|
3
|
+
tool_name: string;
|
|
4
|
+
total_calls: number;
|
|
5
|
+
success_count: number;
|
|
6
|
+
failed_count: number;
|
|
7
|
+
pending_input_count: number;
|
|
8
|
+
success_rate: number;
|
|
9
|
+
avg_duration_ms: number;
|
|
10
|
+
p50_duration_ms: number;
|
|
11
|
+
p95_duration_ms: number;
|
|
12
|
+
semantic_hit_rate: number;
|
|
13
|
+
error_distribution: Record<string, number>;
|
|
14
|
+
top_error_messages: Array<{
|
|
15
|
+
message: string;
|
|
16
|
+
count: number;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export interface OperationStats {
|
|
20
|
+
operation_type: string;
|
|
21
|
+
total_calls: number;
|
|
22
|
+
success_rate: number;
|
|
23
|
+
semantic_hit_rate: number;
|
|
24
|
+
error_distribution: Record<string, number>;
|
|
25
|
+
}
|
|
26
|
+
export interface AggregatedStats {
|
|
27
|
+
aggregation_date: string;
|
|
28
|
+
total_events: number;
|
|
29
|
+
date_range: {
|
|
30
|
+
earliest: string;
|
|
31
|
+
latest: string;
|
|
32
|
+
};
|
|
33
|
+
per_tool: ToolStats[];
|
|
34
|
+
per_operation: OperationStats[];
|
|
35
|
+
overall: {
|
|
36
|
+
total_calls: number;
|
|
37
|
+
success_count: number;
|
|
38
|
+
failed_count: number;
|
|
39
|
+
success_rate: number;
|
|
40
|
+
semantic_hit_rate: number;
|
|
41
|
+
unknown_error_count: number;
|
|
42
|
+
unknown_error_rate: number;
|
|
43
|
+
avg_duration_ms: number;
|
|
44
|
+
};
|
|
45
|
+
error_code_distribution: Record<string, number>;
|
|
46
|
+
intent_distribution: Record<string, number>;
|
|
47
|
+
}
|
|
48
|
+
export declare function aggregateByTool(events: TelemetryEvent[]): ToolStats[];
|
|
49
|
+
export declare function aggregateByOperation(events: TelemetryEvent[]): OperationStats[];
|
|
50
|
+
export declare function aggregate(events: TelemetryEvent[]): AggregatedStats;
|