@wowok/agent-mcp 2.3.16 → 2.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/customer/index.d.ts +9 -0
  2. package/dist/customer/index.js +9 -0
  3. package/dist/customer/industry-risks.d.ts +4 -0
  4. package/dist/customer/industry-risks.js +14 -0
  5. package/dist/customer/user-preferences.d.ts +3 -0
  6. package/dist/customer/user-preferences.js +9 -0
  7. package/dist/experience/realtime-feedback.js +17 -0
  8. package/dist/index.js +360 -273
  9. package/dist/knowledge/acquisition-flywheel.d.ts +3 -0
  10. package/dist/knowledge/acquisition-flywheel.js +9 -0
  11. package/dist/knowledge/guard-ledger.d.ts +19 -0
  12. package/dist/knowledge/guard-ledger.js +219 -0
  13. package/dist/knowledge/guard-puzzle.d.ts +93 -0
  14. package/dist/knowledge/guard-puzzle.js +278 -0
  15. package/dist/knowledge/guard-risk.d.ts +60 -0
  16. package/dist/knowledge/guard-risk.js +474 -0
  17. package/dist/knowledge/guard-translation.d.ts +46 -0
  18. package/dist/knowledge/guard-translation.js +487 -0
  19. package/dist/knowledge/index.d.ts +13 -0
  20. package/dist/knowledge/index.js +13 -0
  21. package/dist/knowledge/industry-registry.d.ts +1 -2
  22. package/dist/knowledge/industry-registry.js +23 -3
  23. package/dist/knowledge/safety-rules.js +61 -0
  24. package/dist/knowledge/tool-constraints.js +12 -22
  25. package/dist/safety/confirm-gate.d.ts +4 -2
  26. package/dist/safety/confirm-gate.js +48 -4
  27. package/dist/schema/call/allocation.d.ts +24 -14
  28. package/dist/schema/call/arbitration.d.ts +142 -132
  29. package/dist/schema/call/base.d.ts +901 -43
  30. package/dist/schema/call/base.js +66 -2
  31. package/dist/schema/call/bridge-handler.js +15 -2
  32. package/dist/schema/call/bridge.d.ts +769 -1
  33. package/dist/schema/call/bridge.js +37 -0
  34. package/dist/schema/call/contact.d.ts +10 -0
  35. package/dist/schema/call/demand.d.ts +10 -0
  36. package/dist/schema/call/guard.d.ts +76 -46
  37. package/dist/schema/call/handler.js +46 -14
  38. package/dist/schema/call/machine.d.ts +158 -138
  39. package/dist/schema/call/order.d.ts +10 -0
  40. package/dist/schema/call/payment.d.ts +10 -0
  41. package/dist/schema/call/permission.d.ts +232 -222
  42. package/dist/schema/call/personal.d.ts +10 -0
  43. package/dist/schema/call/progress.d.ts +10 -0
  44. package/dist/schema/call/proof.d.ts +20 -0
  45. package/dist/schema/call/repository.d.ts +32 -22
  46. package/dist/schema/call/reward.d.ts +10 -0
  47. package/dist/schema/call/semantic.d.ts +9 -2
  48. package/dist/schema/call/semantic.js +409 -21
  49. package/dist/schema/call/service.d.ts +20 -10
  50. package/dist/schema/call/treasury.d.ts +10 -0
  51. package/dist/schema/config/index.d.ts +18 -0
  52. package/dist/schema/config/index.js +17 -0
  53. package/dist/schema/index.d.ts +6 -0
  54. package/dist/schema/index.js +5 -0
  55. package/dist/schema/local/index.d.ts +9 -9
  56. package/dist/schema/local/index.js +9 -0
  57. package/dist/schema/messenger/index.d.ts +350 -29
  58. package/dist/schema/messenger/index.js +17 -17
  59. package/dist/schema/operations.d.ts +1667 -545
  60. package/dist/schema/operations.js +91 -96
  61. package/dist/schema/project/index.d.ts +21 -0
  62. package/dist/schema/project/index.js +32 -0
  63. package/dist/schema/query/index.d.ts +1074 -168
  64. package/dist/schema/query/index.js +8 -8
  65. package/dist/schema/schema-query/index.d.ts +33 -0
  66. package/dist/schema/schema-query/index.js +36 -0
  67. package/dist/schema/schema-version.d.ts +25 -0
  68. package/dist/schema/schema-version.js +76 -0
  69. package/dist/schema/trust/index.d.ts +407 -0
  70. package/dist/schema/trust/index.js +113 -0
  71. package/dist/schemas/bridge_operation.output.json +224 -0
  72. package/dist/schemas/bridge_operation.schema.json +67 -8
  73. package/dist/schemas/config_operation.output.json +18 -0
  74. package/dist/schemas/config_operation.schema.json +34 -0
  75. package/dist/schemas/guard-node-schema.json +82 -0
  76. package/dist/schemas/guard2file.schema.json +8 -0
  77. package/dist/schemas/index.json +19 -1
  78. package/dist/schemas/machineNode2file.schema.json +8 -0
  79. package/dist/schemas/messenger_operation.output.json +224 -0
  80. package/dist/schemas/onchain_events.output.json +718 -0
  81. package/dist/schemas/onchain_operations.output.json +277 -2
  82. package/dist/schemas/onchain_operations.schema.json +19 -16
  83. package/dist/schemas/onchain_operations_allocation.schema.json +8 -0
  84. package/dist/schemas/onchain_operations_arbitration.schema.json +8 -0
  85. package/dist/schemas/onchain_operations_contact.schema.json +8 -0
  86. package/dist/schemas/onchain_operations_demand.schema.json +8 -0
  87. package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -0
  88. package/dist/schemas/onchain_operations_guard.schema.json +11 -16
  89. package/dist/schemas/onchain_operations_machine.schema.json +8 -0
  90. package/dist/schemas/onchain_operations_order.schema.json +8 -0
  91. package/dist/schemas/onchain_operations_payment.schema.json +8 -0
  92. package/dist/schemas/onchain_operations_permission.schema.json +8 -0
  93. package/dist/schemas/onchain_operations_personal.schema.json +8 -0
  94. package/dist/schemas/onchain_operations_progress.schema.json +8 -0
  95. package/dist/schemas/onchain_operations_repository.schema.json +8 -0
  96. package/dist/schemas/onchain_operations_reward.schema.json +8 -0
  97. package/dist/schemas/onchain_operations_service.schema.json +8 -0
  98. package/dist/schemas/onchain_operations_treasury.schema.json +8 -0
  99. package/dist/schemas/onchain_table_data.output.json +718 -0
  100. package/dist/schemas/project_operation.output.json +18 -0
  101. package/dist/schemas/project_operation.schema.json +42 -0
  102. package/dist/schemas/query_toolkit.schema.json +360 -368
  103. package/dist/schemas/schema_query.schema.json +6 -3
  104. package/dist/schemas/trust_score.output.json +327 -0
  105. package/dist/schemas/trust_score.schema.json +46 -0
  106. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
