@wowok/agent-mcp 2.3.14 → 2.3.16

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 (156) hide show
  1. package/dist/config/index.d.ts +1 -0
  2. package/dist/config/index.js +1 -0
  3. package/dist/config/runtime.d.ts +26 -0
  4. package/dist/config/runtime.js +217 -0
  5. package/dist/customer/industry-risks.d.ts +36 -0
  6. package/dist/customer/industry-risks.js +424 -0
  7. package/dist/customer/info-puzzle.d.ts +102 -0
  8. package/dist/customer/info-puzzle.js +312 -0
  9. package/dist/customer/order-monitor.d.ts +75 -0
  10. package/dist/customer/order-monitor.js +327 -0
  11. package/dist/customer/order-strategy.d.ts +36 -0
  12. package/dist/customer/order-strategy.js +373 -0
  13. package/dist/customer/post-purchase.d.ts +42 -0
  14. package/dist/customer/post-purchase.js +350 -0
  15. package/dist/customer/reminder-system.d.ts +42 -0
  16. package/dist/customer/reminder-system.js +295 -0
  17. package/dist/customer/risk-assessment.d.ts +8 -0
  18. package/dist/customer/risk-assessment.js +337 -0
  19. package/dist/customer/types.d.ts +193 -0
  20. package/dist/customer/types.js +13 -0
  21. package/dist/customer/user-preferences.d.ts +67 -0
  22. package/dist/customer/user-preferences.js +451 -0
  23. package/dist/experience/experience-reuse.d.ts +10 -0
  24. package/dist/experience/experience-reuse.js +103 -0
  25. package/dist/experience/index.d.ts +6 -0
  26. package/dist/experience/index.js +5 -0
  27. package/dist/experience/intent-distill.d.ts +3 -0
  28. package/dist/experience/intent-distill.js +83 -0
  29. package/dist/experience/realtime-feedback.d.ts +5 -0
  30. package/dist/experience/realtime-feedback.js +77 -0
  31. package/dist/experience/types.d.ts +50 -0
  32. package/dist/experience/types.js +1 -0
  33. package/dist/experience/user-profile.d.ts +25 -0
  34. package/dist/experience/user-profile.js +171 -0
  35. package/dist/index.js +570 -186
  36. package/dist/knowledge/acquisition-flywheel.d.ts +50 -0
  37. package/dist/knowledge/acquisition-flywheel.js +183 -0
  38. package/dist/knowledge/arbitration-trust.d.ts +24 -0
  39. package/dist/knowledge/arbitration-trust.js +117 -0
  40. package/dist/knowledge/audit-rules.d.ts +28 -0
  41. package/dist/knowledge/audit-rules.js +141 -0
  42. package/dist/knowledge/demand-matching.d.ts +29 -0
  43. package/dist/knowledge/demand-matching.js +132 -0
  44. package/dist/knowledge/dynamic-pricing.d.ts +31 -0
  45. package/dist/knowledge/dynamic-pricing.js +87 -0
  46. package/dist/knowledge/flywheel-loop.d.ts +87 -0
  47. package/dist/knowledge/flywheel-loop.js +378 -0
  48. package/dist/knowledge/glossary.d.ts +18 -0
  49. package/dist/knowledge/glossary.js +209 -0
  50. package/dist/knowledge/index.d.ts +64 -0
  51. package/dist/knowledge/index.js +66 -0
  52. package/dist/knowledge/industry-evolution.d.ts +82 -0
  53. package/dist/knowledge/industry-evolution.js +323 -0
  54. package/dist/knowledge/industry-generalizer.d.ts +17 -0
  55. package/dist/knowledge/industry-generalizer.js +381 -0
  56. package/dist/knowledge/industry-registry.d.ts +49 -0
  57. package/dist/knowledge/industry-registry.js +167 -0
  58. package/dist/knowledge/intent-metrics.d.ts +42 -0
  59. package/dist/knowledge/intent-metrics.js +566 -0
  60. package/dist/knowledge/process-model.d.ts +24 -0
  61. package/dist/knowledge/process-model.js +160 -0
  62. package/dist/knowledge/reputation-rules.d.ts +42 -0
  63. package/dist/knowledge/reputation-rules.js +99 -0
  64. package/dist/knowledge/reward-templates.d.ts +25 -0
  65. package/dist/knowledge/reward-templates.js +125 -0
  66. package/dist/knowledge/safety-rules.d.ts +36 -0
  67. package/dist/knowledge/safety-rules.js +171 -0
  68. package/dist/knowledge/tool-constraints.d.ts +30 -0
  69. package/dist/knowledge/tool-constraints.js +185 -0
  70. package/dist/knowledge/trust-metrics.d.ts +37 -0
  71. package/dist/knowledge/trust-metrics.js +138 -0
  72. package/dist/loop-engineering/diagnose.d.ts +3 -2
  73. package/dist/loop-engineering/diagnose.js +94 -0
  74. package/dist/loop-engineering/improve.d.ts +1 -1
  75. package/dist/loop-engineering/improve.js +52 -1
  76. package/dist/project/graph.d.ts +71 -0
  77. package/dist/project/graph.js +314 -0
  78. package/dist/project/index.d.ts +62 -0
  79. package/dist/project/index.js +167 -0
  80. package/dist/project/namespace.d.ts +62 -0
  81. package/dist/project/namespace.js +181 -0
  82. package/dist/project/query.d.ts +40 -0
  83. package/dist/project/query.js +110 -0
  84. package/dist/safety/confirm-gate.d.ts +15 -0
  85. package/dist/safety/confirm-gate.js +44 -0
  86. package/dist/safety/index.d.ts +3 -0
  87. package/dist/safety/index.js +3 -0
  88. package/dist/safety/preview.d.ts +2 -0
  89. package/dist/safety/preview.js +36 -0
  90. package/dist/schema/call/allocation.d.ts +15 -0
  91. package/dist/schema/call/arbitration.d.ts +111 -96
  92. package/dist/schema/call/base.d.ts +1070 -44
  93. package/dist/schema/call/base.js +69 -1
  94. package/dist/schema/call/bridge.d.ts +709 -52
  95. package/dist/schema/call/bridge.js +13 -2
  96. package/dist/schema/call/contact.d.ts +15 -0
  97. package/dist/schema/call/demand.d.ts +69 -54
  98. package/dist/schema/call/guard.d.ts +125 -80
  99. package/dist/schema/call/handler.d.ts +3 -0
  100. package/dist/schema/call/handler.js +14 -0
  101. package/dist/schema/call/machine.d.ts +830 -800
  102. package/dist/schema/call/order.d.ts +15 -0
  103. package/dist/schema/call/payment.d.ts +15 -0
  104. package/dist/schema/call/permission.d.ts +15 -0
  105. package/dist/schema/call/personal.d.ts +15 -0
  106. package/dist/schema/call/progress.d.ts +15 -0
  107. package/dist/schema/call/proof.d.ts +42 -12
  108. package/dist/schema/call/proof.js +3 -3
  109. package/dist/schema/call/repository.d.ts +91 -76
  110. package/dist/schema/call/reward.d.ts +45 -30
  111. package/dist/schema/call/semantic.d.ts +1 -0
  112. package/dist/schema/call/semantic.js +217 -0
  113. package/dist/schema/call/service.d.ts +407 -392
  114. package/dist/schema/call/treasury.d.ts +15 -0
  115. package/dist/schema/common/index.js +3 -3
  116. package/dist/schema/local/index.d.ts +228 -72
  117. package/dist/schema/local/index.js +33 -6
  118. package/dist/schema/messenger/index.d.ts +668 -50
  119. package/dist/schema/messenger/index.js +9 -0
  120. package/dist/schema/operations.d.ts +1693 -1369
  121. package/dist/schema/operations.js +2 -2
  122. package/dist/schema/query/index.d.ts +1614 -1614
  123. package/dist/schema/query/index.js +30 -27
  124. package/dist/schemas/account_operation.output.json +25 -16
  125. package/dist/schemas/account_operation.schema.json +1 -1
  126. package/dist/schemas/bridge_operation.output.json +520 -0
  127. package/dist/schemas/bridge_operation.schema.json +15 -0
  128. package/dist/schemas/guard2file.schema.json +15 -0
  129. package/dist/schemas/index.json +1 -1
  130. package/dist/schemas/local_info_operation.output.json +23 -0
  131. package/dist/schemas/local_info_operation.schema.json +1 -1
  132. package/dist/schemas/local_mark_operation.output.json +24 -1
  133. package/dist/schemas/local_mark_operation.schema.json +4 -4
  134. package/dist/schemas/machineNode2file.schema.json +15 -0
  135. package/dist/schemas/messenger_operation.output.json +528 -0
  136. package/dist/schemas/onchain_operations.output.json +350 -16
  137. package/dist/schemas/onchain_operations.schema.json +96 -23
  138. package/dist/schemas/onchain_operations_allocation.schema.json +15 -0
  139. package/dist/schemas/onchain_operations_arbitration.schema.json +15 -0
  140. package/dist/schemas/onchain_operations_contact.schema.json +15 -0
  141. package/dist/schemas/onchain_operations_demand.schema.json +15 -0
  142. package/dist/schemas/onchain_operations_gen_passport.schema.json +30 -0
  143. package/dist/schemas/onchain_operations_guard.schema.json +15 -0
  144. package/dist/schemas/onchain_operations_machine.schema.json +81 -23
  145. package/dist/schemas/onchain_operations_order.schema.json +15 -0
  146. package/dist/schemas/onchain_operations_payment.schema.json +15 -0
  147. package/dist/schemas/onchain_operations_permission.schema.json +15 -0
  148. package/dist/schemas/onchain_operations_personal.schema.json +15 -0
  149. package/dist/schemas/onchain_operations_progress.schema.json +15 -0
  150. package/dist/schemas/onchain_operations_repository.schema.json +15 -0
  151. package/dist/schemas/onchain_operations_reward.schema.json +15 -0
  152. package/dist/schemas/onchain_operations_service.schema.json +15 -0
  153. package/dist/schemas/onchain_operations_treasury.schema.json +15 -0
  154. package/dist/schemas/onchain_table_data.output.json +221 -69
  155. package/dist/schemas/onchain_table_data.schema.json +2 -2
  156. package/package.json +2 -2
