@wowok/agent-mcp 2.3.18 → 2.4.1

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 (65) 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/knowledge/acquisition-flywheel.js +64 -64
  12. package/dist/knowledge/arbitration-trust.js +10 -10
  13. package/dist/knowledge/demand-matching.js +8 -8
  14. package/dist/knowledge/dynamic-pricing.js +18 -18
  15. package/dist/knowledge/flywheel-loop.js +11 -11
  16. package/dist/knowledge/glossary.js +22 -22
  17. package/dist/knowledge/guard-ledger.d.ts +1 -1
  18. package/dist/knowledge/guard-ledger.js +131 -104
  19. package/dist/knowledge/guard-lint.d.ts +76 -0
  20. package/dist/knowledge/guard-lint.js +590 -0
  21. package/dist/knowledge/guard-puzzle.d.ts +109 -14
  22. package/dist/knowledge/guard-puzzle.js +627 -101
  23. package/dist/knowledge/guard-risk.d.ts +8 -1
  24. package/dist/knowledge/guard-risk.js +868 -296
  25. package/dist/knowledge/guard-templates.d.ts +37 -0
  26. package/dist/knowledge/guard-templates.js +329 -0
  27. package/dist/knowledge/guard-translation.d.ts +14 -2
  28. package/dist/knowledge/guard-translation.js +825 -194
  29. package/dist/knowledge/index.d.ts +8 -4
  30. package/dist/knowledge/index.js +9 -5
  31. package/dist/knowledge/industry-evolution.js +29 -29
  32. package/dist/knowledge/industry-generalizer.js +52 -52
  33. package/dist/knowledge/industry-registry.js +20 -33
  34. package/dist/knowledge/intent-metrics.js +67 -67
  35. package/dist/knowledge/process-model.js +80 -80
  36. package/dist/knowledge/reputation-rules.js +9 -9
  37. package/dist/knowledge/reward-templates.js +51 -51
  38. package/dist/knowledge/safety-rules.js +3 -3
  39. package/dist/knowledge/tool-constraints.js +20 -4
  40. package/dist/knowledge/trust-metrics.js +26 -26
  41. package/dist/schema/call/base.js +16 -16
  42. package/dist/schema/call/bridge.d.ts +32 -32
  43. package/dist/schema/call/demand.d.ts +84 -84
  44. package/dist/schema/call/guard.d.ts +153 -0
  45. package/dist/schema/call/guard.js +50 -0
  46. package/dist/schema/call/permission.d.ts +78 -78
  47. package/dist/schema/call/repository.d.ts +22 -22
  48. package/dist/schema/call/semantic.js +228 -24
  49. package/dist/schema/local/wip.d.ts +39 -19
  50. package/dist/schema/local/wip.js +5 -5
  51. package/dist/schema/messenger/index.d.ts +26 -26
  52. package/dist/schema/messenger/index.js +2 -2
  53. package/dist/schema/operations.d.ts +222 -144
  54. package/dist/schema/query/index.d.ts +38 -38
  55. package/dist/schema/trust/index.d.ts +4 -4
  56. package/dist/schema/utils/guard-parser.js +4 -4
  57. package/dist/schema/utils/node-parser.js +14 -14
  58. package/dist/schemas/bridge_operation.output.json +14 -14
  59. package/dist/schemas/index.json +1 -1
  60. package/dist/schemas/messenger_operation.output.json +17 -15
  61. package/dist/schemas/onchain_events.output.json +14 -14
  62. package/dist/schemas/onchain_operations.output.json +14 -14
  63. package/dist/schemas/onchain_table_data.output.json +14 -14
  64. package/dist/schemas/wip_file.output.json +24 -1
  65. package/package.json +2 -2