5
5
  import { readFileSync } from "fs";
6
6
  import { resolve } from "path";
7
7
  const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
8
- import { 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, registerSuccessHook, } from "./schema/index.js";
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, registerSuccessHook, SchemaQueryInputSchema, SchemaQueryOutputSchema, ProjectOperationInputSchema, ProjectOperationOutputSchema, ConfigOperationInputSchema, ConfigOperationOutputSchema, TrustScoreInputSchema, TrustScoreOutputSchema, checkClientSchemaCompatibility, } from "./schema/index.js";
9
9
  import { handleBridgeOperations } from "./schema/call/bridge-handler.js";
10
10
  import { buildDataSemantic, classifyError } from "./schema/call/semantic.js";
11
11
  import { getHarness } from "./harness/index.js";
@@ -13,7 +13,8 @@ import { confirmGate } from "./safety/confirm-gate.js";
13
13
  import { renderPreview } from "./safety/preview.js";
14
14
  import { isProjectServiceEnabled, normalize as projectNormalize, observe as projectObserve, queryProjects, queryProjectObjects, queryShareableObjects, queryDependencies, queryReferencedBy, queryPrePublishCheck, queryCrossProjectReferences, queryGraphStats, saveGraph, loadGraph, } from "./project/index.js";
15
15
  import { isEnabled as isRuntimeEnabled, listServices, getServiceInfo, toggle as toggleService, setEnabled as setServiceEnabled, reset as resetService, } from "./config/index.js";
16
- import { validateOperation, hasBlockingViolations, getWarningViolations, } from "./knowledge/index.js";
16
+ import { validateOperation, hasBlockingViolations, getWarningViolations, computeServiceTrustScore, } from "./knowledge/index.js";
17
+ import { assembleInfoPuzzle, assessRisk, } from "./customer/index.js";
17
18
  const HARNESS_ENABLED = () => isRuntimeEnabled("harness");
18
19
  function withHarness(base, operation, intent) {
19
20
  if (!HARNESS_ENABLED())
@@ -84,7 +85,7 @@ function buildConstraintError(operation_type, violations) {
84
85
  structuredContent: output,
85
86
  };
86
87
  }
87
- 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";
88
+ 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, transformRewardInput, transformPersonalInput, } from "@wowok/wowok";
88
89
  import { areSchemasAvailable, getSchemaIndex, processSchemaQuery, } from "./schema-query/index.js";
89
90
  const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
90
91
 
@@ -266,38 +267,6 @@ function wrapHandlerWithErrorShape(handler, timeoutMs, toolName, errorShapeBuild
266
267
  }
267
268
  };
268
269
  }