@@ -1,3 +1,16 @@
1
+ import { auditService } from "../../knowledge/index.js";
2
+ import { getExperienceFeedback, recordOperationOutcome } from "../../experience/index.js";
3
+ import { isEnabled as isRuntimeEnabled, listServices } from "../../config/index.js";
4
+ import { generateReminders } from "../../customer/reminder-system.js";
5
+ import { getProfile } from "../../experience/user-profile.js";
6
+ import { injectEvolutionContext, recordIndustrySignal } from "../../knowledge/flywheel-loop.js";
7
+ function booleanFromSignals(positive, negative) {
8
+ if (positive)
9
+ return true;
10
+ if (negative)
11
+ return false;
12
+ return undefined;
13
+ }
1
14
  const ERROR_RULES = [
2
15
  {
3
16
  patterns: [/insufficient\s*(gas|balance|coin|fund)/i, /ENOTENOUGH/i, /not\s*enough\s*(coin|gas|balance)/i, /gas\s*budget/i],
@@ -11,6 +24,12 @@ const ERROR_RULES = [
11
24
  retryable: true,
12
25
  recovery_hint: "Retry the call; if it persists, switch RPC endpoint or check connectivity",
13
26
  },
27
+ {
28
+ patterns: [/faucet/i, /too\s*many\s*requests/i, /rate\s*limit/i, /429/i],
29
+ error_code: "network_error",
30
+ retryable: true,
31
+ recovery_hint: "Faucet rate limit hit (HTTP 429). Wait a few minutes and retry. To check existing balance, use account_balance query.",
32
+ },
14
33
  {
15
34
  patterns: [/guard.*(reject|fail|denied)/i, /verification\s*failed/i, /submission.*(invalid|fail|required)/i, /passport.*(invalid|fail)/i, /move[._-]?abort.*guard/i],
16
35
  error_code: "guard_rejected",
@@ -553,6 +572,13 @@ const NEXT_ACTION_RULES = [
553
572
  reason: "Order lifecycle: payment → allocation → completion",
554
573
  priority: "optional",
555
574
  },
575
+ {
576
+ when: (ot, data) => ot === "order" && data?.transfer_to !== undefined,
577
+ action: "inform the end customer about the supplier/sub-contractor who will fulfill this order",
578
+ reason: "O-5 procurement sub-order transparency: customers have the right to know who fulfills their order",
579
+ tool: "messenger_operation (notify customer)",
580
+ priority: "recommended",
581
+ },
556
582
  {
557
583
  when: (ot) => ot === "demand",
558
584
  action: "wait for presenter submissions or evaluate existing ones",
@@ -633,6 +659,10 @@ function inferWarnings(operation_type, data, _safeResult) {
633
659
  if (operation_type === "reward" && (data?.balance === "0" || data?.balance === 0)) {
634
660
  warnings.push("Reward pool balance is zero; claimants cannot withdraw");
635
661
  }
662
+ if (operation_type === "order" && data?.transfer_to !== undefined) {
663
+ warnings.push("[TRANSPARENCY] Order ownership is being transferred (likely to a supplier/sub-contractor). " +
664
+ "Ensure the end customer is informed about who fulfills their order — this builds trust and is required for procurement sub-orders.");
665
+ }
636
666
  return warnings;
637
667
  }
638
668
  function composeSummary(intent, status, created, modified, released) {
@@ -679,6 +709,92 @@ function shortCoinType(coinType) {
679
709
  const parts = coinType.split("::");
680
710
  return parts[parts.length - 1] || coinType;
681
711
  }
712
+ function buildCustomerAdvice(operation_type, data, safeResult) {
713
+ if (!isRuntimeEnabled("customer_intelligence"))
714
+ return undefined;
715
+ let stage;
716
+ if (operation_type === "order") {
717
+ stage = "preorder";
718
+ }
719
+ else if (operation_type === "query_toolkit" || operation_type === "onchain_table_data" || operation_type === "onchain_events") {
720
+ stage = "browse";
721
+ }
722
+ else if (operation_type === "service") {
723
+ stage = "evaluate";
724
+ }
725
+ else {
726
+ return undefined;
727
+ }
728
+ const serviceId = data?.service_name ?? data?.service_id ?? data?.service ?? data?.name;
729
+ const orderId = data?.order_name ?? data?.order_id ?? data?.order;
730
+ let servicePrice;
731
+ if (data?.price !== undefined) {
732
+ try {
733
+ servicePrice = BigInt(String(data.price));
734
+ }
735
+ catch { }
736
+ }
737
+ if (servicePrice === undefined && safeResult?.price !== undefined) {
738
+ try {
739
+ servicePrice = BigInt(String(safeResult.price));
740
+ }
741
+ catch { }
742
+ }
743
+ const hasArbitration = booleanFromSignals(data?.arb_name !== undefined || data?.arbitration !== undefined, data?.arb === false);
744
+ const hasCompensation = booleanFromSignals(data?.compensation_fund !== undefined || data?.compensation !== undefined, false);
745
+ const hasRefundPath = booleanFromSignals(data?.refund !== undefined, false);
746
+ const hasMessenger = booleanFromSignals(data?.um_name !== undefined || data?.messenger !== undefined, false);
747
+ const noArbitration = hasArbitration === false;
748
+ const noCompensation = hasCompensation === false;
749
+ const riskScore = typeof data?.risk_score === "number" ? data.risk_score
750
+ : typeof safeResult?.risk_score === "number" ? safeResult.risk_score : undefined;
751
+ const riskLevel = data?.risk_level ?? safeResult?.risk_level;
752
+ const profile = getProfile();
753
+ const userMinTrust = profile.risk_appetite === "conservative" ? 70
754
+ : profile.risk_appetite === "aggressive" ? 30 : 50;
755
+ const ctx = {
756
+ stage,
757
+ service_id: serviceId,
758
+ order_id: orderId,
759
+ service_price: servicePrice,
760
+ has_arbitration: hasArbitration,
761
+ has_compensation: hasCompensation,
762
+ has_refund_path: hasRefundPath,
763
+ has_messenger: hasMessenger,
764
+ risk_score: riskScore,
765
+ risk_level: riskLevel,
766
+ user_min_trust_score: userMinTrust,
767
+ user_require_arbitration: profile.risk_appetite === "conservative",
768
+ user_require_compensation: profile.risk_appetite === "conservative",
769
+ };
770
+ const reminders = generateReminders(ctx);
771
+ const recommendations = [];
772
+ for (const r of reminders) {
773
+ if (r.action)
774
+ recommendations.push(r.action);
775
+ }
776
+ if (noArbitration && !recommendations.some((r) => r.includes("仲裁"))) {
777
+ recommendations.push("要求商家配置 Arbitration 服务后再下单");
778
+ }
779
+ if (noCompensation && !recommendations.some((r) => r.includes("赔偿金"))) {
780
+ recommendations.push("要求商家设置 compensation_fund(赔偿金)以保障订单失败时自动赔付");
781
+ }
782
+ const advice = {
783
+ recommendations,
784
+ reminders: reminders.map((r) => ({
785
+ id: r.id,
786
+ stage: r.stage,
787
+ priority: r.priority,
788
+ message: r.message,
789
+ action: r.action,
790
+ })),
791
+ };
792
+ if (riskScore !== undefined)
793
+ advice.risk_score = riskScore;
794
+ if (riskLevel !== undefined)
795
+ advice.risk_level = riskLevel;
796
+ return advice;
797
+ }
682
798
  export function buildSemantic(safeResult, context) {
683
799
  if (!context)
684
800
  return undefined;
@@ -693,6 +809,72 @@ export function buildSemantic(safeResult, context) {
693
809
  const annotatedEvents = annotateEvents(events);
694
810
  const next_actions = inferNextActions(context.operation_type, context.data, status);
695
811
  const warnings = inferWarnings(context.operation_type, context.data, safeResult);
812
+ if (context.pre_warnings && context.pre_warnings.length > 0) {
813
+ warnings.push(...context.pre_warnings);
814
+ }
815
+ if (context.operation_type === "service" && context.data?.publish === true) {
816
+ const findings = auditService(context.data);
817
+ for (const f of findings) {
818
+ const prefix = f.severity === "error" ? "[AUDIT ERROR] " : f.severity === "warning" ? "[AUDIT] " : "[INFO] ";
819
+ warnings.push(prefix + f.message);
820
+ }
821
+ }
822
+ let experience;
823
+ if (isRuntimeEnabled("experience_layer")) {
824
+ try {
825
+ const feedback = getExperienceFeedback(context.operation_type, context.data, intent);
826
+ if (feedback) {
827
+ experience = feedback;
828
+ }
829
+ const outcome = status === "success" ? "success" : status === "failed" ? "failed" : "partial";
830
+ const referencedObjects = [...created, ...modified].map((o) => o.id).filter(Boolean);
831
+ recordOperationOutcome(context.operation_type, context.data, intent, outcome, undefined, referencedObjects);
832
+ }
833
+ catch {
834
+ }
835
+ }
836
+ let evolution_context;
837
+ if (isRuntimeEnabled("industry_evolution")) {
838
+ try {
839
+ const industryHint = (typeof context.data?.industry === "string" && context.data.industry.trim())
840
+ ? context.data.industry.trim()
841
+ : undefined;
842
+ if (industryHint) {
843
+ const outcome = status === "success"
844
+ ? { success: true }
845
+ : { success: false, error_code: inferErrorCodeForSignal(safeResult) };
846
+ recordIndustrySignal(industryHint, { type: context.operation_type, data: context.data }, outcome);
847
+ }
848
+ if (industryHint) {
849
+ const evoCtx = injectEvolutionContext(undefined, industryHint);
850
+ if (evoCtx && (evoCtx.industry_signal || evoCtx.evolution_advice || evoCtx.confidence > 0)) {
851
+ evolution_context = evoCtx;
852
+ }
853
+ }
854
+ }
855
+ catch {
856
+ }
857
+ }
858
+ let service_status;
859
+ if (isRuntimeEnabled("semantic_rich")) {
860
+ try {
861
+ const all = listServices();
862
+ const active = all.filter((s) => s.enabled).map((s) => s.name);
863
+ const inactive = all.filter((s) => !s.enabled).map((s) => s.name);
864
+ service_status = {
865
+ active,
866
+ inactive: inactive.length ? inactive : undefined,
867
+ };
868
+ }
869
+ catch {
870
+ }
871
+ }
872
+ let customer_advice;
873
+ try {
874
+ customer_advice = buildCustomerAdvice(context.operation_type, context.data, safeResult);
875
+ }
876
+ catch {
877
+ }
696
878
  return {
697
879
  intent,
698
880
  status,
@@ -703,8 +885,19 @@ export function buildSemantic(safeResult, context) {
703
885
  events: annotatedEvents.length ? annotatedEvents : undefined,
704
886
  next_actions: next_actions.length ? next_actions : undefined,
705
887
  warnings: warnings.length ? warnings : undefined,
888
+ experience,
889
+ service_status,
890
+ customer_advice,
891
+ evolution_context,
706
892
  };
707
893
  }
894
+ function inferErrorCodeForSignal(safeResult) {
895
+ if (!safeResult)
896
+ return undefined;
897
+ if (typeof safeResult.error === "string")
898
+ return safeResult.error.slice(0, 64);
899
+ return undefined;
900
+ }
708
901
  export function buildDataSemantic(data, context, isError, errorMsg) {
709
902
  if (!context)
710
903
  return undefined;
@@ -753,6 +946,28 @@ export function buildDataSemantic(data, context, isError, errorMsg) {
753
946
  else {
754
947
  summary = `Successfully ${intentVerb}`;
755
948
  }
949
+ let service_status;
950
+ if (isRuntimeEnabled("semantic_rich")) {
951
+ try {
952
+ const all = listServices();
953
+ const active = all.filter((s) => s.enabled).map((s) => s.name);
954
+ const inactive = all.filter((s) => !s.enabled).map((s) => s.name);
955
+ service_status = {
956
+ active,
957
+ inactive: inactive.length ? inactive : undefined,
958
+ };
959
+ }
960
+ catch {
961
+ }
962
+ }
963
+ let customer_advice;
964
+ if (!isError) {
965
+ try {
966
+ customer_advice = buildCustomerAdvice(context.operation_type, context.data, data);
967
+ }
968
+ catch {
969
+ }
970
+ }
756
971
  return {
757
972
  intent,
758
973
  status,
@@ -760,5 +975,7 @@ export function buildDataSemantic(data, context, isError, errorMsg) {
760
975
  events: annotatedEvents,
761
976
  next_actions: next_actions.length ? next_actions : undefined,
762
977
  warnings: warnings.length ? warnings : undefined,
978
+ service_status,
979
+ customer_advice,
763
980
  };
764
981
  }