@wowok/agent-mcp 2.3.18 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/customer/industry-risks.js +31 -31
  2. package/dist/customer/order-monitor.js +57 -57
  3. package/dist/customer/order-strategy.js +89 -89
  4. package/dist/customer/post-purchase.js +97 -97
  5. package/dist/customer/reminder-system.js +26 -26
  6. package/dist/customer/risk-assessment.js +46 -46
  7. package/dist/customer/types.d.ts +4 -4
  8. package/dist/customer/types.js +4 -4
  9. package/dist/customer/user-preferences.js +50 -50
  10. package/dist/experience/intent-distill.js +6 -6
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +11 -1624
  13. package/dist/knowledge/acquisition-flywheel.js +64 -64
  14. package/dist/knowledge/arbitration-trust.js +10 -10
  15. package/dist/knowledge/demand-matching.js +8 -8
  16. package/dist/knowledge/dynamic-pricing.js +18 -18
  17. package/dist/knowledge/flywheel-loop.js +11 -11
  18. package/dist/knowledge/glossary.js +22 -22
  19. package/dist/knowledge/guard-ledger.d.ts +1 -1
  20. package/dist/knowledge/guard-ledger.js +145 -104
  21. package/dist/knowledge/guard-lint.d.ts +77 -0
  22. package/dist/knowledge/guard-lint.js +670 -0
  23. package/dist/knowledge/guard-migration.d.ts +48 -0
  24. package/dist/knowledge/guard-migration.js +228 -0
  25. package/dist/knowledge/guard-puzzle.d.ts +109 -14
  26. package/dist/knowledge/guard-puzzle.js +627 -101
  27. package/dist/knowledge/guard-risk.d.ts +10 -1
  28. package/dist/knowledge/guard-risk.js +1634 -292
  29. package/dist/knowledge/guard-templates.d.ts +38 -0
  30. package/dist/knowledge/guard-templates.js +605 -0
  31. package/dist/knowledge/guard-translation.d.ts +14 -2
  32. package/dist/knowledge/guard-translation.js +825 -194
  33. package/dist/knowledge/index.d.ts +8 -4
  34. package/dist/knowledge/index.js +9 -5
  35. package/dist/knowledge/industry-evolution.js +29 -29
  36. package/dist/knowledge/industry-generalizer.js +52 -52
  37. package/dist/knowledge/industry-registry.js +20 -33
  38. package/dist/knowledge/intent-metrics.js +67 -67
  39. package/dist/knowledge/process-model.js +80 -80
  40. package/dist/knowledge/reputation-rules.js +9 -9
  41. package/dist/knowledge/reward-templates.js +51 -51
  42. package/dist/knowledge/safety-rules.js +3 -3
  43. package/dist/knowledge/tool-constraints.js +20 -4
  44. package/dist/knowledge/trust-metrics.js +26 -26
  45. package/dist/project/graph.d.ts +1 -0
  46. package/dist/project/graph.js +27 -1
  47. package/dist/project/index.d.ts +1 -0
  48. package/dist/project/index.js +39 -2
  49. package/dist/project/namespace.d.ts +11 -1
  50. package/dist/project/namespace.js +27 -2
  51. package/dist/project/query.d.ts +2 -0
  52. package/dist/project/query.js +56 -15
  53. package/dist/rules.d.ts +12 -0
  54. package/dist/rules.js +9 -0
  55. package/dist/schema/call/allocation.d.ts +10 -10
  56. package/dist/schema/call/base.js +19 -19
  57. package/dist/schema/call/bridge.d.ts +32 -32
  58. package/dist/schema/call/demand.d.ts +84 -84
  59. package/dist/schema/call/guard.d.ts +153 -0
  60. package/dist/schema/call/guard.js +50 -0
  61. package/dist/schema/call/machine.d.ts +38 -38
  62. package/dist/schema/call/permission.d.ts +78 -78
  63. package/dist/schema/call/repository.d.ts +22 -22
  64. package/dist/schema/call/semantic.js +229 -25
  65. package/dist/schema/call/service.d.ts +7 -7
  66. package/dist/schema/local/wip.d.ts +39 -19
  67. package/dist/schema/local/wip.js +5 -5
  68. package/dist/schema/messenger/index.d.ts +26 -26
  69. package/dist/schema/messenger/index.js +2 -2
  70. package/dist/schema/operations.d.ts +270 -192
  71. package/dist/schema/query/index.d.ts +184 -184
  72. package/dist/schema/query/index.js +15 -9
  73. package/dist/schema/trust/index.d.ts +4 -4
  74. package/dist/schema/utils/guard-parser.js +4 -4
  75. package/dist/schema/utils/guard-query-utils.d.ts +7 -0
  76. package/dist/schema/utils/guard-query-utils.js +14 -1
  77. package/dist/schema/utils/node-parser.js +14 -14
  78. package/dist/schemas/bridge_operation.output.json +15 -15
  79. package/dist/schemas/index.json +1 -1
  80. package/dist/schemas/messenger_operation.output.json +18 -16
  81. package/dist/schemas/onchain_events.output.json +15 -15
  82. package/dist/schemas/onchain_operations.output.json +16 -16
  83. package/dist/schemas/onchain_operations.schema.json +11 -20
  84. package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
  85. package/dist/schemas/onchain_operations_machine.schema.json +2 -5
  86. package/dist/schemas/onchain_operations_service.schema.json +2 -5
  87. package/dist/schemas/onchain_table_data.output.json +20 -26
  88. package/dist/schemas/wip_file.output.json +24 -1
  89. package/dist/tools/handlers/bridge.d.ts +1 -0
  90. package/dist/tools/handlers/bridge.js +1 -0
  91. package/dist/tools/handlers/config.d.ts +2 -0
  92. package/dist/tools/handlers/config.js +71 -0
  93. package/dist/tools/handlers/file-export.d.ts +3 -0
  94. package/dist/tools/handlers/file-export.js +90 -0
  95. package/dist/tools/handlers/local.d.ts +30 -0
  96. package/dist/tools/handlers/local.js +27 -0
  97. package/dist/tools/handlers/messenger.d.ts +16 -0
  98. package/dist/tools/handlers/messenger.js +187 -0
  99. package/dist/tools/handlers/onchain.d.ts +2 -0
  100. package/dist/tools/handlers/onchain.js +246 -0
  101. package/dist/tools/handlers/project.d.ts +2 -0
  102. package/dist/tools/handlers/project.js +53 -0
  103. package/dist/tools/handlers/query.d.ts +5 -0
  104. package/dist/tools/handlers/query.js +256 -0
  105. package/dist/tools/handlers/schema-query.d.ts +2 -0
  106. package/dist/tools/handlers/schema-query.js +92 -0
  107. package/dist/tools/handlers/trust.d.ts +2 -0
  108. package/dist/tools/handlers/trust.js +194 -0
  109. package/dist/tools/handlers/wip.d.ts +2 -0
  110. package/dist/tools/handlers/wip.js +44 -0
  111. package/dist/tools/index.d.ts +13 -0
  112. package/dist/tools/index.js +479 -0
  113. package/dist/tools/rules-hook.d.ts +2 -0
  114. package/dist/tools/rules-hook.js +22 -0
  115. package/dist/tools/shared.d.ts +29 -0
  116. package/dist/tools/shared.js +130 -0
  117. package/dist/tools/types.d.ts +35 -0
  118. package/dist/tools/types.js +1 -0
  119. package/dist/tools/wrap.d.ts +6 -0
  120. package/dist/tools/wrap.js +55 -0
  121. package/package.json +19 -5