269
- function convertAmountType(type) {
270
- if (typeof type === "number")
271
- return type;
272
- const upperType = type.toUpperCase();
273
- if (upperType === "GUARDU64IDENTIFIER" || upperType === "GUARD_U64_IDENTIFIER") {
274
- return AmountType.GuardU64Identifier;
275
- }
276
- if (upperType === "FIXED") {
277
- return AmountType.Fixed;
278
- }
279
- return AmountType.Fixed;
280
- }
281
- function transformRewardData(data) {
282
- if (!data)
283
- return data;
284
- const transformed = { ...data };
285
- if (transformed.guard_add && Array.isArray(transformed.guard_add)) {
286
- transformed.guard_add = transformed.guard_add.map((guard) => {
287
- if (guard.amount && typeof guard.amount.type === "string") {
288
- return {
289
- ...guard,
290
- amount: {
291
- ...guard.amount,
292
- type: convertAmountType(guard.amount.type)
293
- }
294
- };
295
- }
296
- return guard;
297
- });
298
- }
299
- return transformed;
300
- }
301
270
  async function handleOnchainTableData(args) {
302
271
  const validated = strictParse(OnchainTableDataSchema, args, "onchain_table_data input");
303
272
  let result;
@@ -405,6 +374,17 @@ async function handleOnchainOperations(args) {
405
374
  return buildConstraintError(validated.operation_type, constraintViolations);
406
375
  }
407
376
  constraintWarnings = getWarningViolations(constraintViolations).map((v) => `[PRE-CHECK] ${v.message}`);
377
+ const clientSchemaVersion = env?.client_schema_version;
378
+ const schemaStrictMode = env?.schema_strict_mode;
379
+ const schemaCheck = clientSchemaVersion
380
+ ? checkClientSchemaCompatibility(clientSchemaVersion, { mode: schemaStrictMode ? "strict" : "warn" })
381
+ : undefined;
382
+ const buildCtx = (data) => ({
383
+ operation_type: validated.operation_type,
384
+ data,
385
+ pre_warnings: constraintWarnings.length ? constraintWarnings : undefined,
386
+ schema_check: schemaCheck,
387
+ });
408
388
  const projectEnvPrefix = env?.project;
409
389
  if (isProjectServiceEnabled()) {
410
390
  const pn = projectNormalize({
@@ -418,6 +398,8 @@ async function handleOnchainOperations(args) {
418
398
  delete env.confirmed;
419
399
  delete env.user_intent_phrases;
420
400
  delete env.project;
401
+ delete env.client_schema_version;
402
+ delete env.schema_strict_mode;
421
403
  }
422
404
  switch (validated.operation_type) {
423
405
  case "service": {
@@ -427,7 +409,7 @@ async function handleOnchainOperations(args) {
427
409
  : await callService.call(env);
428
410
  const data = validated.data;
429
411
  const intent = data?.publish ? "publish service" : data?.bPublished !== undefined ? "modify service" : "create service";
430
- return handleCallResult(result, withHarness({ operation_type: validated.operation_type, data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined }, "service", intent));
412
+ return handleCallResult(result, withHarness(buildCtx(data), "service", intent));
431
413
  }
432
414
  case "machine": {
433
415
  if (validated.data.node && typeof validated.data.node === 'object' && 'json_or_markdown_file' in validated.data.node) {
@@ -458,62 +440,62 @@ async function handleOnchainOperations(args) {
458
440
  const result = validated.submission
459
441
  ? await callMachine.call_with_submission(env, await transformSubmission(validated.submission))
460
442
  : await callMachine.call(env);
461
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
443
+ return handleCallResult(result, buildCtx(validated.data));
462
444
  }
463
445
  case "progress": {
464
446
  const callProgress = new CallProgress(validated.data);
465
447
  const result = validated.submission
466
448
  ? await callProgress.call_with_submission(env, await transformSubmission(validated.submission))
467
449
  : await callProgress.call(env);
468
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
450
+ return handleCallResult(result, buildCtx(validated.data));
469
451
  }
470
452
  case "repository": {
471
453
  const callRepository = new CallRepository(validated.data);
472
454
  const result = validated.submission
473
455
  ? await callRepository.call_with_submission(env, await transformSubmission(validated.submission))
474
456
  : await callRepository.call(env);
475
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
457
+ return handleCallResult(result, buildCtx(validated.data));
476
458
  }
477
459
  case "arbitration": {
478
460
  const callArbitration = new CallArbitration(validated.data);
479
461
  const result = validated.submission
480
462
  ? await callArbitration.call_with_submission(env, await transformSubmission(validated.submission))
481
463
  : await callArbitration.call(env);
482
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
464
+ return handleCallResult(result, buildCtx(validated.data));
483
465
  }
484
466
  case "contact": {
485
467
  const callContact = new CallContact(validated.data);
486
468
  const result = validated.submission
487
469
  ? await callContact.call_with_submission(env, await transformSubmission(validated.submission))
488
470
  : await callContact.call(env);
489
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
471
+ return handleCallResult(result, buildCtx(validated.data));
490
472
  }
491
473
  case "treasury": {
492
474
  const callTreasury = new CallTreasury(validated.data);
493
475
  const result = validated.submission
494
476
  ? await callTreasury.call_with_submission(env, await transformSubmission(validated.submission))
495
477
  : await callTreasury.call(env);
496
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
478
+ return handleCallResult(result, buildCtx(validated.data));
497
479
  }
498
480
  case "reward": {
499
- const transformedData = transformRewardData(validated.data);
481
+ const transformedData = transformRewardInput(validated.data);
500
482
  const callReward = new CallReward(transformedData);
501
483
  const result = validated.submission
502
484
  ? await callReward.call_with_submission(env, await transformSubmission(validated.submission))
503
485
  : await callReward.call(env);
504
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
486
+ return handleCallResult(result, buildCtx(validated.data));
505
487
  }
506
488
  case "allocation": {
507
489
  const callAllocation = new CallAllocation(validated.data);
508
490
  const result = validated.submission
509
491
  ? await callAllocation.call_with_submission(env, await transformSubmission(validated.submission))
510
492
  : await callAllocation.call(env);
511
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
493
+ return handleCallResult(result, buildCtx(validated.data));
512
494
  }
513
495
  case "permission": {
514
496
  const callPermission = new CallPermission(validated.data);
515
497
  const result = await callPermission.call(env);
516
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
498
+ return handleCallResult(result, buildCtx(validated.data));
517
499
  }
518
500
  case "guard": {
519
501
  const validatedData = validated.data;
@@ -560,217 +542,120 @@ async function handleOnchainOperations(args) {
560
542
  }
561
543
  const callGuard = new CallGuard(validatedData);
562
544
  const result = await callGuard.call(env);
563
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
545
+ return handleCallResult(result, buildCtx(validated.data));
564
546
  }
565
547
  case "personal": {
566
- const transformPersonalData = (data) => {
567
- const result = { ...data };
568
- if (data.mark) {
569
- const transformAddress = (addr) => {
570
- if (typeof addr === 'string') {
571
- return { name_or_address: addr, local_mark_first: true };
572
- }
573
- return addr;
574
- };
575
- if (data.mark.op === 'add' && data.mark.data) {
576
- result.mark = {
577
- ...data.mark,
578
- data: data.mark.data.map((item) => ({
579
- ...item,
580
- address: transformAddress(item.address)
581
- }))
582
- };
583
- }
584
- else if (data.mark.op === 'remove' && data.mark.data) {
585
- result.mark = {
586
- ...data.mark,
587
- data: data.mark.data.map((item) => ({
588
- ...item,
589
- address: transformAddress(item.address)
590
- }))
591
- };
592
- }
593
- else if (data.mark.op === 'clear' && data.mark.address) {
594
- const addr = data.mark.address;
595
- if (Array.isArray(addr) && addr.every((a) => typeof a === 'string')) {
596
- result.mark = {
597
- ...data.mark,
598
- address: {
599
- entities: addr.map((a) => ({ name_or_address: a, local_mark_first: true }))
600
- }
601
- };
602
- }
603
- }
604
- else if (data.mark.op === 'transfer' && data.mark.to) {
605
- result.mark = {
606
- ...data.mark,
607
- to: transformAddress(data.mark.to)
608
- };
609
- }
610
- }
611
- return result;
612
- };
613
- const transformedData = transformPersonalData(validated.data);
548
+ const transformedData = transformPersonalInput(validated.data);
614
549
  const callPersonal = new CallPersonal(transformedData);
615
550
  const result = await callPersonal.call(env);
616
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
551
+ return handleCallResult(result, buildCtx(validated.data));
617
552
  }
618
553
  case "payment": {
619
554
  const callPayment = new CallPayment(validated.data);
620
555
  const result = await callPayment.call(env);
621
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
556
+ return handleCallResult(result, buildCtx(validated.data));
622
557
  }
623
558
  case "demand": {
624
559
  const callDemand = new CallDemand(validated.data);
625
560
  const result = validated.submission
626
561
  ? await callDemand.call_with_submission(env, await transformSubmission(validated.submission))
627
562
  : await callDemand.call(env);
628
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
563
+ return handleCallResult(result, buildCtx(validated.data));
629
564
  }
630
565
  case "order": {
631
566
  const callOrder = new CallOrder(validated.data);
632
567
  const result = validated.submission
633
568
  ? await callOrder.call_with_submission(env, await transformSubmission(validated.submission))
634
569
  : await callOrder.call(env);
635
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
570
+ return handleCallResult(result, buildCtx(validated.data));
636
571
  }
637
572
  case "gen_passport": {
638
573
  const result = await gen_passport(env, validated.guard, validated.info);
639
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
574
+ return handleCallResult(result, buildCtx(validated.data));
640
575
  }
641
576
  case "proof": {
642
577
  const callProof = new CallProof(validated.data);
643
578
  const result = validated.submission
644
579
  ? await callProof.call_with_submission(env, await transformSubmission(validated.submission))
645
580
  : await callProof.call(env);
646
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
581
+ return handleCallResult(result, buildCtx(validated.data));
647
582
  }
648
583
  case "gen_proof": {
649
584
  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);
650
- return handleCallResult(result, { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined });
585
+ return handleCallResult(result, buildCtx(validated.data));
651
586
  }
652
587
  }
653
588
  throw new Error(`Unknown on-chain operation type: ${validated.operation_type}`);
654
589
  }
655
590
  catch (error) {
656
591
  const errorMessage = error instanceof Error ? error.message : String(error);
657
- return handleCallResult({ error: errorMessage }, validated ? { operation_type: validated.operation_type, data: validated.data, pre_warnings: constraintWarnings.length ? constraintWarnings : undefined } : undefined);
658
- }
659
- }
660
- async function handleAccountOperation(args) {
661
- let validated;
662
- try {
663
- validated = strictParse(AccountOperationSchema, args, "account_operation input");
664
- const result = await account_operation(validated);
665
- const ctx = { operation_type: "account_" + validated.operation_type, data: validated };
666
- return {
667
- content: [{ type: "text", text: JSON.stringify(result) }],
668
- structuredContent: {
669
- result: {
670
- status: "success",
671
- data: result,
672
- },
673
- semantic: buildDataSemantic(result, ctx),
674
- },
675
- };
676
- }
677
- catch (error) {
678
- const errorMessage = error instanceof Error ? error.message : String(error);
679
- const ctx = validated ? { operation_type: "account_" + validated.operation_type, data: validated } : undefined;
680
- const classified = classifyError(errorMessage);
681
- const errorResult = {
682
- status: "error",
683
- error: errorMessage,
684
- };
685
- if (classified.error_code !== undefined)
686
- errorResult.error_code = classified.error_code;
687
- if (classified.retryable !== undefined)
688
- errorResult.retryable = classified.retryable;
689
- if (classified.recovery_hint !== undefined)
690
- errorResult.recovery_hint = classified.recovery_hint;
691
- return {
692
- content: [{ type: "text", text: `Error: ${errorMessage}` }],
693
- structuredContent: {
694
- result: errorResult,
695
- semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
696
- },
697
- };
592
+ return handleCallResult({ error: errorMessage }, validated ? {
593
+ operation_type: validated.operation_type,
594
+ data: validated.data,
595
+ } : undefined);
698
596
  }
699
597
  }
700
- async function handleMarkOperation(args) {
701
- let validated;
702
- try {
703
- validated = strictParse(LocalMarkOperationSchema, args, "local_mark_operation input");
704
- const result = await local_mark_operation(validated);
705
- const ctx = { operation_type: "mark_" + validated.operation_type, data: validated };
706
- return {
707
- content: [{ type: "text", text: JSON.stringify(result) }],
708
- structuredContent: {
709
- result: {
710
- status: "success",
711
- data: result,
598
+ function wrapLocalHandler(config) {
599
+ const { schema, operationFn, parseLabel, buildContext } = config;
600
+ return async (args) => {
601
+ let validated;
602
+ try {
603
+ validated = strictParse(schema, args, parseLabel);
604
+ const result = await operationFn(validated);
605
+ const ctx = buildContext(validated);
606
+ return {
607
+ content: [{ type: "text", text: JSON.stringify(result) }],
608
+ structuredContent: {
609
+ result: {
610
+ status: "success",
611
+ data: result,
612
+ },
613
+ semantic: buildDataSemantic(result, ctx),
712
614
  },
713
- semantic: buildDataSemantic(result, ctx),
714
- },
715
- };
716
- }
717
- catch (error) {
718
- const errorMessage = error instanceof Error ? error.message : String(error);
719
- const ctx = validated ? { operation_type: "mark_" + validated.operation_type, data: validated } : undefined;
720
- const classified = classifyError(errorMessage);
721
- const errorResult = { status: "error", error: errorMessage };
722
- if (classified.error_code !== undefined)
723
- errorResult.error_code = classified.error_code;
724
- if (classified.retryable !== undefined)
725
- errorResult.retryable = classified.retryable;
726
- if (classified.recovery_hint !== undefined)
727
- errorResult.recovery_hint = classified.recovery_hint;
728
- return {
729
- content: [{ type: "text", text: `Error: ${errorMessage}` }],
730
- structuredContent: {
731
- result: errorResult,
732
- semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
733
- },
734
- };
735
- }
736
- }
737
- async function handleInfoOperation(args) {
738
- let validated;
739
- try {
740
- validated = strictParse(LocalInfoOperationSchema, args, "local_info_operation input");
741
- const result = await local_info_operation(validated);
742
- const ctx = { operation_type: "local_info", data: validated };
743
- return {
744
- content: [{ type: "text", text: JSON.stringify(result) }],
745
- structuredContent: {
746
- result: {
747
- status: "success",
748
- data: result,
615
+ };
616
+ }
617
+ catch (error) {
618
+ const errorMessage = error instanceof Error ? error.message : String(error);
619
+ const ctx = validated ? buildContext(validated) : undefined;
620
+ const classified = classifyError(errorMessage);
621
+ const errorResult = {
622
+ status: "error",
623
+ error: errorMessage,
624
+ };
625
+ if (classified.error_code !== undefined)
626
+ errorResult.error_code = classified.error_code;
627
+ if (classified.retryable !== undefined)
628
+ errorResult.retryable = classified.retryable;
629
+ if (classified.recovery_hint !== undefined)
630
+ errorResult.recovery_hint = classified.recovery_hint;
631
+ return {
632
+ content: [{ type: "text", text: `Error: ${errorMessage}` }],
633
+ structuredContent: {
634
+ result: errorResult,
635
+ semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
749
636
  },
750
- semantic: buildDataSemantic(result, ctx),
751
- },
752
- };
753
- }
754
- catch (error) {
755
- const errorMessage = error instanceof Error ? error.message : String(error);
756
- const ctx = validated ? { operation_type: "local_info", data: validated } : undefined;
757
- const classified = classifyError(errorMessage);
758
- const errorResult = { status: "error", error: errorMessage };
759
- if (classified.error_code !== undefined)
760
- errorResult.error_code = classified.error_code;
761
- if (classified.retryable !== undefined)
762
- errorResult.retryable = classified.retryable;
763
- if (classified.recovery_hint !== undefined)
764
- errorResult.recovery_hint = classified.recovery_hint;
765
- return {
766
- content: [{ type: "text", text: `Error: ${errorMessage}` }],
767
- structuredContent: {
768
- result: errorResult,
769
- semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
770
- },
771
- };
772
- }
637
+ };
638
+ }
639
+ };
773
640
  }
641
+ const handleAccountOperation = wrapLocalHandler({
642
+ schema: AccountOperationSchema,
643
+ operationFn: account_operation,
644
+ parseLabel: "account_operation input",
645
+ buildContext: (validated) => ({ operation_type: "account_" + validated.operation_type, data: validated }),
646
+ });
647
+ const handleMarkOperation = wrapLocalHandler({
648
+ schema: LocalMarkOperationSchema,
649
+ operationFn: local_mark_operation,
650
+ parseLabel: "local_mark_operation input",
651
+ buildContext: (validated) => ({ operation_type: "mark_" + validated.operation_type, data: validated }),
652
+ });
653
+ const handleInfoOperation = wrapLocalHandler({
654
+ schema: LocalInfoOperationSchema,
655
+ operationFn: local_info_operation,
656
+ parseLabel: "local_info_operation input",
657
+ buildContext: (validated) => ({ operation_type: "local_info", data: validated }),
658
+ });
774
659
  async function handleWipOperations(args) {
775
660
  const validated = strictParse(WipOperationsSchema, args, "wip_file input");
776
661
  let structuredContent;
@@ -995,47 +880,55 @@ async function handleConfigOperation(args) {
995
880
  const service = args.service;
996
881
  if (!service)
997
882
  throw new Error("'service' param is required for toggle");
998
- const validServices = ["confirm_gate", "project_service", "harness", "graph_persist", "semantic_rich"];
999
- if (!validServices.includes(service)) {
1000
- throw new Error(`Unknown service: ${service}. Valid: ${validServices.join(", ")}`);
883
+ const existing = getServiceInfo(service);
884
+ if (!existing) {
885
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
1001
886
  }
1002
887
  const newState = toggleService(service);
1003
- const info = getServiceInfo(service);
1004
- result = { service, enabled: newState, reminder: info?.reminder };
888
+ result = { service, enabled: newState, reminder: existing.reminder };
1005
889
  break;
1006
890
  }
1007
891
  case "enable": {
1008
892
  const service = args.service;
1009
893
  if (!service)
1010
894
  throw new Error("'service' param is required for enable");
895
+ const existing = getServiceInfo(service);
896
+ if (!existing)
897
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
1011
898
  setServiceEnabled(service, true);
1012
- const info = getServiceInfo(service);
1013
- result = { service, enabled: true, reminder: info?.reminder };
899
+ result = { service, enabled: true, reminder: existing.reminder };
1014
900
  break;
1015
901
  }
1016
902
  case "disable": {
1017
903
  const service = args.service;
1018
904
  if (!service)
1019
905
  throw new Error("'service' param is required for disable");
906
+ const existing = getServiceInfo(service);
907
+ if (!existing)
908
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
1020
909
  setServiceEnabled(service, false);
1021
- const info = getServiceInfo(service);
1022
- result = { service, enabled: false, reminder: info?.reminder };
910
+ result = { service, enabled: false, reminder: existing.reminder };
1023
911
  break;
1024
912
  }
1025
913
  case "reset": {
1026
914
  const service = args.service;
1027
915
  if (!service)
1028
916
  throw new Error("'service' param is required for reset");
917
+ const existing = getServiceInfo(service);
918
+ if (!existing)
919
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
1029
920
  resetService(service);
1030
- const info = getServiceInfo(service);
1031
- result = { service, enabled: info?.enabled, reminder: info?.reminder, reset: true };
921
+ result = { service, enabled: getServiceInfo(service)?.enabled, reminder: existing.reminder, reset: true };
1032
922
  break;
1033
923
  }
1034
924
  case "info": {
1035
925
  const service = args.service;
1036
926
  if (!service)
1037
927
  throw new Error("'service' param is required for info");
1038
- result = getServiceInfo(service);
928
+ const info = getServiceInfo(service);
929
+ if (!info)
930
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
931
+ result = info;
1039
932
  break;
1040
933
  }
1041
934
  default:
@@ -1046,6 +939,195 @@ async function handleConfigOperation(args) {
1046
939
  structuredContent: { result },
1047
940
  };
1048
941
  }
942
+ function extractTrustMetrics(serviceObj) {
943
+ const data = serviceObj?.data ?? serviceObj ?? {};
944
+ const sales = Array.isArray(data.sales) ? data.sales : [];
945
+ const activeSales = sales.filter((s) => s && !s.suspension);
946
+ const compensationFund = data.compensation_fund;
947
+ const compBalance = (() => {
948
+ if (compensationFund === null || compensationFund === undefined)
949
+ return undefined;
950
+ if (typeof compensationFund === "bigint")
951
+ return compensationFund;
952
+ if (typeof compensationFund === "number")
953
+ return BigInt(compensationFund);
954
+ if (typeof compensationFund === "string") {
955
+ try {
956
+ return BigInt(compensationFund);
957
+ }
958
+ catch {
959
+ return undefined;
960
+ }
961
+ }
962
+ if (typeof compensationFund === "object") {
963
+ const bal = compensationFund.balance;
964
+ if (bal === null || bal === undefined)
965
+ return undefined;
966
+ try {
967
+ return BigInt(bal);
968
+ }
969
+ catch {
970
+ return undefined;
971
+ }
972
+ }
973
+ return undefined;
974
+ })();
975
+ return {
976
+ arbitrationCases: Array.isArray(data.arbitrations) ? data.arbitrations.length : undefined,
977
+ compensationFundBalance: compBalance,
978
+ hasMachineBound: typeof data.machine === "string" && data.machine.length > 0,
979
+ hasBuyGuard: typeof data.buy_guard === "string" && data.buy_guard.length > 0,
980
+ };
981
+ }
982
+ function buildPuzzleRawData(serviceObj, orderAmount, trustScore, serviceOwner) {
983
+ const data = serviceObj?.data ?? serviceObj ?? {};
984
+ const sales = Array.isArray(data.sales) ? data.sales : [];
985
+ const order_allocators = data.order_allocators
986
+ ? Array.isArray(data.order_allocators.allocators)
987
+ ? data.order_allocators
988
+ : { allocators: data.order_allocators }
989
+ : undefined;
990
+ const serviceRaw = {
991
+ name: data.name ?? serviceObj?.id,
992
+ bPublished: data.bPublished,
993
+ bPaused: data.bPaused,
994
+ price: sales[0]?.price != null ? String(sales[0].price) : "0",
995
+ priceRaw: sales[0]?.price != null ? BigInt(sales[0].price) : 0n,
996
+ token_type: sales[0]?.price_type ?? (compensation_fund_token(data) ?? "0x2::wow::WOW"),
997
+ sales,
998
+ machine: data.machine ?? undefined,
999
+ buy_guard: data.buy_guard ?? undefined,
1000
+ customer_required: data.customer_required,
1001
+ arbitrations: data.arbitrations,
1002
+ compensation_fund: data.compensation_fund
1003
+ ? { balance: extractBalance(data.compensation_fund) }
1004
+ : undefined,
1005
+ compensation_lock_duration: typeof data.setting_lock_duration === "number"
1006
+ ? data.setting_lock_duration
1007
+ : undefined,
1008
+ um: data.um ?? undefined,
1009
+ order_allocators: order_allocators ? [order_allocators] : undefined,
1010
+ };
1011
+ return {
1012
+ service: serviceRaw,
1013
+ order_amount: orderAmount,
1014
+ trust_score: trustScore,
1015
+ service_owner: serviceOwner,
1016
+ };
1017
+ }
1018
+ function compensation_fund_token(data) {
1019
+ if (data?.compensation_fund && typeof data.compensation_fund === "object") {
1020
+ return data.compensation_fund.token_type;
1021
+ }
1022
+ return undefined;
1023
+ }
1024
+ function extractBalance(b) {
1025
+ if (b === null || b === undefined)
1026
+ return 0n;
1027
+ if (typeof b === "bigint")
1028
+ return b;
1029
+ if (typeof b === "number")
1030
+ return BigInt(b);
1031
+ if (typeof b === "string") {
1032
+ try {
1033
+ return BigInt(b);
1034
+ }
1035
+ catch {
1036
+ return 0n;
1037
+ }
1038
+ }
1039
+ if (typeof b === "object") {
1040
+ const bal = b.balance;
1041
+ if (bal === null || bal === undefined)
1042
+ return 0n;
1043
+ try {
1044
+ return BigInt(bal);
1045
+ }
1046
+ catch {
1047
+ return 0n;
1048
+ }
1049
+ }
1050
+ return 0n;
1051
+ }
1052
+ async function handleTrustScore(args) {
1053
+ const validated = strictParse(TrustScoreInputSchema, args, "trust_score input");
1054
+ const depth = (validated.depth ?? "evaluate");
1055
+ const queryResult = await query_objects({
1056
+ objects: [validated.service],
1057
+ no_cache: validated.no_cache,
1058
+ network: validated.network,
1059
+ });
1060
+ const objects = queryResult?.objects;
1061
+ if (!objects || !Array.isArray(objects) || objects.length === 0) {
1062
+ throw new Error(`Service object not found for '${validated.service}'. ` +
1063
+ `Verify the ID/name and network, or use query_toolkit with query_type='onchain_objects' to debug.`);
1064
+ }
1065
+ const serviceObj = objects[0];
1066
+ const objType = serviceObj?.data?.object_type ?? serviceObj?.object_type ?? serviceObj?.type;
1067
+ if (objType && typeof objType === "string" && !objType.includes("Service")) {
1068
+ throw new Error(`Object '${validated.service}' is not a Service (type: ${objType}). ` +
1069
+ `trust_score only evaluates Service objects.`);
1070
+ }
1071
+ const metrics = extractTrustMetrics(serviceObj);
1072
+ const trustScore = computeServiceTrustScore(metrics);
1073
+ const sales = Array.isArray(serviceObj?.data?.sales) ? serviceObj.data.sales : [];
1074
+ const activeSale = sales.find((s) => s && !s.suspension) ?? sales[0];
1075
+ const salePriceRaw = activeSale?.price != null ? BigInt(activeSale.price) : 0n;
1076
+ const orderAmount = validated.order_amount != null
1077
+ ? BigInt(validated.order_amount)
1078
+ : salePriceRaw;
1079
+ let riskScore = undefined;
1080
+ let infoPuzzle = undefined;
1081
+ if (depth === "evaluate" || depth === "preorder") {
1082
+ const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
1083
+ infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
1084
+ riskScore = assessRisk(infoPuzzle);
1085
+ }
1086
+ const result = {
1087
+ service_id: validated.service,
1088
+ service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
1089
+ service_basics: {
1090
+ bPublished: serviceObj?.data?.bPublished ?? false,
1091
+ bPaused: serviceObj?.data?.bPaused ?? false,
1092
+ sales_count: sales.filter((s) => s && !s.suspension).length,
1093
+ has_machine: !!serviceObj?.data?.machine,
1094
+ has_buy_guard: !!serviceObj?.data?.buy_guard,
1095
+ has_um_contact: !!serviceObj?.data?.um,
1096
+ arbitrations_count: Array.isArray(serviceObj?.data?.arbitrations)
1097
+ ? serviceObj.data.arbitrations.length
1098
+ : 0,
1099
+ },
1100
+ trust_score: {
1101
+ score: trustScore.score,
1102
+ level: trustScore.level,
1103
+ summary: trustScore.summary,
1104
+ warnings: trustScore.warnings,
1105
+ breakdown: trustScore.breakdown,
1106
+ },
1107
+ order_amount: orderAmount.toString(),
1108
+ depth,
1109
+ ...(riskScore ? {
1110
+ risk_score: {
1111
+ total: riskScore.total,
1112
+ level: riskScore.level,
1113
+ red_flags: riskScore.red_flags,
1114
+ advice: riskScore.advice,
1115
+ dimensions: riskScore.dimensions,
1116
+ },
1117
+ } : {}),
1118
+ ...(infoPuzzle ? {
1119
+ info_puzzle: {
1120
+ completeness: infoPuzzle.completeness,
1121
+ gaps: infoPuzzle.gaps,
1122
+ assembled_at: infoPuzzle.assembled_at,
1123
+ },
1124
+ } : {}),
1125
+ };
1126
+ return {
1127
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
1128
+ structuredContent: { result },
1129
+ };
1130
+ }
1049
1131
  function normalizeAccountOrMark(input) {
1050
1132
  if (typeof input === 'string') {
1051
1133
  return { name_or_address: input, local_mark_first: true };
@@ -1340,7 +1422,7 @@ async function main() {
1340
1422
  console.error(`Phase 2 active services: ${activeServices.join(", ") || "none"}`);
1341
1423
  reg("onchain_operations", {
1342
1424
  title: "⛓️ On-chain Operations",
1343
- 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).",
1425
+ 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).\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_operations' to retrieve the complete parameter schema. For individual operation schemas (e.g., 'onchain_operations_permission'), use schema_query with action='list_operations' to see all available operation schemas.",
1344
1426
  inputSchema: OnchainOperationsSchema,
1345
1427
  outputSchema: CallOutputSchema,
1346
1428
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
@@ -1348,7 +1430,7 @@ async function main() {
1348
1430
  }, handleOnchainOperations);
1349
1431
  reg("account_operation", {
1350
1432
  title: "🔒 LOCAL ONLY: Account - Wallet Management",
1351
- description: "🔒 100% LOCAL, NEVER ON-CHAIN 🔒 Manage WoWok accounts locally on device: generate, suspend, resume, faucet-test, operate assets, sign data, etc.",
1433
+ description: "🔒 100% LOCAL, NEVER ON-CHAIN 🔒 Manage WoWok accounts locally on device: generate, suspend, resume, faucet-test, operate assets, sign data, etc.\n\n💡 Schema hint: Use schema_query with action='get' and name='account_operation' to retrieve the exact parameter schema before calling.",
1352
1434
  inputSchema: AccountOperationSchema,
1353
1435
  outputSchema: AccountOperationOutputWrappedSchema,
1354
1436
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
@@ -1356,7 +1438,7 @@ async function main() {
1356
1438
  }, handleAccountOperation, statusErrorShape);
1357
1439
  reg("local_mark_operation", {
1358
1440
  title: "🔒 LOCAL ONLY: LocalMark - Address Book Management",
1359
- 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.",
1441
+ 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.\n\n💡 Schema hint: Use schema_query with action='get' and name='local_mark_operation' to retrieve the exact parameter schema before calling.",
1360
1442
  inputSchema: LocalMarkOperationSchema,
1361
1443
  outputSchema: LocalMarkOperationOutputWrappedSchema,
1362
1444
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
@@ -1364,7 +1446,7 @@ async function main() {
1364
1446
  }, handleMarkOperation, statusErrorShape);
1365
1447
  reg("local_info_operation", {
1366
1448
  title: "🔒 LOCAL ONLY: LocalInfo - Private Data Management",
1367
- description: "100% LOCAL, NEVER ON-CHAIN 🔒 Manage sensitive personal information stored ONLY on your device: delivery addresses, phone numbers, contacts.",
1449
+ description: "100% LOCAL, NEVER ON-CHAIN 🔒 Manage sensitive personal information stored ONLY on your device: delivery addresses, phone numbers, contacts.\n\n💡 Schema hint: Use schema_query with action='get' and name='local_info_operation' to retrieve the exact parameter schema before calling.",
1368
1450
  inputSchema: LocalInfoOperationSchema,
1369
1451
  outputSchema: LocalInfoOperationOutputWrappedSchema,
1370
1452
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
@@ -1372,7 +1454,7 @@ async function main() {
1372
1454
  }, handleInfoOperation, statusErrorShape);
1373
1455
  reg("wip_file", {
1374
1456
  title: "🤝 Witness Immutable Promise File Operations",
1375
- description: "generate (create WIP files from markdown and images), verify (integrity check), sign (add signatures), or wip2html (convert to HTML).",
1457
+ description: "generate (create WIP files from markdown and images), verify (integrity check), sign (add signatures), or wip2html (convert to HTML).\n\n💡 Schema hint: Use schema_query with action='get' and name='wip_file' to retrieve the exact parameter schema before calling.",
1376
1458
  inputSchema: WipOperationsSchema,
1377
1459
  outputSchema: z.object({
1378
1460
  result: WipOperationOutputSchema,
@@ -1382,7 +1464,7 @@ async function main() {
1382
1464
  }, handleWipOperations);
1383
1465
  reg("messenger_operation", {
1384
1466
  title: "💬 Messenger Operations",
1385
- 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.",
1467
+ 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.\n\n💡 Schema hint: Use schema_query with action='get' and name='messenger_operation' to retrieve the exact parameter schema before calling.",
1386
1468
  inputSchema: MessengerOperationInputSchema,
1387
1469
  outputSchema: MessengerOperationOutputSchema,
1388
1470
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
@@ -1390,7 +1472,7 @@ async function main() {
1390
1472
  }, handleMessengerOperation, operationErrorShape, 30000);
1391
1473
  reg("guard2file", {
1392
1474
  title: "📄 Guard to File - Export Guard Definition",
1393
- 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.",
1475
+ 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.\n\n💡 Schema hint: Use schema_query with action='get' and name='guard2file' to retrieve the exact parameter schema before calling.",
1394
1476
  inputSchema: Guard2File_InputSchema,
1395
1477
  outputSchema: Guard2File_OutputWrappedSchema,
1396
1478
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -1398,7 +1480,7 @@ async function main() {
1398
1480
  }, handleGuard2File, strictStatusErrorShape);
1399
1481
  reg("machineNode2file", {
1400
1482
  title: "⚙️ Machine Node to File - Export Machine Node Definition",
1401
- 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.",
1483
+ 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.\n\n💡 Schema hint: Use schema_query with action='get' and name='machineNode2file' to retrieve the exact parameter schema before calling.",
1402
1484
  inputSchema: MachineNode2File_InputSchema,
1403
1485
  outputSchema: MachineNode2File_OutputWrappedSchema,
1404
1486
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -1418,7 +1500,8 @@ async function main() {
1418
1500
  + "7. onchain_personal_profile — Query any user's PUBLIC on-chain profile: social links, reputation (likes/dislikes), personal info records, voting history, referrer.\n"
1419
1501
  + "8. onchain_objects — Batch query on-chain WOWOK objects by ID or name: supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more.\n"
1420
1502
  + "9. onchain_received — Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and type filter.\n\n"
1421
- + "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.",
1503
+ + "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.\n\n"
1504
+ + "💡 Schema hint: Use schema_query with action='get' and name='query_toolkit' to retrieve the exact parameter schema with all query types and field definitions.",
1422
1505
  inputSchema: WatchQueryOperationsSchema,
1423
1506
  outputSchema: z.object({
1424
1507
  result: z.unknown().describe("Query result — type depends on query_type. Local queries return arrays (MarkData[], AccountData[], InfoData[], TokenTypeInfo[]). account_balance returns { address, balance? | coin? }. Onchain queries return typed objects or undefined. onchain_received returns ReceivedBalance | ReceivedNormal[]."),
@@ -1441,7 +1524,8 @@ async function main() {
1441
1524
  + "9. onchain_table_item_machine_node — Query a workflow node definition from a Machine object's node table (Parent: Machine). Key: node name (string). Returns node configuration: pairs, forwards, guards, thresholds.\n"
1442
1525
  + "10. onchain_table_item_progress_history — Query a progress step record from a Progress object's history table (Parent: Progress). Key: sequence number (u64). Returns step details: node, next_node, session state, time.\n"
1443
1526
  + "11. onchain_table_item_address_mark — Query a PUBLIC on-chain name/tag mark from an AddressMark object's table (Parent: AddressMark). Key: address. Returns public labels: entity, name, tags[]. Unlike local marks, these are published on-chain.\n"
1444
- + "12. onchain_table_item_generic — Query a generic table item from ANY object's dynamic fields (Parent: any object). Supports arbitrary key types (address, u64, string, object ID, etc.). Use for custom objects and general-purpose table lookups. Returns: ObjectBase | undefined.",
1527
+ + "12. onchain_table_item_generic — Query a generic table item from ANY object's dynamic fields (Parent: any object). Supports arbitrary key types (address, u64, string, object ID, etc.). Use for custom objects and general-purpose table lookups. Returns: ObjectBase | undefined.\n\n"
1528
+ + "💡 Schema hint: Use schema_query with action='get' and name='onchain_table_data' to retrieve the exact parameter schema with all table item types and field definitions.",
1445
1529
  inputSchema: OnchainTableDataSchema,
1446
1530
  outputSchema: OnchainTableDataResultSchema,
1447
1531
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -1449,7 +1533,7 @@ async function main() {
1449
1533
  }, handleOnchainTableData);
1450
1534
  reg("onchain_events", {
1451
1535
  title: "📅 Watch WoWok On-chain Events",
1452
- 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.",
1536
+ 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.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_events' to retrieve the exact parameter schema with all event types and field definitions.",
1453
1537
  inputSchema: OnchainEventsInputSchema,
1454
1538
  outputSchema: OnchainEventsResultSchema,
1455
1539
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -1474,19 +1558,8 @@ async function main() {
1474
1558
  " 'get_output' - Fetch the output JSON Schema of a tool by name (e.g. 'onchain_operations'). Use with the 'name' param. Use this to understand a tool's return value structure.\n" +
1475
1559
  " 'search' - Find schemas by keyword, matching name/title/description. Use with the 'query' param.\n" +
1476
1560
  " 'list_operations' - Show only on-chain operation schemas (prefixed 'onchain_operations_'). Narrower than 'list'.",
1477
- inputSchema: z.object({
1478
- action: z.enum(["list", "get", "get_output", "search", "list_operations"])
1479
- .describe("Action to perform: 'list' to see all available schemas, 'get' to retrieve a specific input schema, 'get_output' to retrieve a tool's output schema, 'search' to find schemas by keyword, 'list_operations' to list all on-chain operations"),
1480
- name: z.string().optional().describe("Schema/tool name for 'get'/'get_output' action (e.g., 'onchain_operations', 'account_operation', 'onchain_operations_permission')"),
1481
- query: z.string().optional().describe("Search query for 'search' action"),
1482
- }),
1483
- outputSchema: z.object({
1484
- success: z.boolean().describe("Whether the request was successful"),
1485
- action: z.string().describe("The action that was performed"),
1486
- data: z.any().describe("Response data - JSON Schema object for 'get'/'get_output', array of schema info for 'list'/'search'/'list_operations'"),
1487
- message: z.string().describe("Human-readable message describing the result"),
1488
- suggestions: z.array(z.string()).optional().describe("Suggested next steps or alternatives"),
1489
- }),
1561
+ inputSchema: SchemaQueryInputSchema,
1562
+ outputSchema: SchemaQueryOutputSchema,
1490
1563
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1491
1564
  _meta: createToolMeta("schema", ["schema", "json-schema", "types", "structure", "validation", "reference"]),
1492
1565
  }, async (args) => {
@@ -1622,20 +1695,10 @@ async function main() {
1622
1695
  " • load_graph — Load the graph from file (restore after restart).\n\n" +
1623
1696
  "NOTE: The graph is in-memory by default. Use save_graph/load_graph for cross-session persistence " +
1624
1697
  "(or toggle graph_persist via config_operation for auto-save). " +
1625
- "list_projects/shareable always query local_mark (persistent).",
1626
- inputSchema: z.object({
1627
- action: z.enum([
1628
- "list_projects", "list_objects", "shareable",
1629
- "dependencies", "referenced_by", "pre_publish_check",
1630
- "cross_project_refs", "graph_stats",
1631
- "save_graph", "load_graph",
1632
- ]).describe("Query/action to perform"),
1633
- project: z.string().optional().describe("Project prefix (for list_objects)"),
1634
- object: z.string().optional().describe("Object name or address (for dependencies / referenced_by / pre_publish_check)"),
1635
- }),
1636
- outputSchema: z.object({
1637
- result: z.any().describe("Query result — shape depends on action"),
1638
- }),
1698
+ "list_projects/shareable always query local_mark (persistent).\n\n" +
1699
+ "💡 Schema hint: Use schema_query with action='get' and name='project_operation' to retrieve the exact parameter schema with all actions and field definitions.",
1700
+ inputSchema: ProjectOperationInputSchema,
1701
+ outputSchema: ProjectOperationOutputSchema,
1639
1702
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1640
1703
  _meta: createToolMeta("project", ["project", "namespace", "graph", "dag", "dependency", "reference", "organization"]),
1641
1704
  }, handleProjectOperation);
@@ -1656,19 +1719,43 @@ async function main() {
1656
1719
  " • project_service — Project Namespace + Dependency Graph (default ON)\n" +
1657
1720
  " • harness — L4 Verify/Recover Loop (default OFF)\n" +
1658
1721
  " • graph_persist — Graph Persistence to File (default OFF)\n" +
1659
- " • semantic_rich — Semantic Layer Enrichment Reminder (default ON)\n\n" +
1722
+ " • semantic_rich — Semantic Layer Enrichment Reminder (default ON)\n" +
1723
+ " • experience_layer — Real-time Experience Layer (Phase 2 Topic 2, default ON)\n" +
1724
+ " • customer_intelligence — Buyer Intelligence / Risk & Preference Alerts (Phase 3 C-3, default ON)\n" +
1725
+ " • order_monitor — In-progress Order Monitoring (Phase 3 C-3.2, default OFF)\n" +
1726
+ " • industry_evolution — Industry Specialization Evolution Flywheel (Phase 4, default ON)\n\n" +
1660
1727
  "NOTE: Toggles persist for the MCP process lifetime. Set WOWOK_RUNTIME_CONFIG_PERSIST=1 " +
1661
- "to persist across sessions to ~/.wowok/runtime-config.json.",
1662
- inputSchema: z.object({
1663
- action: z.enum(["list", "toggle", "enable", "disable", "reset", "info"]).describe("Config action to perform"),
1664
- service: z.string().optional().describe("Service name (required for toggle/enable/disable/reset/info)"),
1665
- }),
1666
- outputSchema: z.object({
1667
- result: z.any().describe("Config result — shape depends on action"),
1668
- }),
1728
+ "to persist across sessions to ~/.wowok/runtime-config.json.\n\n" +
1729
+ "💡 Schema hint: Use schema_query with action='get' and name='config_operation' to retrieve the exact parameter schema with all actions and field definitions.",
1730
+ inputSchema: ConfigOperationInputSchema,
1731
+ outputSchema: ConfigOperationOutputSchema,
1669
1732
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1670
1733
  _meta: createToolMeta("config", ["config", "toggle", "service", "runtime", "switch", "enable", "disable"]),
1671
1734
  }, handleConfigOperation);
1735
+ reg("trust_score", {
1736
+ title: "🛡️ Trust Score - Service Risk & Trust Assessment",
1737
+ description: "Proactively query the trust score and risk assessment of a Service object. " +
1738
+ "This is the standalone query form of the trust_score field that is otherwise only " +
1739
+ "passively injected into onchain_operations semantic output.\n\n" +
1740
+ "Returns:\n" +
1741
+ " • trust_score (0-100, 5 dimensions: arbitration/reviews/fulfillment/fund_safety/transparency)\n" +
1742
+ " • risk_score (4 dimensions: workflow/fund/trust/behavior, 100-point) when depth >= 'evaluate'\n" +
1743
+ " • info_puzzle completeness + gaps summary\n" +
1744
+ " • service_basics snapshot (published/paused/sales/guards/arbitrations)\n\n" +
1745
+ "Use this tool when the user asks 'is this service trustworthy?', 'should I buy from this merchant?', " +
1746
+ "'what's the risk of ordering this service?', or any explicit trust/risk inquiry about a Service.\n\n" +
1747
+ "Parameters:\n" +
1748
+ " • service (required) — Service object ID or local_mark name.\n" +
1749
+ " • order_amount (optional) — Order amount in smallest token unit (e.g. 2000000000 for 2 WOW). " +
1750
+ "Defaults to the service's first active sale price.\n" +
1751
+ " • depth (optional, default 'evaluate') — 'browse' (trust score only), 'evaluate' (+ risk assessment), " +
1752
+ "'preorder' (most thorough, includes market context dimension).\n\n" +
1753
+ "💡 Schema hint: Use schema_query with action='get' and name='trust_score' to retrieve the exact parameter schema.",
1754
+ inputSchema: TrustScoreInputSchema,
1755
+ outputSchema: TrustScoreOutputSchema,
1756
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1757
+ _meta: createToolMeta("trust", ["trust", "score", "risk", "service", "merchant", "reputation", "safety", "evaluate"]),
1758
+ }, handleTrustScore);
1672
1759
  const transport = new StdioServerTransport();
1673
1760
  await server.connect(transport);
1674
1761
  process.on("SIGINT", async () => {