@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
@@ -0,0 +1,424 @@
1
+ import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
2
+ const hasRefundPath = (p) => p.workflow_analysis?.has_refund_path ?? false;
3
+ const hasArbitrationPath = (p) => p.workflow_analysis?.has_arbitration_path ?? false;
4
+ const hasMilestoneNodes = (p) => p.workflow_analysis?.has_milestone_nodes ?? false;
5
+ const hasMessenger = (p) => p.trust_signals?.has_messenger ?? false;
6
+ const compensationCoversOrder = (p) => p.fund_safety?.compensation_covers_order ?? false;
7
+ const lockDurationSafe = (p) => p.fund_safety?.lock_duration_safe ?? false;
8
+ const userOperableForwards = (p) => p.workflow_analysis?.user_operable_forwards ?? 0;
9
+ const wipVerified = (p) => p.service_basics.wip_verified === true;
10
+ const hasCompensationFund = (p) => p.service_basics.compensation_fund_balance > 0n;
11
+ const deadEndCount = (p) => p.workflow_analysis?.dead_end_nodes?.length ?? 0;
12
+ const totalNodes = (p) => p.workflow_analysis?.total_nodes ?? 0;
13
+ const trustScore = (p) => p.trust_signals?.trust_score ?? 0;
14
+ const reviewTotal = (p) => p.trust_signals?.review_total ?? 0;
15
+ const merchantTotalOrders = (p) => p.merchant_behavior?.total_orders ?? 0;
16
+ const repeatBuyerRate = (p) => p.merchant_behavior?.repeat_buyer_rate ?? 0;
17
+ const disputeRate = (p) => p.merchant_behavior?.dispute_rate ?? 1;
18
+ const INDUSTRY_RISK_CHECKS = {
19
+ freelance: [
20
+ {
21
+ id: "fr_wip_verified", industry: "freelance", dimension: "trust",
22
+ description: "WIP hash verified (work traceable)",
23
+ weight: 30,
24
+ passed: wipVerified,
25
+ advice: "⚠️ WIP 未验证:自由职业交付物无法溯源,建议要求商家提供 WIP hash 并写入 WTS。",
26
+ },
27
+ {
28
+ id: "fr_milestone_nodes", industry: "freelance", dimension: "workflow",
29
+ description: "存在里程碑节点(分阶段验收)",
30
+ weight: 25,
31
+ passed: hasMilestoneNodes,
32
+ advice: "⚠️ 无里程碑节点:交付一次性完成无中间验收,建议要求商家增加分阶段交付节点。",
33
+ },
34
+ {
35
+ id: "fr_refund_path", industry: "freelance", dimension: "workflow",
36
+ description: "Has refund path",
37
+ weight: 25,
38
+ passed: hasRefundPath,
39
+ advice: "⚠️ No refund path: if freelance order delivery is not satisfactory, funds are hard to recover.",
40
+ },
41
+ {
42
+ id: "fr_response_time", industry: "freelance", dimension: "trust",
43
+ description: "Messenger configured (communication response guarantee)",
44
+ weight: 20,
45
+ passed: hasMessenger,
46
+ advice: "⚠️ Messenger not configured: cannot conduct requirement confirmation and revision communication.",
47
+ },
48
+ ],
49
+ rental: [
50
+ {
51
+ id: "rt_compensation_full", industry: "rental", dimension: "fund",
52
+ description: "赔偿金完全覆盖订单金额",
53
+ weight: 30,
54
+ passed: compensationCoversOrder,
55
+ advice: "🔴 赔偿金未完全覆盖:租赁物损坏时赔付不足,建议选择赔偿金充足的商家。",
56
+ },
57
+ {
58
+ id: "rt_lock_duration", industry: "rental", dimension: "fund",
59
+ description: "锁定期安全(赔偿金不可被商家随时撤回)",
60
+ weight: 25,
61
+ passed: lockDurationSafe,
62
+ advice: "⚠️ 锁定期不安全:商家可能随时撤回赔偿金,押金安全无保障。",
63
+ },
64
+ {
65
+ id: "rt_arbitration", industry: "rental", dimension: "workflow",
66
+ description: "Arbitration configured (damage dispute resolution)",
67
+ weight: 25,
68
+ passed: hasArbitrationPath,
69
+ advice: "⚠️ Arbitration not configured: no third-party ruling channel for rental damage disputes.",
70
+ },
71
+ {
72
+ id: "rt_user_operable", industry: "rental", dimension: "workflow",
73
+ description: "存在用户可操作路径(归还/确认)",
74
+ weight: 20,
75
+ passed: (p) => userOperableForwards(p) > 0,
76
+ advice: "🔴 无用户可操作路径:归还流程完全依赖商家,可能被恶意拖延。",
77
+ },
78
+ ],
79
+ education: [
80
+ {
81
+ id: "ed_refund_path", industry: "education", dimension: "workflow",
82
+ description: "Has refund path (refund guarantee)",
83
+ weight: 30,
84
+ passed: hasRefundPath,
85
+ advice: "🔴 No refund path: course refund not guaranteed, recommend asking the merchant to configure a refund Allocator.",
86
+ },
87
+ {
88
+ id: "ed_compensation", industry: "education", dimension: "fund",
89
+ description: "Has compensation fund",
90
+ weight: 25,
91
+ passed: hasCompensationFund,
92
+ advice: "⚠️ No compensation fund: no automatic compensation source when course service quality is not up to standard.",
93
+ },
94
+ {
95
+ id: "ed_arbitration", industry: "education", dimension: "workflow",
96
+ description: "Arbitration configured",
97
+ weight: 25,
98
+ passed: hasArbitrationPath,
99
+ advice: "⚠️ Arbitration not configured: no resolution channel for course quality disputes.",
100
+ },
101
+ {
102
+ id: "ed_long_cycle_ok", industry: "education", dimension: "workflow",
103
+ description: "Long cycle acceptable (education industry allows long cycles, over 90 days needs attention)",
104
+ weight: 20,
105
+ passed: () => true,
106
+ advice: "ℹ️ Long delivery cycles are normal in education, but if the actual cycle exceeds 90 days, recommend periodically checking learning progress and lesson consumption.",
107
+ },
108
+ ],
109
+ travel: [
110
+ {
111
+ id: "tr_urgent_delivery", industry: "travel", dimension: "workflow",
112
+ description: "Urgent delivery configuration (needs milestone nodes for phased acceptance)",
113
+ weight: 30,
114
+ passed: hasMilestoneNodes,
115
+ advice: "⚠️ No milestone nodes: travel itinerary has no phased acceptance, recommend setting nodes by itinerary stage.",
116
+ },
117
+ {
118
+ id: "tr_compensation_full", industry: "travel", dimension: "fund",
119
+ description: "Compensation fully covers (breach compensation)",
120
+ weight: 25,
121
+ passed: compensationCoversOrder,
122
+ advice: "🔴 Compensation not fully covered: insufficient payout when itinerary breaches.",
123
+ },
124
+ {
125
+ id: "tr_refund_path", industry: "travel", dimension: "workflow",
126
+ description: "Has refund path (itinerary change/cancellation)",
127
+ weight: 25,
128
+ passed: hasRefundPath,
129
+ advice: "⚠️ No refund path: funds hard to recover when itinerary changes or cancels due to force majeure.",
130
+ },
131
+ {
132
+ id: "tr_messenger", industry: "travel", dimension: "trust",
133
+ description: "Messenger configured (emergency communication)",
134
+ weight: 20,
135
+ passed: hasMessenger,
136
+ advice: "⚠️ Messenger not configured: cannot immediately contact merchant during travel emergencies.",
137
+ },
138
+ ],
139
+ subscription: [
140
+ {
141
+ id: "sub_no_lockin", industry: "subscription", dimension: "workflow",
142
+ description: "No long-term lock-in (no dead-end nodes, can exit)",
143
+ weight: 30,
144
+ passed: (p) => deadEndCount(p) === 0,
145
+ advice: "🔴 Dead-end nodes exist: subscription may be locked and unable to exit, auto-renewal trap exists.",
146
+ },
147
+ {
148
+ id: "sub_refund_path", industry: "subscription", dimension: "workflow",
149
+ description: "Has refund path (exit mechanism)",
150
+ weight: 25,
151
+ passed: hasRefundPath,
152
+ advice: "⚠️ No refund path: remaining cycle fees hard to recover after subscription exit.",
153
+ },
154
+ {
155
+ id: "sub_user_operable", industry: "subscription", dimension: "workflow",
156
+ description: "Has user-operable path (pause/downgrade/cancel)",
157
+ weight: 25,
158
+ passed: (p) => userOperableForwards(p) > 0,
159
+ advice: "🔴 No user-operable path: subscription status entirely controlled by merchant, cannot pause or cancel independently.",
160
+ },
161
+ {
162
+ id: "sub_compensation_optional", industry: "subscription", dimension: "fund",
163
+ description: "Compensation optional (not mandatory for subscription industry)",
164
+ weight: 20,
165
+ passed: () => true,
166
+ advice: "ℹ️ Compensation is not mandatory for subscription industry; having it is better.",
167
+ },
168
+ ],
169
+ retail: [
170
+ {
171
+ id: "ret_wip_verified", industry: "retail", dimension: "trust",
172
+ description: "WIP verified (authenticity/logistics traceable)",
173
+ weight: 25,
174
+ passed: wipVerified,
175
+ advice: "⚠️ WIP not verified: product traceability info missing, recommend confirming authenticity guarantee.",
176
+ },
177
+ {
178
+ id: "ret_compensation_full", industry: "retail", dimension: "fund",
179
+ description: "赔偿金完全覆盖",
180
+ weight: 25,
181
+ passed: compensationCoversOrder,
182
+ advice: "⚠️ 赔偿金未完全覆盖:退换货纠纷时赔付不足。",
183
+ },
184
+ {
185
+ id: "ret_refund_path", industry: "retail", dimension: "workflow",
186
+ description: "存在退款路径(退换货)",
187
+ weight: 25,
188
+ passed: hasRefundPath,
189
+ advice: "🔴 无退款路径:退换货无保障。",
190
+ },
191
+ {
192
+ id: "ret_arbitration", industry: "retail", dimension: "workflow",
193
+ description: "Arbitration configured",
194
+ weight: 25,
195
+ passed: hasArbitrationPath,
196
+ advice: "⚠️ Arbitration not configured: no third-party ruling for return/exchange disputes.",
197
+ },
198
+ ],
199
+ };
200
+ function commonNeeds() {
201
+ return [
202
+ {
203
+ id: "need_arbitration", tier: "common",
204
+ description: "配置仲裁(纠纷解决通道)",
205
+ satisfied: hasArbitrationPath,
206
+ advice: "未配置仲裁:纠纷无第三方解决通道。",
207
+ },
208
+ {
209
+ id: "need_refund_path", tier: "common",
210
+ description: "Has refund path",
211
+ satisfied: hasRefundPath,
212
+ advice: "无退款路径:交付失败时资金难以回收。",
213
+ },
214
+ {
215
+ id: "need_user_operable", tier: "common",
216
+ description: "Has user-operable Forward",
217
+ satisfied: (p) => userOperableForwards(p) > 0,
218
+ advice: "No user-operable steps in workflow, order progress depends entirely on merchant.",
219
+ },
220
+ {
221
+ id: "need_messenger", tier: "common",
222
+ description: "Messenger configured",
223
+ satisfied: hasMessenger,
224
+ advice: "商家无 Messenger 通道,无法协商或售后沟通。",
225
+ },
226
+ ];
227
+ }
228
+ const INDUSTRY_NEEDS = {
229
+ freelance: [
230
+ ...commonNeeds(),
231
+ {
232
+ id: "need_wip_verified", tier: "personalized",
233
+ description: "WIP 验证(作品知识产权可溯源)",
234
+ satisfied: wipVerified,
235
+ advice: "WIP 未验证:作品知识产权归属与原创性无法溯源。",
236
+ },
237
+ {
238
+ id: "need_milestone_nodes", tier: "personalized",
239
+ description: "Milestone nodes (phased feedback)",
240
+ satisfied: hasMilestoneNodes,
241
+ advice: "No milestone nodes: lack of phased feedback and revision round control.",
242
+ },
243
+ {
244
+ id: "need_merchant_history", tier: "advanced",
245
+ description: "商家历史 ≥3 单(履约经验)",
246
+ satisfied: (p) => merchantTotalOrders(p) >= 3,
247
+ advice: "商家历史订单不足 3 单:履约经验有限。",
248
+ },
249
+ ],
250
+ rental: [
251
+ ...commonNeeds(),
252
+ {
253
+ id: "need_lock_duration_safe", tier: "personalized",
254
+ description: "Lock duration safe (deposit cannot be withdrawn)",
255
+ satisfied: lockDurationSafe,
256
+ advice: "Lock duration not safe: deposit may be withdrawn by merchant at any time.",
257
+ },
258
+ {
259
+ id: "need_compensation_full", tier: "personalized",
260
+ description: "Compensation fully covers",
261
+ satisfied: compensationCoversOrder,
262
+ advice: "Compensation not fully covered: insufficient payout for rental item damage.",
263
+ },
264
+ {
265
+ id: "need_merchant_history", tier: "advanced",
266
+ description: "Merchant history ≥5 orders (rental experience)",
267
+ satisfied: (p) => merchantTotalOrders(p) >= 5,
268
+ advice: "Merchant history orders less than 5: rental service experience limited.",
269
+ },
270
+ ],
271
+ education: [
272
+ ...commonNeeds(),
273
+ {
274
+ id: "need_has_compensation", tier: "personalized",
275
+ description: "Has compensation fund (course quality guarantee)",
276
+ satisfied: hasCompensationFund,
277
+ advice: "No compensation fund: no compensation source when course quality is not up to standard.",
278
+ },
279
+ {
280
+ id: "need_long_cycle_ok", tier: "personalized",
281
+ description: "长周期可接受",
282
+ satisfied: () => true,
283
+ advice: "教育行业长周期属正常;建议跟踪课时消耗与出勤。",
284
+ },
285
+ {
286
+ id: "need_high_reputation", tier: "advanced",
287
+ description: "声誉评分高(trust_score ≥70)",
288
+ satisfied: (p) => trustScore(p) >= 70,
289
+ advice: "商家声誉评分低于 70:课程口碑可能不佳。",
290
+ },
291
+ ],
292
+ travel: [
293
+ ...commonNeeds(),
294
+ {
295
+ id: "need_urgent_delivery", tier: "personalized",
296
+ description: "Urgent delivery configuration (milestone phasing)",
297
+ satisfied: hasMilestoneNodes,
298
+ advice: "No milestone nodes: itinerary has no phased acceptance, urgent delivery guarantee insufficient.",
299
+ },
300
+ {
301
+ id: "need_compensation_full", tier: "personalized",
302
+ description: "赔偿金完全覆盖(违约赔偿)",
303
+ satisfied: compensationCoversOrder,
304
+ advice: "赔偿金未完全覆盖:行程违约赔付不足。",
305
+ },
306
+ {
307
+ id: "need_high_reputation", tier: "advanced",
308
+ description: "High reputation score (trust_score ≥70)",
309
+ satisfied: (p) => trustScore(p) >= 70,
310
+ advice: "Merchant reputation score below 70: travel service reputation may be poor.",
311
+ },
312
+ ],
313
+ subscription: [
314
+ ...commonNeeds(),
315
+ {
316
+ id: "need_no_lockin", tier: "personalized",
317
+ description: "无长期锁定(无死端节点)",
318
+ satisfied: (p) => deadEndCount(p) === 0,
319
+ advice: "存在死端节点:订阅可能被锁定,存在续费陷阱。",
320
+ },
321
+ {
322
+ id: "need_low_dispute", tier: "personalized",
323
+ description: "Low dispute rate (≤15%, stable content quality)",
324
+ satisfied: (p) => disputeRate(p) <= 0.15,
325
+ advice: "Dispute rate is high: subscription content quality may be unstable.",
326
+ },
327
+ {
328
+ id: "need_repeat_rate", tier: "advanced",
329
+ description: "Repeat buyer rate ≥20% (strong subscription renewal willingness)",
330
+ satisfied: (p) => repeatBuyerRate(p) >= 0.2,
331
+ advice: "Repeat buyer rate below 20%: subscription renewal willingness is weak, service may not be worth long-term subscription.",
332
+ },
333
+ ],
334
+ retail: [
335
+ ...commonNeeds(),
336
+ {
337
+ id: "need_wip_verified", tier: "personalized",
338
+ description: "WIP verified (authenticity/logistics traceability)",
339
+ satisfied: wipVerified,
340
+ advice: "WIP not verified: product authenticity and logistics traceability info missing.",
341
+ },
342
+ {
343
+ id: "need_compensation_full", tier: "personalized",
344
+ description: "赔偿金完全覆盖",
345
+ satisfied: compensationCoversOrder,
346
+ advice: "赔偿金未完全覆盖:退换货纠纷赔付不足。",
347
+ },
348
+ {
349
+ id: "need_high_reputation", tier: "advanced",
350
+ description: "High reputation score (trust_score ≥70)",
351
+ satisfied: (p) => trustScore(p) >= 70,
352
+ advice: "Merchant reputation score below 70: product or service reputation may be poor.",
353
+ },
354
+ ],
355
+ };
356
+ export function getIndustryRiskChecks(industry) {
357
+ return INDUSTRY_RISK_CHECKS[industry];
358
+ }
359
+ export function getIndustryNeeds(industry) {
360
+ return INDUSTRY_NEEDS[industry];
361
+ }
362
+ export function checkIndustryNeeds(puzzle, industry) {
363
+ const needs = getIndustryNeeds(industry);
364
+ const met = [];
365
+ const unmet = [];
366
+ for (const n of needs) {
367
+ if (n.satisfied(puzzle))
368
+ met.push(n);
369
+ else
370
+ unmet.push(n);
371
+ }
372
+ return { met, unmet };
373
+ }
374
+ export function assessIndustryRisks(puzzle, industry) {
375
+ const internalChecks = INDUSTRY_RISK_CHECKS[industry];
376
+ const totalWeight = internalChecks.reduce((s, c) => s + c.weight, 0);
377
+ const checks = internalChecks.map((c) => {
378
+ const passed = c.passed(puzzle);
379
+ return {
380
+ id: c.id,
381
+ dimension: c.dimension,
382
+ description: c.description,
383
+ weight: c.weight,
384
+ passed,
385
+ advice: passed ? undefined : c.advice,
386
+ };
387
+ });
388
+ const passedWeight = checks.reduce((s, c) => s + (c.passed ? c.weight : 0), 0);
389
+ const passRatio = totalWeight > 0 ? passedWeight / totalWeight : 0;
390
+ const rawAdj = Math.round((passRatio - 0.5) * 20);
391
+ const score_adjustment = Math.max(-10, Math.min(10, rawAdj));
392
+ const needs = getIndustryNeeds(industry);
393
+ const { met, unmet } = checkIndustryNeeds(puzzle, industry);
394
+ const passedCount = checks.filter((c) => c.passed).length;
395
+ const sign = score_adjustment >= 0 ? "+" : "";
396
+ const summary = `${industry} industry risk check: ${passedCount} checks passed out of ${checks.length}` +
397
+ ` (pass rate ${Math.round(passRatio * 100)}%); ${met.length} needs satisfied out of ${needs.length};` +
398
+ ` Score adjustment ${sign}${score_adjustment}.`;
399
+ return {
400
+ industry,
401
+ checks,
402
+ needs,
403
+ unmet_needs: unmet,
404
+ score_adjustment,
405
+ summary,
406
+ };
407
+ }
408
+ export function inferIndustry(puzzle) {
409
+ const basics = puzzle.service_basics;
410
+ if (basics.price_raw < 1000000000n && basics.has_wip) {
411
+ return "retail";
412
+ }
413
+ if (basics.compensation_lock_duration > 7) {
414
+ return "rental";
415
+ }
416
+ if (reviewTotal(puzzle) > 50) {
417
+ return "retail";
418
+ }
419
+ if (totalNodes(puzzle) > 10) {
420
+ return "education";
421
+ }
422
+ return "freelance";
423
+ }
424
+ export { CUSTOMER_INTELLIGENCE_VERSION };
@@ -0,0 +1,102 @@
1
+ import type { InfoPuzzle, ServiceBasics, WorkflowAnalysis, FundSafety, TrustSignals, MerchantBehavior, MarketContext, PuzzleDepth } from "./types.js";
2
+ import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
3
+ export interface ServiceRawData {
4
+ name?: string;
5
+ bPublished?: boolean;
6
+ bPaused?: boolean;
7
+ price?: string;
8
+ priceRaw?: bigint;
9
+ token_type?: string;
10
+ sales?: Array<{
11
+ suspension?: boolean;
12
+ wip_url?: string;
13
+ wip_hash?: string;
14
+ }>;
15
+ machine?: string;
16
+ buy_guard?: string;
17
+ customer_required?: unknown[];
18
+ arbitrations?: string[];
19
+ compensation_fund?: {
20
+ balance?: bigint;
21
+ };
22
+ compensation_lock_duration?: number;
23
+ um?: string;
24
+ order_allocators?: Array<{
25
+ allocators?: Array<{
26
+ amount?: {
27
+ type?: string;
28
+ value?: bigint;
29
+ };
30
+ surplus_to?: string;
31
+ guard?: string;
32
+ marker?: {
33
+ node?: string;
34
+ };
35
+ }>;
36
+ }>;
37
+ }
38
+ export interface MachineNodeRaw {
39
+ name: string;
40
+ forwards?: Array<{
41
+ name?: string;
42
+ weight?: number;
43
+ namedOperator?: string | null;
44
+ guard?: string | null;
45
+ to?: string;
46
+ }>;
47
+ is_pair_done?: boolean;
48
+ }
49
+ export interface ReviewRaw {
50
+ rating?: "like" | "dislike" | string;
51
+ reviewer?: string;
52
+ verified?: boolean;
53
+ has_evidence?: boolean;
54
+ timestamp?: number;
55
+ }
56
+ export interface EventRaw {
57
+ type: string;
58
+ timestamp?: number;
59
+ address?: string;
60
+ data?: Record<string, unknown>;
61
+ }
62
+ export declare function assembleServiceBasics(serviceId: string, raw: ServiceRawData, wipVerified?: boolean): ServiceBasics;
63
+ export declare function assembleWorkflowAnalysis(nodes: MachineNodeRaw[], isPublished: boolean, isPaused: boolean): WorkflowAnalysis;
64
+ export declare function assembleFundSafety(raw: ServiceRawData, orderAmount: bigint): FundSafety;
65
+ export declare function assembleTrustSignals(service: ServiceRawData, reviews: ReviewRaw[], trustScore: {
66
+ score: number;
67
+ level: string;
68
+ }, arbitrationOwner?: string, serviceOwner?: string): TrustSignals;
69
+ export declare function assembleMerchantBehavior(events: EventRaw[], orderHistory?: Array<{
70
+ status: string;
71
+ has_dispute: boolean;
72
+ is_repeat: boolean;
73
+ }>): MerchantBehavior;
74
+ export declare function assembleMarketContext(similarServices: Array<{
75
+ price: bigint;
76
+ }>, currentPrice: bigint): MarketContext;
77
+ export interface PuzzleRawData {
78
+ service: ServiceRawData;
79
+ machine_nodes?: MachineNodeRaw[];
80
+ machine_published?: boolean;
81
+ machine_paused?: boolean;
82
+ reviews?: ReviewRaw[];
83
+ events?: EventRaw[];
84
+ similar_services?: Array<{
85
+ price: bigint;
86
+ }>;
87
+ order_amount?: bigint;
88
+ trust_score?: {
89
+ score: number;
90
+ level: string;
91
+ };
92
+ arbitration_owner?: string;
93
+ service_owner?: string;
94
+ wip_verified?: boolean;
95
+ order_history?: Array<{
96
+ status: string;
97
+ has_dispute: boolean;
98
+ is_repeat: boolean;
99
+ }>;
100
+ }
101
+ export declare function assembleInfoPuzzle(serviceId: string, raw: PuzzleRawData, depth?: PuzzleDepth): InfoPuzzle;
102
+ export { CUSTOMER_INTELLIGENCE_VERSION };