@@ -1,95 +1,95 @@
1
1
  export const REWARD_TEMPLATES = [
2
2
  {
3
3
  type: "first_order",
4
- name: "首单奖励",
5
- description: "新客户首次下单后获得奖励,降低尝试门槛,促进转化。",
6
- guardCondition: "Guard 验证: order_addressholder == 当前 claim 者, order.service == Service, order 是该 holder 的第一笔订单 (通过 Repository 查询历史)",
4
+ name: "First-order reward",
5
+ description: "New customers receive a reward after their first order, lowering the trial barrier and boosting conversion.",
6
+ guardCondition: "Guard verifies: order_address.holder == current claimer, and order.service == this Service, and order is the first order for this holder (via Repository history query)",
7
7
  amountRange: { min: "0.1WOW", max: "5WOW" },
8
8
  allocationStrategy: "fixed",
9
9
  parameters: [
10
- { name: "amount", type: "string", description: "奖励金额 ( '1WOW')", required: true },
11
- { name: "budget", type: "string", description: "总预算 ( '100WOW')", required: true },
10
+ { name: "amount", type: "string", description: "Reward amount (e.g., '1WOW')", required: true },
11
+ { name: "budget", type: "string", description: "Total budget (e.g., '100WOW')", required: true },
12
12
  ],
13
- example: "新客户下单购买摄影服务,首单获得 1 WOW 返还,降低首次尝试成本。",
13
+ example: "A new customer orders a photography service and receives 1 WOW cashback on the first order, lowering the first trial cost.",
14
14
  relevantGuardOps: ["query", "repository_read"],
15
15
  },
16
16
  {
17
17
  type: "referral",
18
- name: "裂变推荐奖励",
19
- description: "老客户推荐新客户下单后,双方各获得奖励,形成口碑传播飞轮。",
20
- guardCondition: "Guard 验证: 推荐人地址在 Repository 评价表中标记为 'referred_by', 且被推荐人的订单已完成 (Progress 到达终态)",
18
+ name: "Referral viral reward",
19
+ description: "Existing customers refer new customers to place an order; both parties receive a reward, creating a word-of-mouth flywheel.",
20
+ guardCondition: "Guard verifies: referrer address is marked as 'referred_by' in the Repository review table, and the referee's order is completed (Progress reached terminal state)",
21
21
  amountRange: { min: "0.5WOW", max: "10WOW" },
22
22
  allocationStrategy: "proportional",
23
23
  parameters: [
24
- { name: "referrer_reward", type: "string", description: "推荐人奖励 ( '2WOW')", required: true },
25
- { name: "referee_reward", type: "string", description: "被推荐人奖励 ( '1WOW')", required: true },
26
- { name: "max_referrals", type: "number", description: "每人最多推荐数 ( 10)", required: false },
24
+ { name: "referrer_reward", type: "string", description: "Referrer reward (e.g., '2WOW')", required: true },
25
+ { name: "referee_reward", type: "string", description: "Referee reward (e.g., '1WOW')", required: true },
26
+ { name: "max_referrals", type: "number", description: "Max referrals per person (e.g., 10)", required: false },
27
27
  ],
28
- example: "Alice 推荐 Bob 购买服务,Bob 完成首单后 Alice 2 WOWBob 1 WOW",
28
+ example: "Alice refers Bob to purchase a service; after Bob completes the first order, Alice gets 2 WOW and Bob gets 1 WOW.",
29
29
  relevantGuardOps: ["query", "repository_read", "repository_write"],
30
30
  },
31
31
  {
32
32
  type: "loyalty",
33
- name: "忠诚度阶梯奖励",
34
- description: "客户累计消费达到阶梯后解锁更高奖励,提升复购率和客单价。",
35
- guardCondition: "Guard 验证: 通过 Repository 查询该地址历史订单数 >= N, N 为当前阶梯阈值",
33
+ name: "Loyalty tiered reward",
34
+ description: "Customers unlock higher rewards after reaching cumulative spending tiers, improving repeat rate and average order value.",
35
+ guardCondition: "Guard verifies: via Repository query, the address's historical order count >= N, where N is the current tier threshold",
36
36
  amountRange: { min: "1WOW", max: "50WOW" },
37
37
  allocationStrategy: "tiered",
38
38
  parameters: [
39
- { name: "tier1_orders", type: "number", description: "第一阶梯订单数 ( 3)", required: true },
40
- { name: "tier1_reward", type: "string", description: "第一阶梯奖励 ( '1WOW')", required: true },
41
- { name: "tier2_orders", type: "number", description: "第二阶梯订单数 ( 10)", required: true },
42
- { name: "tier2_reward", type: "string", description: "第二阶梯奖励 ( '5WOW')", required: true },
43
- { name: "tier3_orders", type: "number", description: "第三阶梯订单数 ( 30)", required: false },
44
- { name: "tier3_reward", type: "string", description: "第三阶梯奖励 ( '20WOW')", required: false },
39
+ { name: "tier1_orders", type: "number", description: "Tier 1 order count (e.g., 3)", required: true },
40
+ { name: "tier1_reward", type: "string", description: "Tier 1 reward (e.g., '1WOW')", required: true },
41
+ { name: "tier2_orders", type: "number", description: "Tier 2 order count (e.g., 10)", required: true },
42
+ { name: "tier2_reward", type: "string", description: "Tier 2 reward (e.g., '5WOW')", required: true },
43
+ { name: "tier3_orders", type: "number", description: "Tier 3 order count (e.g., 30)", required: false },
44
+ { name: "tier3_reward", type: "string", description: "Tier 3 reward (e.g., '20WOW')", required: false },
45
45
  ],
46
- example: "客户累计 3 单得 1 WOW10 单得 5 WOW30 单得 20 WOW,激励持续消费。",
46
+ example: "A customer with 3 cumulative orders gets 1 WOW, 10 orders gets 5 WOW, 30 orders gets 20 WOW, incentivizing continued spending.",
47
47
  relevantGuardOps: ["query", "repository_read"],
48
48
  },
49
49
  {
50
50
  type: "flash_sale",
51
- name: "限时闪购",
52
- description: "在限定时间窗口内提供折扣或额外奖励,制造紧迫感促进即时转化。",
53
- guardCondition: "Guard 验证: 当前区块时间在 [start_time, end_time] 范围内 (Guard 时间条件)",
51
+ name: "Limited-time flash sale",
52
+ description: "Provides discounts or extra rewards within a limited time window, creating urgency to drive instant conversion.",
53
+ guardCondition: "Guard verifies: current block time is within [start_time, end_time] range (Guard time condition)",
54
54
  amountRange: { min: "0.1WOW", max: "20WOW" },
55
55
  allocationStrategy: "fixed",
56
56
  parameters: [
57
- { name: "start_time", type: "string", description: "开始时间 (Unix timestamp)", required: true },
58
- { name: "end_time", type: "string", description: "结束时间 (Unix timestamp)", required: true },
59
- { name: "amount", type: "string", description: "闪购奖励金额", required: true },
60
- { name: "max_claims", type: "number", description: "最大领取数 ( 100)", required: true },
57
+ { name: "start_time", type: "string", description: "Start time (Unix timestamp)", required: true },
58
+ { name: "end_time", type: "string", description: "End time (Unix timestamp)", required: true },
59
+ { name: "amount", type: "string", description: "Flash sale reward amount", required: true },
60
+ { name: "max_claims", type: "number", description: "Max claims (e.g., 100)", required: true },
61
61
  ],
62
- example: "周末限时 48 小时闪购,下单客户额外获得 2 WOW 返还,前 100 名有效。",
62
+ example: "Weekend 48-hour flash sale: ordering customers get an extra 2 WOW cashback, valid for the first 100.",
63
63
  relevantGuardOps: ["query", "time_condition"],
64
64
  },
65
65
  {
66
66
  type: "cashback",
67
- name: "消费返现",
68
- description: "客户完成订单后按消费比例返现,提升复购意愿。",
69
- guardCondition: "Guard 验证: order 已到达终态 (Progress completed), order.service == Service",
67
+ name: "Spending cashback",
68
+ description: "Customers receive cashback proportional to spending after completing an order, improving repeat purchase willingness.",
69
+ guardCondition: "Guard verifies: order has reached terminal state (Progress completed), and order.service == this Service",
70
70
  amountRange: { min: "0.1WOW", max: "100WOW" },
71
71
  allocationStrategy: "proportional",
72
72
  parameters: [
73
- { name: "cashback_rate", type: "string", description: "返现比例 ( '0.1' = 10%)", required: true },
74
- { name: "max_cashback", type: "string", description: "单笔最大返现 ( '10WOW')", required: true },
75
- { name: "budget", type: "string", description: "总预算 ( '500WOW')", required: true },
73
+ { name: "cashback_rate", type: "string", description: "Cashback rate (e.g., '0.1' = 10%)", required: true },
74
+ { name: "max_cashback", type: "string", description: "Max cashback per order (e.g., '10WOW')", required: true },
75
+ { name: "budget", type: "string", description: "Total budget (e.g., '500WOW')", required: true },
76
76
  ],
77
- example: "客户消费 10 WOW,按 10% 比例返现 1 WOW,下次消费可抵扣。",
77
+ example: "A customer spends 10 WOW, gets 10% cashback = 1 WOW, which can be deducted on the next purchase.",
78
78
  relevantGuardOps: ["query"],
79
79
  },
80
80
  {
81
81
  type: "milestone",
82
- name: "里程碑奖励",
83
- description: "Service 达到特定里程碑(如 100 单、1000 客户)时给早期支持者发放额外奖励。",
84
- guardCondition: "Guard 验证: Repository 查询 Service 累计订单数 >= milestone_threshold, claim 者为早期客户 (order_index < milestone)",
82
+ name: "Milestone reward",
83
+ description: "When a Service reaches a specific milestone (e.g., 100 orders, 1000 customers), early supporters receive extra rewards.",
84
+ guardCondition: "Guard verifies: Repository query shows Service cumulative order count >= milestone_threshold, and claimer is an early customer (order_index < milestone)",
85
85
  amountRange: { min: "1WOW", max: "100WOW" },
86
86
  allocationStrategy: "fixed",
87
87
  parameters: [
88
- { name: "milestone", type: "number", description: "里程碑值 ( 100)", required: true },
89
- { name: "reward_per_user", type: "string", description: "每人奖励 ( '5WOW')", required: true },
90
- { name: "max_recipients", type: "number", description: "最大受益人数 ( 50)", required: true },
88
+ { name: "milestone", type: "number", description: "Milestone value (e.g., 100)", required: true },
89
+ { name: "reward_per_user", type: "string", description: "Reward per person (e.g., '5WOW')", required: true },
90
+ { name: "max_recipients", type: "number", description: "Max beneficiaries (e.g., 50)", required: true },
91
91
  ],
92
- example: "Service 达到 100 单里程碑,前 50 名客户每人获得 5 WOW 额外奖励。",
92
+ example: "Service reaches the 100-order milestone; the first 50 customers each receive 5 WOW extra reward.",
93
93
  relevantGuardOps: ["query", "repository_read"],
94
94
  },
95
95
  ];