@@ -17,8 +17,10 @@ import { FLYWHEEL_LOOP_VERSION, FLYWHEEL_LOOP_MIN_SIGNALS, EVOLUTION_STATE_VERSI
17
17
  import { BUILTIN_INTENT_SPECS, registerIntentProfile, getIntentProfile, listIntents, evaluateIndustryHealthByIntent, suggestIndustryUpdateByIntent, evaluateIndustryHealthMultiIntent, getRoleAdvice, filterSuggestionsByRole, type BusinessIntent, type MetricDimension, type IntentMetricSpec, type IntentSuggestionTrigger, type AdviceRole } from "./intent-metrics.js";
18
18
  import { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getNumericIdentifierScenes, type GuardScene } from "./guard-ledger.js";
19
19
  import { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, type SemanticToSchemaRule, type SchemaToSemanticRule, type GuardConstraintRule } from "./guard-translation.js";
20
- import { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataEntryPuzzle, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension } from "./guard-puzzle.js";
21
- import { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory } from "./guard-risk.js";
20
+ import { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataSourcePuzzle, type OnChainConstantEntry, type WitnessDerivedEntry, type SubmittedObjectEntry, type SubmittedValueEntry, type SystemContextEntry, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension } from "./guard-puzzle.js";
21
+ import { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule } from "./guard-risk.js";
22
+ import { GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType } from "./guard-templates.js";
23
+ import { lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction } from "./guard-lint.js";
22
24
  export { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, type GlossaryEntry, type GlossaryCategory, type GlossaryDrift, };
23
25
  export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, type ConfirmationRule, type OperationPreview, type ConfirmLevel, };
24
26
  export { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, type ConstraintSeverity, type FieldConstraint, type OperationConstraint, type ConstraintViolation, };
@@ -38,8 +40,8 @@ export { FLYWHEEL_LOOP_VERSION, FLYWHEEL_LOOP_MIN_SIGNALS, EVOLUTION_STATE_VERSI
38
40
  export { BUILTIN_INTENT_SPECS, registerIntentProfile, getIntentProfile, listIntents, evaluateIndustryHealthByIntent, suggestIndustryUpdateByIntent, evaluateIndustryHealthMultiIntent, getRoleAdvice, filterSuggestionsByRole, type BusinessIntent, type MetricDimension, type IntentMetricSpec, type IntentSuggestionTrigger, type AdviceRole, };
39
41
  export { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getNumericIdentifierScenes, type GuardScene, };
40
42
  export { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, type SemanticToSchemaRule, type SchemaToSemanticRule, type GuardConstraintRule, };
41
- export { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataEntryPuzzle, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension, };
42
- export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, };
43
+ export { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, type GuardPuzzle, type IntentPuzzle, type BindingPuzzle, type DataSourcePuzzle, type OnChainConstantEntry, type WitnessDerivedEntry, type SubmittedObjectEntry, type SubmittedValueEntry, type SystemContextEntry, type QueryPuzzle, type LogicNodePuzzle, type ConstraintChecklist, type PuzzleCompleteness, type PuzzleDimension, };
44
+ export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, type GuardRisk, type GuardRiskAssessment, type GuardStakeholder, type RiskLevel, type RiskCategory, type DataSourceClass, type RiskRule, GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, type GuardTemplate, type GuardTemplateParam, type TemplateParamType, lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, type GuardJsonInput, type GuardLintResult, type GuardDiagnostic, type DiagnosticSeverity, type DiagnosticSource, type AutoFixAction, };
43
45
  export declare function getKnowledgeBase(): {
44
46
  version: {
45
47
  glossary: number;
@@ -74,4 +76,6 @@ export declare function getKnowledgeBase(): {
74
76
  guard_schema_rules_count: number;
75
77
  guard_constraint_rules_count: number;
76
78
  guard_risk_rules_count: number;
79
+ guard_templates_count: number;
80
+ guard_lint_enabled: boolean;
77
81
  };
@@ -17,8 +17,10 @@ import { FLYWHEEL_LOOP_VERSION, FLYWHEEL_LOOP_MIN_SIGNALS, EVOLUTION_STATE_VERSI
17
17
  import { BUILTIN_INTENT_SPECS, registerIntentProfile, getIntentProfile, listIntents, evaluateIndustryHealthByIntent, suggestIndustryUpdateByIntent, evaluateIndustryHealthMultiIntent, getRoleAdvice, filterSuggestionsByRole, } from "./intent-metrics.js";
18
18
  import { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getNumericIdentifierScenes, } from "./guard-ledger.js";
19
19
  import { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, } from "./guard-translation.js";
20
- import { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, } from "./guard-puzzle.js";
21
- import { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, } from "./guard-risk.js";
20
+ import { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, } from "./guard-puzzle.js";
21
+ import { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, } from "./guard-risk.js";
22
+ import { GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, } from "./guard-templates.js";
23
+ import { lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, } from "./guard-lint.js";
22
24
  export { CONCEPT_GLOSSARY, CONCEPT_GLOSSARY_VERSION, resolveTerm, lookupEntry, validateText, auditSchemaFields, };
23
25
  export { CONFIRMATION_RULES, SAFETY_RULES_VERSION, };
24
26
  export { TOOL_CONSTRAINTS, TOOL_CONSTRAINTS_VERSION, validateOperation, hasBlockingViolations, getWarningViolations, };
@@ -38,8 +40,8 @@ export { FLYWHEEL_LOOP_VERSION, FLYWHEEL_LOOP_MIN_SIGNALS, EVOLUTION_STATE_VERSI
38
40
  export { BUILTIN_INTENT_SPECS, registerIntentProfile, getIntentProfile, listIntents, evaluateIndustryHealthByIntent, suggestIndustryUpdateByIntent, evaluateIndustryHealthMultiIntent, getRoleAdvice, filterSuggestionsByRole, };
39
41
  export { GUARD_SCENES, findScene, inferSceneFromAction, getImmutableScenes, getNumericIdentifierScenes, };
40
42
  export { SEMANTIC_TO_SCHEMA_RULES, SCHEMA_TO_SEMANTIC_RULES, GUARD_CONSTRAINT_RULES, matchSemanticPattern, explainNode, explainWitness, getConstraintsByCategory, };
41
- export { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, };
42
- export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, };
43
+ export { checkPuzzleCompleteness, generateConfirmationText, initPuzzleFromIntent, inferBindingFromAction, emptyDataSources, getWitnessInfo, WITNESS_NAME_MAP, };
44
+ export { assessGuardRisks, assessGuardRisksForOperation, getRiskSummary, getRiskRulesByDataSourceClass, getAllRiskRules, getRiskRulesCount, GUARD_TEMPLATES, GUARD_TEMPLATES_VERSION, GUARD_TEMPLATES_COUNT, getTemplatesByScene, getTemplateById, getTemplatesByIndustry, getTemplatesByPattern, listGuardTemplates, suggestTemplateForScene, getTemplateParameters, validateTemplateParams, lintGuard, autoFixGuard, isGuardReady, getGuardErrors, formatLintResult, };
43
45
  export function getKnowledgeBase() {
44
46
  return {
45
47
  version: {
@@ -74,6 +76,8 @@ export function getKnowledgeBase() {
74
76
  guard_semantic_rules_count: SEMANTIC_TO_SCHEMA_RULES.length,
75
77
  guard_schema_rules_count: SCHEMA_TO_SEMANTIC_RULES.length,
76
78
  guard_constraint_rules_count: GUARD_CONSTRAINT_RULES.length,
77
- guard_risk_rules_count: 14,
79
+ guard_risk_rules_count: getRiskRulesCount(),
80
+ guard_templates_count: GUARD_TEMPLATES_COUNT,
81
+ guard_lint_enabled: true,
78
82
  };
79
83
  }
@@ -72,19 +72,19 @@ export function aggregateIndustryMetrics(industry, rawData, timeWindowDays = 30)
72
72
  const refundRate = refundCount / sample_size;
73
73
  if (sample_size >= 20) {
74
74
  if (milestoneRate(filtered) > 0.4) {
75
- emerging_patterns.push("分阶段交付占比上升(≥40% 订单采用里程碑节点)");
75
+ emerging_patterns.push("Milestone delivery share rising (>=40% of orders use milestone nodes)");
76
76
  }
77
77
  if (repeatBuyerRate > 0.25) {
78
- emerging_patterns.push(`复购率上升至 ${Math.round(repeatBuyerRate * 100)}%`);
78
+ emerging_patterns.push(`Repeat buyer rate rose to ${Math.round(repeatBuyerRate * 100)}%`);
79
79
  }
80
80
  if (disputeRate > THRESHOLDS.stressed_dispute_rate) {
81
- anomalies.push(`争议率突增至 ${Math.round(disputeRate * 100)}%(阈值 ${THRESHOLDS.stressed_dispute_rate * 100}%)`);
81
+ anomalies.push(`Dispute rate spiked to ${Math.round(disputeRate * 100)}% (threshold ${THRESHOLDS.stressed_dispute_rate * 100}%)`);
82
82
  }
83
83
  if (refundRate > 0.2) {
84
- anomalies.push(`退款率突增至 ${Math.round(refundRate * 100)}%`);
84
+ anomalies.push(`Refund rate spiked to ${Math.round(refundRate * 100)}%`);
85
85
  }
86
86
  if (avgCycleHours > 24 * 30) {
87
- anomalies.push(`平均完成周期过长(${Math.round(avgCycleHours / 24)} 天)`);
87
+ anomalies.push(`Average completion cycle too long (${Math.round(avgCycleHours / 24)} days)`);
88
88
  }
89
89
  }
90
90
  return {
@@ -114,47 +114,47 @@ export function evaluateIndustryHealth(industry, metrics) {
114
114
  const weaknesses = [];
115
115
  const recommendations = [];
116
116
  if (metrics.sample_size < THRESHOLDS.min_sample_size) {
117
- weaknesses.push(`样本量不足(${metrics.sample_size} < ${THRESHOLDS.min_sample_size}),评估置信度低`);
118
- recommendations.push("继续累积订单数据以提升评估精度");
117
+ weaknesses.push(`Insufficient sample size (${metrics.sample_size} < ${THRESHOLDS.min_sample_size}), low evaluation confidence`);
118
+ recommendations.push("Continue accumulating order data to improve evaluation accuracy");
119
119
  }
120
120
  const completedScore = metrics.completed_rate * 35;
121
121
  if (metrics.completed_rate >= THRESHOLDS.thriving_completed_rate) {
122
- strengths.push(`完成率高(${Math.round(metrics.completed_rate * 100)}%)`);
122
+ strengths.push(`High completion rate (${Math.round(metrics.completed_rate * 100)}%)`);
123
123
  }
124
124
  else if (metrics.completed_rate < THRESHOLDS.healthy_completed_rate) {
125
- weaknesses.push(`完成率偏低(${Math.round(metrics.completed_rate * 100)}%)`);
126
- recommendations.push("排查未完成订单根因,建议加强 Messenger 沟通与里程碑验收");
125
+ weaknesses.push(`Low completion rate (${Math.round(metrics.completed_rate * 100)}%)`);
126
+ recommendations.push("Investigate root cause of incomplete orders; recommend strengthening Messenger communication and milestone acceptance");
127
127
  }
128
128
  const disputeScore = (1 - Math.min(1, metrics.dispute_rate)) * 25;
129
129
  if (metrics.dispute_rate <= THRESHOLDS.thriving_dispute_rate) {
130
- strengths.push(`争议率低(${Math.round(metrics.dispute_rate * 100)}%)`);
130
+ strengths.push(`Low dispute rate (${Math.round(metrics.dispute_rate * 100)}%)`);
131
131
  }
132
132
  else if (metrics.dispute_rate > THRESHOLDS.stressed_dispute_rate) {
133
- weaknesses.push(`争议率高(${Math.round(metrics.dispute_rate * 100)}%)`);
134
- recommendations.push("争议率超阈值,建议强制配置仲裁 + 赔偿金 + 交付 Guard");
133
+ weaknesses.push(`High dispute rate (${Math.round(metrics.dispute_rate * 100)}%)`);
134
+ recommendations.push("Dispute rate exceeds threshold; recommend mandatory arbitration + compensation fund + delivery Guard");
135
135
  }
136
136
  const refundScore = (1 - Math.min(1, metrics.refund_rate)) * 15;
137
137
  if (metrics.refund_rate > 0.2) {
138
- weaknesses.push(`退款率高(${Math.round(metrics.refund_rate * 100)}%)`);
139
- recommendations.push("退款率异常,建议检查交付质量或商品描述一致性");
138
+ weaknesses.push(`High refund rate (${Math.round(metrics.refund_rate * 100)}%)`);
139
+ recommendations.push("Abnormal refund rate; recommend checking delivery quality or product description consistency");
140
140
  }
141
141
  const repeatScore = Math.min(1, metrics.repeat_buyer_rate) * 15;
142
142
  if (metrics.repeat_buyer_rate >= THRESHOLDS.thriving_repeat_rate) {
143
- strengths.push(`复购率高(${Math.round(metrics.repeat_buyer_rate * 100)}%)`);
143
+ strengths.push(`High repeat buyer rate (${Math.round(metrics.repeat_buyer_rate * 100)}%)`);
144
144
  }
145
145
  else if (metrics.repeat_buyer_rate < THRESHOLDS.healthy_repeat_rate && metrics.sample_size >= 20) {
146
- weaknesses.push(`复购率低(${Math.round(metrics.repeat_buyer_rate * 100)}%)`);
147
- recommendations.push("复购率低,建议设置忠诚度 Reward + 推荐返现裂变");
146
+ weaknesses.push(`Low repeat buyer rate (${Math.round(metrics.repeat_buyer_rate * 100)}%)`);
147
+ recommendations.push("Low repeat buyer rate; recommend setting up loyalty Reward + referral cashback flywheel");
148
148
  }
149
149
  const cycleScore = metrics.avg_cycle_hours > 0
150
150
  ? Math.max(0, Math.min(10, 10 * (1 - (metrics.avg_cycle_hours / 24 - 7) / 23)))
151
151
  : 0;
152
152
  if (metrics.avg_cycle_hours > 0 && metrics.avg_cycle_hours <= 24 * 7) {
153
- strengths.push(`交付周期短(${Math.round(metrics.avg_cycle_hours)} 小时)`);
153
+ strengths.push(`Short delivery cycle (${Math.round(metrics.avg_cycle_hours)} hours)`);
154
154
  }
155
155
  else if (metrics.avg_cycle_hours > 24 * 30) {
156
- weaknesses.push(`交付周期过长(${Math.round(metrics.avg_cycle_hours / 24)} 天)`);
157
- recommendations.push("交付周期过长,建议优化 Machine 节点拆分");
156
+ weaknesses.push(`Delivery cycle too long (${Math.round(metrics.avg_cycle_hours / 24)} days)`);
157
+ recommendations.push("Delivery cycle too long; recommend optimizing Machine node splitting");
158
158
  }
159
159
  const healthScore = Math.round(completedScore + disputeScore + refundScore + repeatScore + cycleScore);
160
160
  let level;
@@ -208,13 +208,13 @@ export function suggestIndustryUpdate(industry, metrics) {
208
208
  industry,
209
209
  suggestion_type: "add_risk_check",
210
210
  field: "risk_checks",
211
- current_value: "(无对应高争议行业的额外检查)",
211
+ current_value: "(no extra check for high-dispute industry)",
212
212
  suggested_value: {
213
213
  id: `auto_dispute_check_${industry}`,
214
- description: "争议率高发行业:强制配置仲裁 + 赔偿金",
214
+ description: "High-dispute industry: mandatory arbitration + compensation fund",
215
215
  weight: 30,
216
216
  },
217
- evidence: `dispute_rate=${(metrics.dispute_rate * 100).toFixed(1)}% 超过阈值 ${THRESHOLDS.healthy_dispute_rate * 100}%`,
217
+ evidence: `dispute_rate=${(metrics.dispute_rate * 100).toFixed(1)}% exceeds threshold ${THRESHOLDS.healthy_dispute_rate * 100}%`,
218
218
  confidence: Math.min(0.95, 0.5 + metrics.dispute_rate),
219
219
  priority: metrics.dispute_rate > THRESHOLDS.stressed_dispute_rate ? "high" : "medium",
220
220
  });
@@ -227,7 +227,7 @@ export function suggestIndustryUpdate(industry, metrics) {
227
227
  field: "preference_template.max_acceptable_cycle",
228
228
  current_value: currentCycleDays,
229
229
  suggested_value: Math.max(7, Math.floor(currentCycleDays * 0.8)),
230
- evidence: `completed_rate=${(metrics.completed_rate * 100).toFixed(1)}% < ${THRESHOLDS.healthy_completed_rate * 100}%;avg_cycle=${currentCycleDays}天`,
230
+ evidence: `completed_rate=${(metrics.completed_rate * 100).toFixed(1)}% < ${THRESHOLDS.healthy_completed_rate * 100}%; avg_cycle=${currentCycleDays} days`,
231
231
  confidence: 0.7,
232
232
  priority: "medium",
233
233
  });
@@ -237,9 +237,9 @@ export function suggestIndustryUpdate(industry, metrics) {
237
237
  industry,
238
238
  suggestion_type: "update_flywheel",
239
239
  field: "flywheel.rewardStrategy",
240
- current_value: "(当前 Reward 策略)",
241
- suggested_value: "强化忠诚度 Reward + 阶梯复购奖励",
242
- evidence: `repeat_buyer_rate=${(metrics.repeat_buyer_rate * 100).toFixed(1)}% ${THRESHOLDS.thriving_repeat_rate * 100}%`,
240
+ current_value: "(current Reward strategy)",
241
+ suggested_value: "Strengthen loyalty Reward + tiered repeat-buyer rewards",
242
+ evidence: `repeat_buyer_rate=${(metrics.repeat_buyer_rate * 100).toFixed(1)}% >= ${THRESHOLDS.thriving_repeat_rate * 100}%`,
243
243
  confidence: 0.75,
244
244
  priority: "low",
245
245
  });
@@ -252,7 +252,7 @@ export function suggestIndustryUpdate(industry, metrics) {
252
252
  field: `traits.${d.trait}`,
253
253
  current_value: d.template_value,
254
254
  suggested_value: d.observed_value,
255
- evidence: `模板假设 ${d.trait}=${d.template_value},但实际数据观察为 ${d.observed_value}drift_severity=${d.drift_severity})`,
255
+ evidence: `Template assumes ${d.trait}=${d.template_value}, but actual data observed ${d.observed_value} (drift_severity=${d.drift_severity})`,
256
256
  confidence: d.drift_severity === "high" ? 0.8 : 0.65,
257
257
  priority: d.drift_severity === "high" ? "high" : "medium",
258
258
  });
@@ -1,50 +1,50 @@
1
1
  import { getIndustryProfile, listIndustries, registerIndustry, } from "./industry-registry.js";
2
2
  const TRAIT_INFERENCE_RULES = [
3
- { keywords: ["物流", "发货", "配送", "快递", "送货", "delivery", "shipping", "logistics", "ship"],
3
+ { keywords: ["logistics", "shipping", "delivery", "express", "shipment", "delivery", "shipping", "logistics", "ship"],
4
4
  trait: "has_logistics", value: true, weight: 0.85 },
5
- { keywords: ["数字", "在线", "云端", "线上", "digital", "online", "cloud"],
5
+ { keywords: ["digital", "online", "cloud", "online", "digital", "online", "cloud"],
6
6
  trait: "has_logistics", value: false, weight: 0.7 },
7
- { keywords: ["咨询", "沟通", "需求确认", "修改轮次", "consult", "communication", "negotiate"],
7
+ { keywords: ["consulting", "communication", "requirement-confirmation", "revision-rounds", "consult", "communication", "negotiate"],
8
8
  trait: "communication_heavy", value: true, weight: 0.8 },
9
- { keywords: ["标准品", "现货", "一键下单", "standard", "instant"],
9
+ { keywords: ["standard-product", "in-stock", "one-click-order", "standard", "instant"],
10
10
  trait: "communication_heavy", value: false, weight: 0.7 },
11
- { keywords: ["数字", "文件", "代码", "设计稿", "电子", "在线", "digital", "file", "online"],
11
+ { keywords: ["digital", "file", "code", "design-draft", "electronic", "online", "digital", "file", "online"],
12
12
  trait: "pure_digital", value: true, weight: 0.8 },
13
- { keywords: ["实物", "硬件", "设备", "physical", "hardware", "equipment"],
13
+ { keywords: ["physical", "hardware", "equipment", "physical", "hardware", "equipment"],
14
14
  trait: "pure_digital", value: false, weight: 0.75 },
15
- { keywords: ["课程", "学期", "周期长", "长期", "项目制", "course", "semester", "long-term", "project"],
15
+ { keywords: ["course", "semester", "long-cycle", "long-term", "project-based", "course", "semester", "long-term", "project"],
16
16
  trait: "long_cycle", value: true, weight: 0.75 },
17
- { keywords: ["即时", "现货", "当天", "instant", "same-day", "immediate"],
17
+ { keywords: ["instant", "in-stock", "same-day", "instant", "same-day", "immediate"],
18
18
  trait: "long_cycle", value: false, weight: 0.8 },
19
- { keywords: ["租赁", "租用", "押金", "rental", "rent", "deposit", "lease"],
19
+ { keywords: ["rental", "rent", "deposit", "rental", "rent", "deposit", "lease"],
20
20
  trait: "deposit_required", value: true, weight: 0.9 },
21
- { keywords: ["购买", "买断", "purchase", "buy"],
21
+ { keywords: ["purchase", "buyout", "purchase", "buy"],
22
22
  trait: "deposit_required", value: false, weight: 0.6 },
23
- { keywords: ["多方", "分段", "多阶段", "多商家", "行程", "multi-party", "segment", "multi-vendor"],
23
+ { keywords: ["multi-party", "segmented", "multi-stage", "multi-vendor", "itinerary", "multi-party", "segment", "multi-vendor"],
24
24
  trait: "multi_tier_allocation", value: true, weight: 0.75 },
25
- { keywords: ["医疗", "法律", "金融", "保险", "药品", "medical", "legal", "finance", "insurance", "pharma"],
25
+ { keywords: ["medical", "legal", "financial", "insurance", "pharmaceutical", "medical", "legal", "finance", "insurance", "pharma"],
26
26
  trait: "regulatory_intensity", value: "high", weight: 0.9 },
27
- { keywords: ["教育", "食品", "建筑", "education", "food", "construction"],
27
+ { keywords: ["education", "food", "construction", "education", "food", "construction"],
28
28
  trait: "regulatory_intensity", value: "medium", weight: 0.7 },
29
- { keywords: ["娱乐", "游戏", "数字", "entertainment", "game", "digital"],
29
+ { keywords: ["entertainment", "gaming", "digital", "entertainment", "game", "digital"],
30
30
  trait: "regulatory_intensity", value: "low", weight: 0.6 },
31
- { keywords: ["定制", "高价值", "定制化", "custom", "high-value", "bespoke"],
31
+ { keywords: ["custom", "high-value", "customized", "custom", "high-value", "bespoke"],
32
32
  trait: "trust_sensitivity", value: "high", weight: 0.8 },
33
- { keywords: ["标准品", "小额", "standard", "low-value"],
33
+ { keywords: ["standard-product", "small-ticket", "standard", "low-value"],
34
34
  trait: "trust_sensitivity", value: "low", weight: 0.7 },
35
- { keywords: ["订阅", "会员", "周期性", "subscription", "membership", "recurring"],
35
+ { keywords: ["subscription", "membership", "recurring", "subscription", "membership", "recurring"],
36
36
  trait: "consumption_frequency", value: "frequent", weight: 0.85 },
37
- { keywords: ["课程", "学期", "教育", "course", "education"],
37
+ { keywords: ["course", "semester", "education", "course", "education"],
38
38
  trait: "consumption_frequency", value: "one_time", weight: 0.75 },
39
- { keywords: ["日常", "频繁", "常用", "daily", "frequent"],
39
+ { keywords: ["daily", "frequent", "common", "daily", "frequent"],
40
40
  trait: "consumption_frequency", value: "frequent", weight: 0.75 },
41
- { keywords: ["小额", "日常", "便利店", "micro", "small-ticket"],
41
+ { keywords: ["small-ticket", "daily", "convenience-store", "micro", "small-ticket"],
42
42
  trait: "avg_ticket_size", value: "micro", weight: 0.7 },
43
- { keywords: ["零售", "商品", "标准品", "retail", "commodity"],
43
+ { keywords: ["retail", "commodity", "standard-product", "retail", "commodity"],
44
44
  trait: "avg_ticket_size", value: "small", weight: 0.7 },
45
- { keywords: ["定制", "项目", "外包", "custom", "project"],
45
+ { keywords: ["custom", "project", "outsourcing", "custom", "project"],
46
46
  trait: "avg_ticket_size", value: "medium", weight: 0.7 },
47
- { keywords: ["房产", "汽车", "高价值", "奢侈品", "realestate", "luxury", "car"],
47
+ { keywords: ["real-estate", "automobile", "high-value", "luxury", "realestate", "luxury", "car"],
48
48
  trait: "avg_ticket_size", value: "large", weight: 0.85 },
49
49
  ];
50
50
  export const DEFAULT_TRAITS = {
@@ -128,91 +128,91 @@ const FALLBACK_RISK_CHECK_RULES = [
128
128
  {
129
129
  trait_key: "deposit_required", trait_value: true,
130
130
  check: {
131
- id: "fb_deposit_lock", description: "押金锁定期安全(押金不可被商家随时撤回)",
131
+ id: "fb_deposit_lock", description: "Deposit lock-period safety (deposit cannot be withdrawn by merchant at any time)",
132
132
  weight: 30,
133
133
  passed: (p) => p?.fund_safety?.lock_duration_safe ?? false,
134
- advice: "⚠️ 锁定期不安全:押金可能被随时撤回,建议要求锁定期 ≥ 7 天。",
134
+ advice: "⚠️ Lock period unsafe: deposit may be withdrawn at any time; recommend requiring a lock period ≥ 7 days.",
135
135
  },
136
136
  need: {
137
137
  id: "need_deposit_lock", tier: "personalized",
138
- description: "押金锁定期安全",
138
+ description: "Deposit lock-period safety",
139
139
  satisfied: (p) => p?.fund_safety?.lock_duration_safe ?? false,
140
- advice: "押金锁定期不安全。",
140
+ advice: "Deposit lock-period unsafe.",
141
141
  },
142
142
  },
143
143
  {
144
144
  trait_key: "has_logistics", trait_value: true,
145
145
  check: {
146
- id: "fb_logistics_track", description: "物流 Guard 配置(发货/收货验证)",
146
+ id: "fb_logistics_track", description: "Logistics Guard configuration (shipping/receipt verification)",
147
147
  weight: 25,
148
148
  passed: (p) => p?.workflow_analysis?.has_milestone_nodes ?? false,
149
- advice: "⚠️ 无物流 Guard:发货与收货状态无第三方验证。",
149
+ advice: "⚠️ No logistics Guard: shipping and receipt status are not verified by a third party.",
150
150
  },
151
151
  },
152
152
  {
153
153
  trait_key: "pure_digital", trait_value: true,
154
154
  check: {
155
- id: "fb_wip_verified", description: "WIP hash 验证(数字交付物可溯源)",
155
+ id: "fb_wip_verified", description: "WIP hash verification (digital deliverables traceable)",
156
156
  weight: 25,
157
157
  passed: (p) => p?.service_basics?.wip_verified === true,
158
- advice: "⚠️ WIP 未验证:数字交付物无法溯源。",
158
+ advice: "⚠️ WIP not verified: digital deliverables cannot be traced.",
159
159
  },
160
160
  },
161
161
  {
162
162
  trait_key: "long_cycle", trait_value: true,
163
163
  check: {
164
- id: "fb_milestone", description: "里程碑节点(分阶段验收)",
164
+ id: "fb_milestone", description: "Milestone nodes (phased acceptance)",
165
165
  weight: 25,
166
166
  passed: (p) => p?.workflow_analysis?.has_milestone_nodes ?? false,
167
- advice: "⚠️ 无里程碑节点:长周期项目缺少分阶段验收。",
167
+ advice: "⚠️ No milestone nodes: long-cycle projects lack phased acceptance.",
168
168
  },
169
169
  },
170
170
  {
171
171
  trait_key: "regulatory_intensity", trait_value: "high",
172
172
  check: {
173
- id: "fb_compliance", description: "合规配置(仲裁 + 赔偿金)",
173
+ id: "fb_compliance", description: "Compliance configuration (arbitration + compensation fund)",
174
174
  weight: 30,
175
175
  passed: (p) => (p?.workflow_analysis?.has_arbitration_path ?? false) &&
176
176
  (p?.service_basics?.compensation_fund_balance ?? 0n) > 0n,
177
- advice: "🔴 合规要求未满足:高监管行业必须配置仲裁与赔偿金。",
177
+ advice: "🔴 Compliance requirement not met: highly regulated industries must configure arbitration and a compensation fund.",
178
178
  },
179
179
  },
180
180
  {
181
181
  trait_key: "multi_tier_allocation", trait_value: true,
182
182
  check: {
183
- id: "fb_multi_tier_fair", description: "多层分账公平性(每个 segment 有对应 Allocator",
183
+ id: "fb_multi_tier_fair", description: "Multi-tier allocation fairness (each segment has a corresponding Allocator)",
184
184
  weight: 20,
185
185
  passed: (p) => (p?.workflow_analysis?.total_nodes ?? 0) >= 3,
186
- advice: "⚠️ 多层分账需配置对应节点与 Allocator,否则资金分配不透明。",
186
+ advice: "⚠️ Multi-tier allocation requires corresponding nodes and Allocators, otherwise fund distribution is opaque.",
187
187
  },
188
188
  },
189
189
  ];
190
190
  function buildFallbackFlywheel(name, traits) {
191
- const sellingPoints = ["资金托管 + 流程透明"];
191
+ const sellingPoints = ["Fund escrow + process transparency"];
192
192
  if (traits.deposit_required)
193
- sellingPoints.push("押金托管 + 锁定期保障");
193
+ sellingPoints.push("Deposit escrow + lock-period guarantee");
194
194
  if (traits.has_logistics)
195
- sellingPoints.push("物流 Guard 验证");
195
+ sellingPoints.push("Logistics Guard verification");
196
196
  if (traits.pure_digital)
197
- sellingPoints.push("WIP 数字交付物溯源");
197
+ sellingPoints.push("WIP digital deliverable traceability");
198
198
  if (traits.regulatory_intensity === "high")
199
- sellingPoints.push("合规仲裁 + 赔偿金保障");
199
+ sellingPoints.push("Compliant arbitration + compensation fund guarantee");
200
200
  const keyActions = [
201
- { action: "设置首单 Reward", purpose: "吸引新客户", mutableField: "rewards", metricToWatch: "新客下单率" },
202
- { action: "配置 compensation_fund", purpose: "提升信任分", mutableField: "compensation_fund", metricToWatch: "信任分" },
201
+ { action: "Set first-order Reward", purpose: "Attract new customers", mutableField: "rewards", metricToWatch: "New customer order rate" },
202
+ { action: "Configure compensation_fund", purpose: "Improve trust score", mutableField: "compensation_fund", metricToWatch: "Trust score" },
203
203
  ];
204
204
  if (traits.long_cycle) {
205
- keyActions.push({ action: "里程碑 Reward", purpose: "激励完成长周期项目", mutableField: "rewards", metricToWatch: "完单率" });
205
+ keyActions.push({ action: "Milestone Reward", purpose: "Incentivize completion of long-cycle projects", mutableField: "rewards", metricToWatch: "Completion rate" });
206
206
  }
207
207
  if (traits.consumption_frequency === "frequent") {
208
- keyActions.push({ action: "忠诚度 Reward", purpose: "提升复购", mutableField: "rewards", metricToWatch: "复购率" });
208
+ keyActions.push({ action: "Loyalty Reward", purpose: "Improve repurchase", mutableField: "rewards", metricToWatch: "Repurchase rate" });
209
209
  }
210
210
  return {
211
211
  industry: name,
212
212
  trustSellingPoints: sellingPoints,
213
213
  keyActions,
214
- rewardStrategy: "首单奖励 + 推荐返现" + (traits.consumption_frequency === "frequent" ? " + 忠诚度奖励" : ""),
215
- discountStrategy: traits.long_cycle ? "长期合作折扣 + 阶梯优惠" : "首单折扣 + 满减",
214
+ rewardStrategy: "First-order reward + referral cashback" + (traits.consumption_frequency === "frequent" ? " + loyalty reward" : ""),
215
+ discountStrategy: traits.long_cycle ? "Long-term cooperation discount + tiered discount" : "First-order discount + spend-threshold discount",
216
216
  trustDescription: sellingPoints.join(" + "),
217
217
  };
218
218
  }
@@ -234,7 +234,7 @@ export function synthesizeProfile(traits, name) {
234
234
  ? getIndustryProfile(bestMatch.industry)
235
235
  : undefined;
236
236
  const industryName = name ?? `custom_${Date.now().toString(36)}`;
237
- const displayName = name ?? `自定义行业`;
237
+ const displayName = name ?? `Custom Industry`;
238
238
  const flywheel = reuseBasis
239
239
  ? { ...reuseBasis.flywheel, industry: industryName }
240
240
  : buildFallbackFlywheel(industryName, traits);
@@ -263,10 +263,10 @@ export function synthesizeProfile(traits, name) {
263
263
  riskChecks.push({
264
264
  id: "fb_basic_arbitration",
265
265
  industry: industryName,
266
- description: "配置仲裁(基础纠纷解决)",
266
+ description: "Configure arbitration (basic dispute resolution)",
267
267
  weight: 100,
268
268
  passed: (p) => p?.workflow_analysis?.has_arbitration_path ?? false,
269
- advice: "⚠️ 未配置仲裁:基础纠纷无解决通道。",
269
+ advice: "⚠️ No arbitration configured: basic disputes have no resolution channel.",
270
270
  });
271
271
  }
272
272
  return {
@@ -348,7 +348,7 @@ export function composeIndustries(names, newName) {
348
348
  };
349
349
  const composed = {
350
350
  name: newNameResolved,
351
- display_name: newName ?? `组合行业(${names.join("+")})`,
351
+ display_name: newName ?? `Composed Industry (${names.join("+")})`,
352
352
  traits: composedTraits,
353
353
  source: "composed",
354
354
  version: "v1",
@@ -41,49 +41,36 @@ const BUILTIN_TRAITS = {
41
41
  },
42
42
  };
43
43
  const BUILTIN_DISPLAY_NAMES = {
44
- freelance: "自由职业",
45
- rental: "租赁",
46
- education: "教育",
47
- travel: "旅行",
48
- subscription: "订阅",
49
- retail: "零售",
50
- general: "通用",
51
- custom: "自定义",
44
+ freelance: "Freelance",
45
+ rental: "Rental",
46
+ education: "Education",
47
+ travel: "Travel",
48
+ subscription: "Subscription",
49
+ retail: "Retail",
50
+ general: "General",
51
+ custom: "Custom",
52
52
  };
53
53
  const INDUSTRY_ALIASES = {
54
- "自由职业": "freelance",
55
- "外包": "freelance",
56
- "设计": "freelance",
57
- "开发": "freelance",
58
- "咨询": "freelance",
59
- "租赁": "rental",
60
- "租用": "rental",
61
- "出租": "rental",
62
- "教育": "education",
63
- "课程": "education",
64
- "培训": "education",
65
- "旅行": "travel",
66
- "旅游": "travel",
67
- "行程": "travel",
68
- "订阅": "subscription",
69
- "会员": "subscription",
70
- "零售": "retail",
71
- "电商": "retail",
72
- "商品": "retail",
73
- "通用": "general",
74
- "自定义": "custom",
75
- "freelancer": "freelance",
76
- "gig": "freelance",
54
+ "outsourcing": "freelance",
55
+ "design": "freelance",
56
+ "development": "freelance",
57
+ "consulting": "freelance",
77
58
  "rent": "rental",
78
59
  "lease": "rental",
79
60
  "course": "education",
61
+ "training": "education",
62
+ "tourism": "travel",
63
+ "itinerary": "travel",
64
+ "membership": "subscription",
65
+ "ecommerce": "retail",
66
+ "goods": "retail",
67
+ "freelancer": "freelance",
68
+ "gig": "freelance",
80
69
  "edu": "education",
81
70
  "trip": "travel",
82
71
  "tour": "travel",
83
72
  "subscribe": "subscription",
84
- "membership": "subscription",
85
73
  "shop": "retail",
86
- "ecommerce": "retail",
87
74
  "general_industry": "general",
88
75
  };
89
76
  export const INDUSTRY_REGISTRY_VERSION = 1;