@@ -102,22 +102,22 @@ export function listRewardTemplates() {
102
102
  }
103
103
  export function suggestRewardTemplate(intent) {
104
104
  const lower = intent.toLowerCase();
105
- if (lower.includes("首单") || lower.includes("new") || lower.includes("first")) {
105
+ if (lower.includes("first order") || lower.includes("new") || lower.includes("first")) {
106
106
  return getRewardTemplate("first_order");
107
107
  }
108
- if (lower.includes("推荐") || lower.includes("裂变") || lower.includes("referral")) {
108
+ if (lower.includes("referral") || lower.includes("viral") || lower.includes("referral")) {
109
109
  return getRewardTemplate("referral");
110
110
  }
111
- if (lower.includes("复购") || lower.includes("忠诚") || lower.includes("loyalty")) {
111
+ if (lower.includes("repeat") || lower.includes("loyalty") || lower.includes("loyalty")) {
112
112
  return getRewardTemplate("loyalty");
113
113
  }
114
- if (lower.includes("限时") || lower.includes("闪购") || lower.includes("flash")) {
114
+ if (lower.includes("limited-time") || lower.includes("flash") || lower.includes("flash")) {
115
115
  return getRewardTemplate("flash_sale");
116
116
  }
117
- if (lower.includes("返现") || lower.includes("cashback")) {
117
+ if (lower.includes("cashback") || lower.includes("cashback")) {
118
118
  return getRewardTemplate("cashback");
119
119
  }
120
- if (lower.includes("里程碑") || lower.includes("milestone")) {
120
+ if (lower.includes("milestone") || lower.includes("milestone")) {
121
121
  return getRewardTemplate("milestone");
122
122
  }
123
123
  return undefined;
@@ -146,8 +146,8 @@ export const CONFIRMATION_RULES = [
146
146
  bypass_on_explicit_intent: [
147
147
  "use default account",
148
148
  "default account is fine",
149
- "用默认账户",
150
- "用默认账户即可",
149
+ "use the default account",
150
+ "default account works fine",
151
151
  ],
152
152
  },
153
153
  {
@@ -209,7 +209,7 @@ export const CONFIRMATION_RULES = [
209
209
  "gen_passport will consume gas for static testing",
210
210
  ],
211
211
  }),
212
- bypass_on_explicit_intent: ["test guard", "测试 guard", "gen passport", "生成 passport"],
212
+ bypass_on_explicit_intent: ["test guard", "testing guard", "gen passport", "generate passport"],
213
213
  },
214
214
  ];
215
215
  function extractAmount(data) {
@@ -26,8 +26,8 @@ export const TOOL_CONSTRAINTS = [
26
26
  constraints: [
27
27
  {
28
28
  field: "node.nodes",
29
- description: "Machine should have at least one node when published",
30
- severity: "warning",
29
+ description: "Machine must have at least one node when published",
30
+ severity: "error",
31
31
  check: (d) => {
32
32
  if (typeof d?.object === "string")
33
33
  return true;
@@ -61,7 +61,15 @@ export const TOOL_CONSTRAINTS = [
61
61
  },
62
62
  {
63
63
  operation_type: "order",
64
- constraints: [],
64
+ constraints: [
65
+ {
66
+ field: "object",
67
+ description: "Order requires an existing Order object reference",
68
+ severity: "error",
69
+ check: (d) => !!d?.object,
70
+ message: () => "Order requires 'object' field (Order object ID or name).",
71
+ },
72
+ ],
65
73
  },
66
74
  {
67
75
  operation_type: "reward",
@@ -118,7 +126,15 @@ export const TOOL_CONSTRAINTS = [
118
126
  },
119
127
  {
120
128
  operation_type: "progress",
121
- constraints: [],
129
+ constraints: [
130
+ {
131
+ field: "object",
132
+ description: "Progress requires an existing Progress object reference",
133
+ severity: "error",
134
+ check: (d) => !!d?.object,
135
+ message: () => "Progress requires 'object' field (Progress object ID or name).",
136
+ },
137
+ ],
122
138
  },
123
139
  ];
124
140
  const CONSTRAINT_INDEX = new Map(TOOL_CONSTRAINTS.map((c) => [c.operation_type, c]));
@@ -1,9 +1,9 @@
1
1
  export const TRUST_METRICS_VERSION = 1;
2
2
  const TRUST_LEVELS = [
3
- { min: 75, level: "trusted", label: "高信任" },
4
- { min: 50, level: "moderate", label: "中等信任" },
5
- { min: 25, level: "caution", label: "需注意" },
6
- { min: 0, level: "high_risk", label: "高风险" },
3
+ { min: 75, level: "trusted", label: "High trust" },
4
+ { min: 50, level: "moderate", label: "Moderate trust" },
5
+ { min: 25, level: "caution", label: "Needs attention" },
6
+ { min: 0, level: "high_risk", label: "High risk" },
7
7
  ];
8
8
  export function computeServiceTrustScore(metrics) {
9
9
  const breakdown = [];
@@ -11,49 +11,49 @@ export function computeServiceTrustScore(metrics) {
11
11
  const arbScore = computeArbitrationDimension(metrics);
12
12
  breakdown.push(arbScore);
13
13
  if (arbScore.score < arbScore.maxScore * 0.3) {
14
- warnings.push("仲裁信任分较低,建议检查仲裁记录");
14
+ warnings.push("Arbitration trust score is low; recommend checking arbitration records");
15
15
  }
16
16
  const reviewScore = computeReviewDimension(metrics);
17
17
  breakdown.push(reviewScore);
18
18
  if (reviewScore.score < reviewScore.maxScore * 0.3 && metrics.reviewStats) {
19
- warnings.push(`好评率较低 (${metrics.reviewStats.likes}/${metrics.reviewStats.totalReviews})`);
19
+ warnings.push(`Low like rate (${metrics.reviewStats.likes}/${metrics.reviewStats.totalReviews})`);
20
20
  }
21
21
  const fulfillmentScore = computeFulfillmentDimension(metrics);
22
22
  breakdown.push(fulfillmentScore);
23
23
  if (metrics.completedRate !== undefined && metrics.completedRate < 0.7) {
24
- warnings.push(`完成率仅 ${Math.round(metrics.completedRate * 100)}%`);
24
+ warnings.push(`Completion rate only ${Math.round(metrics.completedRate * 100)}%`);
25
25
  }
26
26
  const fundScore = computeFundDimension(metrics);
27
27
  breakdown.push(fundScore);
28
28
  if (metrics.compensationFundBalance === undefined || metrics.compensationFundBalance === 0n) {
29
- warnings.push("无赔偿金,客户权益保障不足");
29
+ warnings.push("No compensation fund; insufficient protection of customer rights");
30
30
  }
31
31
  const transparencyScore = computeTransparencyDimension(metrics);
32
32
  breakdown.push(transparencyScore);
33
33
  const totalScore = breakdown.reduce((sum, d) => sum + d.score, 0);
34
34
  const level = TRUST_LEVELS.find((l) => totalScore >= l.min)?.level ?? "high_risk";
35
- const label = TRUST_LEVELS.find((l) => totalScore >= l.min)?.label ?? "高风险";
35
+ const label = TRUST_LEVELS.find((l) => totalScore >= l.min)?.label ?? "High risk";
36
36
  const summary = buildSummary(totalScore, label, metrics, breakdown);
37
37
  return { score: totalScore, level, breakdown, summary, warnings };
38
38
  }
39
39
  function computeArbitrationDimension(metrics) {
40
40
  const maxScore = 30;
41
41
  if (metrics.arbitrationScore === undefined) {
42
- return { name: "arbitration", score: maxScore * 0.5, maxScore, description: "仲裁信任分(无数据,默认中等)", humanReadable: "仲裁记录: 无数据" };
42
+ return { name: "arbitration", score: maxScore * 0.5, maxScore, description: "Arbitration trust score (no data, default moderate)", humanReadable: "Arbitration record: no data" };
43
43
  }
44
44
  const score = Math.round((metrics.arbitrationScore / 100) * maxScore);
45
45
  return {
46
46
  name: "arbitration",
47
47
  score,
48
48
  maxScore,
49
- description: `仲裁信任分 ${metrics.arbitrationScore}/100`,
50
- humanReadable: `仲裁信任: ${metrics.arbitrationScore}/100${metrics.arbitrationCases !== undefined ? ` (${metrics.arbitrationCases} 案件)` : ""}`,
49
+ description: `Arbitration trust score ${metrics.arbitrationScore}/100`,
50
+ humanReadable: `Arbitration trust: ${metrics.arbitrationScore}/100${metrics.arbitrationCases !== undefined ? ` (${metrics.arbitrationCases} cases)` : ""}`,
51
51
  };
52
52
  }
53
53
  function computeReviewDimension(metrics) {
54
54
  const maxScore = 25;
55
55
  if (!metrics.reviewStats || metrics.reviewStats.totalReviews === 0) {
56
- return { name: "reviews", score: maxScore * 0.5, maxScore, description: "评价声誉(无评价数据)", humanReadable: "评价: 无数据" };
56
+ return { name: "reviews", score: maxScore * 0.5, maxScore, description: "Review reputation (no review data)", humanReadable: "Reviews: no data" };
57
57
  }
58
58
  const { likes, dislikes, verifiedReviews, totalReviews } = metrics.reviewStats;
59
59
  const likeRate = likes / Math.max(1, totalReviews);
@@ -63,14 +63,14 @@ function computeReviewDimension(metrics) {
63
63
  name: "reviews",
64
64
  score: Math.min(maxScore, score),
65
65
  maxScore,
66
- description: `好评率 ${Math.round(likeRate * 100)}% (${totalReviews} 条评价, ${verifiedReviews} 条带凭证)`,
67
- humanReadable: `好评率 ${Math.round(likeRate * 100)}% (${totalReviews} 评价)`,
66
+ description: `Like rate ${Math.round(likeRate * 100)}% (${totalReviews} reviews, ${verifiedReviews} verified)`,
67
+ humanReadable: `Like rate ${Math.round(likeRate * 100)}% (${totalReviews} reviews)`,
68
68
  };
69
69
  }
70
70
  function computeFulfillmentDimension(metrics) {
71
71
  const maxScore = 20;
72
72
  if (metrics.orderCount === undefined) {
73
- return { name: "fulfillment", score: maxScore * 0.5, maxScore, description: "履约记录(无订单数据)", humanReadable: "履约: 无数据" };
73
+ return { name: "fulfillment", score: maxScore * 0.5, maxScore, description: "Fulfillment record (no order data)", humanReadable: "Fulfillment: no data" };
74
74
  }
75
75
  let score = 0;
76
76
  const orderScore = Math.min(10, Math.floor(metrics.orderCount / 5));
@@ -85,14 +85,14 @@ function computeFulfillmentDimension(metrics) {
85
85
  name: "fulfillment",
86
86
  score: Math.min(maxScore, score),
87
87
  maxScore,
88
- description: `已完成 ${metrics.orderCount} 单, 完成率 ${metrics.completedRate !== undefined ? Math.round(metrics.completedRate * 100) + "%" : "未知"}`,
89
- humanReadable: `履约: ${metrics.orderCount} 单${metrics.avgCompletionTime !== undefined ? `, 平均 ${metrics.avgCompletionTime}h` : ""}`,
88
+ description: `Completed ${metrics.orderCount} orders, completion rate ${metrics.completedRate !== undefined ? Math.round(metrics.completedRate * 100) + "%" : "unknown"}`,
89
+ humanReadable: `Fulfillment: ${metrics.orderCount} orders${metrics.avgCompletionTime !== undefined ? `, avg ${metrics.avgCompletionTime}h` : ""}`,
90
90
  };
91
91
  }
92
92
  function computeFundDimension(metrics) {
93
93
  const maxScore = 15;
94
94
  if (metrics.compensationFundBalance === undefined || metrics.compensationFundBalance === 0n) {
95
- return { name: "fund_safety", score: 0, maxScore, description: "无赔偿金", humanReadable: "赔偿金: " };
95
+ return { name: "fund_safety", score: 0, maxScore, description: "No compensation fund", humanReadable: "Compensation fund: none" };
96
96
  }
97
97
  const threshold = 1000000000000n;
98
98
  const ratio = Number(metrics.compensationFundBalance * 100n / threshold) / 100;
@@ -101,8 +101,8 @@ function computeFundDimension(metrics) {
101
101
  name: "fund_safety",
102
102
  score,
103
103
  maxScore,
104
- description: `赔偿金 ${metrics.compensationFundBalance} 最小单位`,
105
- humanReadable: `赔偿金: 充足`,
104
+ description: `Compensation fund ${metrics.compensationFundBalance} smallest unit`,
105
+ humanReadable: `Compensation fund: sufficient`,
106
106
  };
107
107
  }
108
108
  function computeTransparencyDimension(metrics) {
@@ -118,12 +118,12 @@ function computeTransparencyDimension(metrics) {
118
118
  name: "transparency",
119
119
  score: Math.min(maxScore, score),
120
120
  maxScore,
121
- description: `链上事件 ${metrics.hasPublishedEvents ? "✓" : "✗"}, Machine ${metrics.hasMachineBound ? "✓" : "✗"}, Guard ${metrics.hasBuyGuard ? "✓" : "✗"}`,
122
- humanReadable: `透明度: ${["事件", "Machine", "Guard"].filter((_, i) => [metrics.hasPublishedEvents, metrics.hasMachineBound, metrics.hasBuyGuard][i]).join("+") || ""}`,
121
+ description: `On-chain events ${metrics.hasPublishedEvents ? "✓" : "✗"}, Machine ${metrics.hasMachineBound ? "✓" : "✗"}, Guard ${metrics.hasBuyGuard ? "✓" : "✗"}`,
122
+ humanReadable: `Transparency: ${["Events", "Machine", "Guard"].filter((_, i) => [metrics.hasPublishedEvents, metrics.hasMachineBound, metrics.hasBuyGuard][i]).join("+") || "none"}`,
123
123
  };
124
124
  }
125
125
  function buildSummary(score, label, metrics, breakdown) {
126
- const parts = [`信任分 ${score}/100 (${label})`];
126
+ const parts = [`Trust score ${score}/100 (${label})`];
127
127
  for (const d of breakdown) {
128
128
  parts.push(`${d.humanReadable}`);
129
129
  }
@@ -132,7 +132,7 @@ function buildSummary(score, label, metrics, breakdown) {
132
132
  export function quickTrustCheck(metrics) {
133
133
  const result = computeServiceTrustScore(metrics);
134
134
  if (result.score < 25) {
135
- return { pass: false, reason: `信任分 ${result.score}/100,高风险: ${result.warnings.join("; ")}` };
135
+ return { pass: false, reason: `Trust score ${result.score}/100, high risk: ${result.warnings.join("; ")}` };
136
136
  }
137
- return { pass: true, reason: `信任分 ${result.score}/100 (${result.level})` };
137
+ return { pass: true, reason: `Trust score ${result.score}/100 (${result.level})` };
138
138
  }
@@ -122,7 +122,7 @@ export const ExperienceSchema = z.object({
122
122
  avoid: z.array(z.string()).optional().describe("Pitfalls to avoid based on history. Example: ['Guard rejection on delivery_proof']"),
123
123
  relevance: z.number().min(0).max(1).optional().describe("Relevance score 0-1 of the matched experience. Example: 0.85"),
124
124
  matched_scenario: z.string().optional().describe("Matched historical scenario. Example: 'publish_service_freelance'"),
125
- }).strict().describe("Experience layer feedback from past operations (Phase 2 议题 2). Provides advice and pitfalls based on historical patterns.");
125
+ }).strict().describe("Experience layer feedback from past operations (Phase 2 Topic 2). Provides advice and pitfalls based on historical patterns.");
126
126
  export const ServiceStatusSchema = z.object({
127
127
  active: z.array(z.string()).describe("Phase 2 services currently active (enabled). Example: ['confirm_gate','project_service','experience_layer']"),
128
128
  inactive: z.array(z.string()).optional().describe("Phase 2 services currently inactive (can be toggled via config_operation). Example: ['harness','graph_persist']"),
@@ -131,29 +131,29 @@ export const CustomerReminderSchema = z.object({
131
131
  id: z.string().describe("Reminder rule id. Example: 'high_risk_score'"),
132
132
  stage: z.enum(["browse", "evaluate", "preorder", "in_progress", "complete", "after_sale"]).describe("Order lifecycle stage when this reminder fires. Example: 'evaluate'"),
133
133
  priority: z.enum(["required", "recommended", "info", "reminder"]).describe("Priority. 'required' = blocks purchase; 'recommended' = strong caution. Example: 'required'"),
134
- message: z.string().describe("Human-readable reminder message. Example: '🔴 综合风险分 25/100,强烈建议不购买'"),
134
+ message: z.string().describe("Human-readable reminder message. Example: 'Composite risk score 25/100, strongly discourage purchase'"),
135
135
  action: z.string().optional().describe("Suggested next action. Example: 'require merchant to bind Arbitration before ordering'"),
136
136
  }).strict().describe("A buyer-side reminder triggered at a specific order lifecycle stage (Phase 3 C-3).");
137
137
  export const PreferenceMatchSchema = z.object({
138
138
  score: z.number().min(0).max(100).describe("Match score 0-100 (higher = better fit). Example: 75"),
139
- matches: z.array(z.string()).describe("Aspects that match user preferences. Example: ['价格低于均价 10%','有仲裁']"),
140
- mismatches: z.array(z.string()).describe("Aspects that mismatch user preferences. Example: ['交付周期超出期望']"),
139
+ matches: z.array(z.string()).describe("Aspects that match user preferences. Example: ['Price 10% below average','Has arbitration']"),
140
+ mismatches: z.array(z.string()).describe("Aspects that mismatch user preferences. Example: ['Delivery cycle exceeds expectation']"),
141
141
  }).strict().describe("Service-to-preference match result (Phase 3 C-2). 7-dimension scoring: price/time/region/brand/bargain/emotion/risk.");
142
142
  export const CustomerAdviceSchema = z.object({
143
143
  risk_score: z.number().min(0).max(100).optional().describe("Composite risk score 0-100 (higher = safer). Relation: from risk-assessment.ts 4-dimension scoring. Example: 75"),
144
144
  risk_level: z.enum(["low", "medium_low", "medium_high", "high"]).optional().describe("Risk level bucket. 'high' = strongly discourage purchase. Example: 'medium_high'"),
145
- recommendations: z.array(z.string()).describe("Actionable recommendations for the buyer. Example: ['要求商家配置仲裁','通过 Messenger 协商退款条款']"),
146
- reminders: z.array(CustomerReminderSchema).describe("Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'🔴 模糊 Guard 必须人工审查'}]"),
145
+ recommendations: z.array(z.string()).describe("Actionable recommendations for the buyer. Example: ['Require merchant to configure arbitration','Negotiate refund terms via Messenger']"),
146
+ reminders: z.array(CustomerReminderSchema).describe("Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'Ambiguous Guard must be human-reviewed'}]"),
147
147
  preference_match: PreferenceMatchSchema.optional().describe("Service-to-preference match (populated when user preferences exist). Example: {score:75, matches:[...], mismatches:[...]}"),
148
148
  }).strict().describe("Buyer-side advice (Phase 3 C-3.3). Populated in semantic.customer_advice for order/query operations when customer_intelligence service is enabled.");
149
149
  export const EvolutionContextSchema = z.object({
150
- industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: '行业健康度 82/100healthy);累积 25 个行业信号'"),
151
- evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: '建议强制配置仲裁 + 赔偿金 + 交付 Guard'"),
150
+ industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: 'Industry health 82/100 (healthy); 25 cumulative industry signals'"),
151
+ evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: 'Recommend mandatory arbitration + compensation fund + delivery Guard'"),
152
152
  confidence: z.number().min(0).max(1).describe("Confidence of the evolution context 0-1. <0.5 means no data yet. Example: 0.75"),
153
153
  health_score: z.number().min(0).max(100).optional().describe("Industry health score 0-100 if available. Example: 82"),
154
154
  pending_suggestions: z.number().int().min(0).optional().describe("Count of pending industry update suggestions (filtered by role if role is set). Example: 3"),
155
155
  intent: z.enum(["default", "growth", "retention", "compliance", "efficiency", "trust_building", "custom"]).optional().describe("Phase 4 P4-6.C: Current business intent driving the scoring model. Absent = 'default'. Example: 'growth'"),
156
- role_advice: z.array(z.string()).optional().describe("Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['强化忠诚度飞轮','优化首单转化']"),
156
+ role_advice: z.array(z.string()).optional().describe("Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['Strengthen loyalty flywheel','Optimize first-order conversion']"),
157
157
  role: z.enum(["user", "merchant", "arbitrator"]).optional().describe("Phase 4 P4-6.C: Role used for advice routing. Example: 'merchant'"),
158
158
  }).strict().describe("Phase 4 industry evolution context (populated when industry_evolution service is enabled). Provides AI with industry-level health signals, evolution advice, and role-targeted recommendations.");
159
159
  export const GuardPuzzleStatusSchema = z.object({
@@ -179,17 +179,17 @@ export const GuardAdviceSchema = z.object({
179
179
  matched_scene: z.string().optional()
180
180
  .describe("Matched Guard scene id from the 8 binding scenarios ledger. Example: 'machine_forward_guard'"),
181
181
  scene_description: z.string().optional()
182
- .describe("Human-readable scene description. Example: '工作流节点推进验证(Forward.guard'"),
182
+ .describe("Human-readable scene description. Example: 'Workflow node forward validation (Forward.guard)'"),
183
183
  scene_constraints: z.array(z.string()).optional()
184
- .describe("Special constraints for the matched scene. Example: ['Machine 发布后 Forward.guard 不可修改']"),
184
+ .describe("Special constraints for the matched scene. Example: ['Forward.guard cannot be modified after Machine is published']"),
185
185
  suggested_patterns: z.array(z.string()).optional()
186
- .describe("Suggested Guard patterns based on user intent. Example: ['时间锁','进度状态检查']"),
186
+ .describe("Suggested Guard patterns based on user intent. Example: ['time lock','progress status check']"),
187
187
  available_queries: z.array(GuardAvailableQuerySchema).optional()
188
188
  .describe("Available query instructions for the current context (subset of 375 GUARDQUERY entries)"),
189
189
  risk_warnings: z.array(z.string()).optional()
190
- .describe("Risk warnings for the current Guard design. Example: ['Guard 创建后不可修改','时间锁测试用 1000ms']"),
190
+ .describe("Risk warnings for the current Guard design. Example: ['Guard cannot be modified after creation','Time lock test uses 1000ms']"),
191
191
  pending_questions: z.array(z.string()).optional()
192
- .describe("Questions for the user to complete the puzzle. Example: ['Guard 将绑定到哪个 Host Object']"),
192
+ .describe("Questions for the user to complete the puzzle. Example: ['Which Host Object will the Guard bind to?']"),
193
193
  confirmation_text: z.string().optional()
194
194
  .describe("Structured semantic confirmation text for user review (generated when puzzle is complete). User must explicitly confirm before CREATE."),
195
195
  test_result: z.object({
@@ -217,7 +217,7 @@ export const SemanticSummarySchema = z.object({
217
217
  events: z.array(EventSemanticSchema).optional().describe("On-chain events annotated with business semantics (S-8)"),
218
218
  next_actions: z.array(NextActionSchema).optional().describe("Recommended next actions to drive the workflow forward"),
219
219
  warnings: z.array(z.string()).optional().describe("Business-level warnings. Example: 'order_allocators not configured; order funds cannot be distributed'"),
220
- experience: ExperienceSchema.optional().describe("Experience layer feedback from past operations (Phase 2 议题 2)"),
220
+ experience: ExperienceSchema.optional().describe("Experience layer feedback from past operations (Phase 2 Topic 2)"),
221
221
  service_status: ServiceStatusSchema.optional().describe("Phase 2 runtime service status (populated when semantic_rich is enabled). Lets AI see active services in each response."),
222
222
  customer_advice: CustomerAdviceSchema.optional().describe("Buyer-side advice (Phase 3 C-3.3). Populated when customer_intelligence service is enabled AND operation is order/query on a Service. Contains risk_score, recommendations, reminders, and preference_match."),
223
223
  evolution_context: EvolutionContextSchema.optional().describe("Phase 4 industry evolution context (populated when industry_evolution service is enabled). Provides AI with industry health signals and evolution advice."),
@@ -246,7 +246,7 @@ export const OperationPreviewSchema = z.object({
246
246
  immutable_after: z.array(z.string()).optional().describe("Fields that become immutable after this op (for publish). Example: ['machine','order_allocators']"),
247
247
  warnings: z.array(z.string()).optional().describe("Default-value warnings. Example: ['Using default account (env.account=\"\")']"),
248
248
  irreversible: z.boolean().optional().describe("True when the operation cannot be reverted. Example: true"),
249
- }).strict().describe("Preview of an operation awaiting user confirmation (Phase 2 议题 4 ConfirmGate).");
249
+ }).strict().describe("Preview of an operation awaiting user confirmation (Phase 2 Topic 4 ConfirmGate).");
250
250
  export const CallPendingConfirmationSchema = z.object({
251
251
  type: z.literal("pending_confirmation").describe("Discriminator. The operation was NOT executed; it is blocked pending user confirmation. Re-call with env.confirmed=true to proceed, or modify/cancel."),
252
252
  preview: OperationPreviewSchema.describe("Preview of the operation awaiting confirmation."),