@wowok/agent-mcp 2.3.14 → 2.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/runtime.d.ts +26 -0
- package/dist/config/runtime.js +217 -0
- package/dist/customer/index.d.ts +9 -0
- package/dist/customer/index.js +9 -0
- package/dist/customer/industry-risks.d.ts +40 -0
- package/dist/customer/industry-risks.js +438 -0
- package/dist/customer/info-puzzle.d.ts +102 -0
- package/dist/customer/info-puzzle.js +312 -0
- package/dist/customer/order-monitor.d.ts +75 -0
- package/dist/customer/order-monitor.js +327 -0
- package/dist/customer/order-strategy.d.ts +36 -0
- package/dist/customer/order-strategy.js +373 -0
- package/dist/customer/post-purchase.d.ts +42 -0
- package/dist/customer/post-purchase.js +350 -0
- package/dist/customer/reminder-system.d.ts +42 -0
- package/dist/customer/reminder-system.js +295 -0
- package/dist/customer/risk-assessment.d.ts +8 -0
- package/dist/customer/risk-assessment.js +337 -0
- package/dist/customer/types.d.ts +193 -0
- package/dist/customer/types.js +13 -0
- package/dist/customer/user-preferences.d.ts +70 -0
- package/dist/customer/user-preferences.js +460 -0
- package/dist/experience/experience-reuse.d.ts +10 -0
- package/dist/experience/experience-reuse.js +103 -0
- package/dist/experience/index.d.ts +6 -0
- package/dist/experience/index.js +5 -0
- package/dist/experience/intent-distill.d.ts +3 -0
- package/dist/experience/intent-distill.js +83 -0
- package/dist/experience/realtime-feedback.d.ts +5 -0
- package/dist/experience/realtime-feedback.js +94 -0
- package/dist/experience/types.d.ts +50 -0
- package/dist/experience/types.js +1 -0
- package/dist/experience/user-profile.d.ts +25 -0
- package/dist/experience/user-profile.js +171 -0
- package/dist/index.js +842 -371
- package/dist/knowledge/acquisition-flywheel.d.ts +53 -0
- package/dist/knowledge/acquisition-flywheel.js +192 -0
- package/dist/knowledge/arbitration-trust.d.ts +24 -0
- package/dist/knowledge/arbitration-trust.js +117 -0
- package/dist/knowledge/audit-rules.d.ts +28 -0
- package/dist/knowledge/audit-rules.js +141 -0
- package/dist/knowledge/demand-matching.d.ts +29 -0
- package/dist/knowledge/demand-matching.js +132 -0
- package/dist/knowledge/dynamic-pricing.d.ts +31 -0
- package/dist/knowledge/dynamic-pricing.js +87 -0
- package/dist/knowledge/flywheel-loop.d.ts +87 -0
- package/dist/knowledge/flywheel-loop.js +378 -0
- package/dist/knowledge/glossary.d.ts +18 -0
- package/dist/knowledge/glossary.js +209 -0
- package/dist/knowledge/guard-ledger.d.ts +19 -0
- package/dist/knowledge/guard-ledger.js +219 -0
- package/dist/knowledge/guard-puzzle.d.ts +93 -0
- package/dist/knowledge/guard-puzzle.js +278 -0
- package/dist/knowledge/guard-risk.d.ts +60 -0
- package/dist/knowledge/guard-risk.js +474 -0
- package/dist/knowledge/guard-translation.d.ts +46 -0
- package/dist/knowledge/guard-translation.js +487 -0
- package/dist/knowledge/index.d.ts +77 -0
- package/dist/knowledge/index.js +79 -0
- package/dist/knowledge/industry-evolution.d.ts +82 -0
- package/dist/knowledge/industry-evolution.js +323 -0
- package/dist/knowledge/industry-generalizer.d.ts +17 -0
- package/dist/knowledge/industry-generalizer.js +381 -0
- package/dist/knowledge/industry-registry.d.ts +48 -0
- package/dist/knowledge/industry-registry.js +187 -0
- package/dist/knowledge/intent-metrics.d.ts +42 -0
- package/dist/knowledge/intent-metrics.js +566 -0
- package/dist/knowledge/process-model.d.ts +24 -0
- package/dist/knowledge/process-model.js +160 -0
- package/dist/knowledge/reputation-rules.d.ts +42 -0
- package/dist/knowledge/reputation-rules.js +99 -0
- package/dist/knowledge/reward-templates.d.ts +25 -0
- package/dist/knowledge/reward-templates.js +125 -0
- package/dist/knowledge/safety-rules.d.ts +36 -0
- package/dist/knowledge/safety-rules.js +232 -0
- package/dist/knowledge/tool-constraints.d.ts +30 -0
- package/dist/knowledge/tool-constraints.js +175 -0
- package/dist/knowledge/trust-metrics.d.ts +37 -0
- package/dist/knowledge/trust-metrics.js +138 -0
- package/dist/loop-engineering/diagnose.d.ts +3 -2
- package/dist/loop-engineering/diagnose.js +94 -0
- package/dist/loop-engineering/improve.d.ts +1 -1
- package/dist/loop-engineering/improve.js +52 -1
- package/dist/project/graph.d.ts +71 -0
- package/dist/project/graph.js +314 -0
- package/dist/project/index.d.ts +62 -0
- package/dist/project/index.js +167 -0
- package/dist/project/namespace.d.ts +62 -0
- package/dist/project/namespace.js +181 -0
- package/dist/project/query.d.ts +40 -0
- package/dist/project/query.js +110 -0
- package/dist/safety/confirm-gate.d.ts +17 -0
- package/dist/safety/confirm-gate.js +88 -0
- package/dist/safety/index.d.ts +3 -0
- package/dist/safety/index.js +3 -0
- package/dist/safety/preview.d.ts +2 -0
- package/dist/safety/preview.js +36 -0
- package/dist/schema/call/allocation.d.ts +39 -14
- package/dist/schema/call/arbitration.d.ts +187 -162
- package/dist/schema/call/base.d.ts +1971 -87
- package/dist/schema/call/base.js +135 -3
- package/dist/schema/call/bridge-handler.js +15 -2
- package/dist/schema/call/bridge.d.ts +1478 -53
- package/dist/schema/call/bridge.js +50 -2
- package/dist/schema/call/contact.d.ts +25 -0
- package/dist/schema/call/demand.d.ts +79 -54
- package/dist/schema/call/guard.d.ts +125 -50
- package/dist/schema/call/handler.d.ts +3 -0
- package/dist/schema/call/handler.js +60 -14
- package/dist/schema/call/machine.d.ts +988 -938
- package/dist/schema/call/order.d.ts +25 -0
- package/dist/schema/call/payment.d.ts +25 -0
- package/dist/schema/call/permission.d.ts +244 -219
- package/dist/schema/call/personal.d.ts +25 -0
- package/dist/schema/call/progress.d.ts +25 -0
- package/dist/schema/call/proof.d.ts +62 -12
- package/dist/schema/call/proof.js +3 -3
- package/dist/schema/call/repository.d.ts +101 -76
- package/dist/schema/call/reward.d.ts +55 -30
- package/dist/schema/call/semantic.d.ts +10 -2
- package/dist/schema/call/semantic.js +616 -11
- package/dist/schema/call/service.d.ts +442 -417
- package/dist/schema/call/treasury.d.ts +25 -0
- package/dist/schema/common/index.js +3 -3
- package/dist/schema/config/index.d.ts +18 -0
- package/dist/schema/config/index.js +17 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/local/index.d.ts +237 -81
- package/dist/schema/local/index.js +42 -6
- package/dist/schema/messenger/index.d.ts +1018 -79
- package/dist/schema/messenger/index.js +26 -17
- package/dist/schema/operations.d.ts +3192 -1746
- package/dist/schema/operations.js +93 -98
- package/dist/schema/project/index.d.ts +21 -0
- package/dist/schema/project/index.js +32 -0
- package/dist/schema/query/index.d.ts +2762 -1856
- package/dist/schema/query/index.js +38 -35
- package/dist/schema/schema-query/index.d.ts +33 -0
- package/dist/schema/schema-query/index.js +36 -0
- package/dist/schema/schema-version.d.ts +25 -0
- package/dist/schema/schema-version.js +76 -0
- package/dist/schema/trust/index.d.ts +407 -0
- package/dist/schema/trust/index.js +113 -0
- package/dist/schemas/account_operation.output.json +25 -16
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.output.json +744 -0
- package/dist/schemas/bridge_operation.schema.json +82 -8
- package/dist/schemas/config_operation.output.json +18 -0
- package/dist/schemas/config_operation.schema.json +34 -0
- package/dist/schemas/guard-node-schema.json +82 -0
- package/dist/schemas/guard2file.schema.json +23 -0
- package/dist/schemas/index.json +19 -1
- package/dist/schemas/local_info_operation.output.json +23 -0
- package/dist/schemas/local_info_operation.schema.json +1 -1
- package/dist/schemas/local_mark_operation.output.json +24 -1
- package/dist/schemas/local_mark_operation.schema.json +4 -4
- package/dist/schemas/machineNode2file.schema.json +23 -0
- package/dist/schemas/messenger_operation.output.json +752 -0
- package/dist/schemas/onchain_events.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +627 -18
- package/dist/schemas/onchain_operations.schema.json +115 -39
- package/dist/schemas/onchain_operations_allocation.schema.json +23 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +23 -0
- package/dist/schemas/onchain_operations_contact.schema.json +23 -0
- package/dist/schemas/onchain_operations_demand.schema.json +23 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +46 -0
- package/dist/schemas/onchain_operations_guard.schema.json +26 -16
- package/dist/schemas/onchain_operations_machine.schema.json +89 -23
- package/dist/schemas/onchain_operations_order.schema.json +23 -0
- package/dist/schemas/onchain_operations_payment.schema.json +23 -0
- package/dist/schemas/onchain_operations_permission.schema.json +23 -0
- package/dist/schemas/onchain_operations_personal.schema.json +23 -0
- package/dist/schemas/onchain_operations_progress.schema.json +23 -0
- package/dist/schemas/onchain_operations_repository.schema.json +23 -0
- package/dist/schemas/onchain_operations_reward.schema.json +23 -0
- package/dist/schemas/onchain_operations_service.schema.json +23 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +23 -0
- package/dist/schemas/onchain_table_data.output.json +939 -69
- package/dist/schemas/onchain_table_data.schema.json +2 -2
- package/dist/schemas/project_operation.output.json +18 -0
- package/dist/schemas/project_operation.schema.json +42 -0
- package/dist/schemas/query_toolkit.schema.json +360 -368
- package/dist/schemas/schema_query.schema.json +6 -3
- package/dist/schemas/trust_score.output.json +327 -0
- package/dist/schemas/trust_score.schema.json +46 -0
- package/package.json +2 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export const PERMISSION_TYPES = [
|
|
2
|
+
{
|
|
3
|
+
name: "Permission",
|
|
4
|
+
scope: "organization",
|
|
5
|
+
definedOn: "Permission Object (standalone on-chain object, referenced by service/machine/etc.)",
|
|
6
|
+
controls: "Who can modify the bound object's settings, publish it, manage its funds, etc.",
|
|
7
|
+
grantedBy: "The object's creator (owner) or anyone the creator delegates to",
|
|
8
|
+
example: "A shop owner creates a Permission allowing only their staff to modify the Service's price.",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "NamedOperator",
|
|
12
|
+
scope: "order",
|
|
13
|
+
definedOn: "Per-order (specified in the order creation/modification by the service)",
|
|
14
|
+
controls: "Who can operate on a specific order: advance progress, settle, refund, etc.",
|
|
15
|
+
grantedBy: "The service (via its order_allocators or explicit named operators)",
|
|
16
|
+
example: "A delivery service assigns Alice as the NamedOperator for order #123 — only Alice can mark it delivered.",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "OrderHolder",
|
|
20
|
+
scope: "order_holder",
|
|
21
|
+
definedOn: "Per-order (the '' empty string address = the order's current holder)",
|
|
22
|
+
controls: "Who currently holds the order and can perform holder-specific actions (accept, reject, pay)",
|
|
23
|
+
grantedBy: "Implicitly assigned when an order is created or transferred",
|
|
24
|
+
example: "Bob places an order — he becomes the OrderHolder. He can accept delivery or request arbitration.",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
export const GAME_ELEMENTS = [
|
|
28
|
+
{
|
|
29
|
+
id: 1, type: "player", name: "商户 vs 客户",
|
|
30
|
+
description: "博弈的基本参与方:提供服务的商户和购买服务的客户。",
|
|
31
|
+
wowokApplication: "Service 创建者(商户)和 Order 创建者(客户)。",
|
|
32
|
+
onChainMechanism: "Service + Order 对象,各自有独立的 on-chain address。",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 2, type: "player", name: "仲裁员",
|
|
36
|
+
description: "第三方仲裁员参与争议解决博弈。",
|
|
37
|
+
wowokApplication: "Arb 对象的 NamedOperator,由 Service 指定。",
|
|
38
|
+
onChainMechanism: "Arbitration 对象 + NamedOperator 权限。",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 3, type: "strategy", name: "合作 vs 欺骗",
|
|
42
|
+
description: "商户可以选择诚实履约(合作)或欺诈(欺骗)。客户可以选择信任或拒绝。",
|
|
43
|
+
wowokApplication: "商户发货 vs 不发货;客户付款 vs 拒付。",
|
|
44
|
+
onChainMechanism: "Progress 节点推进 + 链上状态不可篡改。",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 4, type: "payoff", name: "履约收益 vs 欺诈收益",
|
|
48
|
+
description: "诚实履约获得持续收入 + 声誉;欺诈获得一次性收益但损失声誉和补偿金。",
|
|
49
|
+
wowokApplication: "compensation_fund 作为欺诈的经济惩罚;repeat business 作为合作的长期收益。",
|
|
50
|
+
onChainMechanism: "Service.compensation_fund + Treasury 锁定资金。",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 5, type: "utility", name: "声誉效用",
|
|
54
|
+
description: "商户的总效用 = 即期收益 + 声誉折现的未来收益 - 惩罚预期。",
|
|
55
|
+
wowokApplication: "声誉分高的商户获得更多订单(Demand 匹配优先)。",
|
|
56
|
+
onChainMechanism: "ReviewRepository (链上公开评价) + Demand 匹配引擎。",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 6, type: "equilibrium", name: "纳什均衡:双方合作",
|
|
60
|
+
description: "当惩罚足够大、声誉足够重要时,双方合作的策略组合成为纳什均衡。",
|
|
61
|
+
wowokApplication: "compensation_fund 足够大 + 链上声誉不可篡改 → 合作成为最优策略。",
|
|
62
|
+
onChainMechanism: "Guard 验证 compensation_fund 金额 + ReviewRepository 公开。",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 7, type: "information", name: "不完全信息",
|
|
66
|
+
description: "客户不完全了解商户的服务质量;商户不完全了解客户的支付能力。",
|
|
67
|
+
wowokApplication: "Service.description + Guard 验证作为信号;客户钱包余额链上可查。",
|
|
68
|
+
onChainMechanism: "Guard + Personal 对象 + 链上交易历史。",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 8, type: "sequence", name: "序贯博弈",
|
|
72
|
+
description: "客户先下单付款,商户后履约 — 这是典型的序贯博弈。",
|
|
73
|
+
wowokApplication: "Order 创建 → Progress 推进 → Acceptance/Arbitration。",
|
|
74
|
+
onChainMechanism: "Machine 节点序列 + Progress 状态机。",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 9, type: "repetition", name: "重复博弈",
|
|
78
|
+
description: "商户和客户可能多次交易,重复博弈使得合作策略更优。",
|
|
79
|
+
wowokApplication: "客户的复购 + Demand 匹配优先推荐高声誉商户。",
|
|
80
|
+
onChainMechanism: "ReviewRepository 累积评价 + Demand 匹配引擎。",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 10, type: "commitment", name: "补偿金承诺",
|
|
84
|
+
description: "商户通过锁定 compensation_fund 做出可信承诺,降低客户的风险感知。",
|
|
85
|
+
wowokApplication: "Service.compensation_fund 锁定资金,欺诈时客户可索赔。",
|
|
86
|
+
onChainMechanism: "Treasury 对象 + Guard 验证金额 + 提取规则。",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 11, type: "punishment", name: "补偿金惩罚",
|
|
90
|
+
description: "商户欺诈时,补偿金被划给客户,构成经济惩罚。",
|
|
91
|
+
wowokApplication: "Arbitration 判决 → compensation_fund 提取 → 客户获得赔偿。",
|
|
92
|
+
onChainMechanism: "Arbitration verdict + Treasury 提取规则。",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 12, type: "reward", name: "Reward 营销激励",
|
|
96
|
+
description: "商户通过 Reward 对象发放奖励,激励客户行为(首单、裂变、忠诚度)。",
|
|
97
|
+
wowokApplication: "Reward 对象 + Guard 验证领取条件(如:完成首单)。",
|
|
98
|
+
onChainMechanism: "Reward 对象 + Guard claim 条件 + Allocation 分发。",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 13, type: "reputation", name: "链上公开声誉",
|
|
102
|
+
description: "所有交易和评价记录在链上,形成不可篡改的声誉系统。",
|
|
103
|
+
wowokApplication: "ReviewRepository 存储 like/dislike/评价标签,链上可检测。",
|
|
104
|
+
onChainMechanism: "Repository 对象 + Guard 防刷 + 地址为 key 的评价记录。",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 14, type: "signaling", name: "质量信号",
|
|
108
|
+
description: "商户通过 Guard 验证、compensation_fund 金额、Machine 透明度发送质量信号。",
|
|
109
|
+
wowokApplication: "buy_guard 验证 → 信号;compensation_fund 金额 → 信号;Machine 公开 → 信号。",
|
|
110
|
+
onChainMechanism: "Guard + Treasury + Machine 对象的链上公开数据。",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 15, type: "screening", name: "客户筛选",
|
|
114
|
+
description: "商户通过 Guard 筛选客户(如:验证身份、信用分、钱包余额)。",
|
|
115
|
+
wowokApplication: "Service.buy_guard 验证客户资格。",
|
|
116
|
+
onChainMechanism: "Guard 对象 + gen_passport 验证凭证。",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 16, type: "bargaining", name: "价格议价",
|
|
120
|
+
description: "客户和商户可以通过 Messenger 议价,最终价格通过 Demand 提交。",
|
|
121
|
+
wowokApplication: "Messenger 加密通信 → Demand 提交带 reward 的需求。",
|
|
122
|
+
onChainMechanism: "Contact + Messenger + Demand 对象。",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 17, type: "auction", name: "Demand 竞标",
|
|
126
|
+
description: "多个服务商可以竞争同一个 Demand,形成竞标机制。",
|
|
127
|
+
wowokApplication: "Demand 发布需求 → 多个 Service 提交方案 → 客户选择。",
|
|
128
|
+
onChainMechanism: "Demand 对象 + order 创建 + Progress 推进。",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 18, type: "mechanism", name: "机制设计",
|
|
132
|
+
description: "WoWok 的整体架构就是机制设计:通过链上规则激励合作、惩罚欺诈。",
|
|
133
|
+
wowokApplication: "compensation_fund + Arbitration + ReviewRepository 组合形成信任机制。",
|
|
134
|
+
onChainMechanism: "Move 合约层面的对象组合 + Guard 验证 + 不可篡改性。",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 19, type: "constraint", name: "资金约束",
|
|
138
|
+
description: "compensation_fund 和 Reward 资金锁定构成经济约束,限制商户的欺诈动机。",
|
|
139
|
+
wowokApplication: "资金锁定 > 欺诈收益 → 合作是理性选择。",
|
|
140
|
+
onChainMechanism: "Treasury + Allocation 资金锁定。",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: 20, type: "cooperation", name: "供应链协作",
|
|
144
|
+
description: "多个商户通过 Machine 组合形成供应链,合作完成复杂订单(子订单)。",
|
|
145
|
+
wowokApplication: "Service 的 order_allocators 支持多供应商分配;Machine 节点间 forward 组合。",
|
|
146
|
+
onChainMechanism: "Allocation + Machine Forward + Progress 跨对象组合。",
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
const PERMISSION_INDEX = new Map(PERMISSION_TYPES.map((p) => [p.name, p]));
|
|
150
|
+
const GAME_ELEMENT_INDEX = new Map(GAME_ELEMENTS.map((g) => [g.id, g]));
|
|
151
|
+
export function getPermissionType(name) {
|
|
152
|
+
return PERMISSION_INDEX.get(name);
|
|
153
|
+
}
|
|
154
|
+
export function getGameElement(id) {
|
|
155
|
+
return GAME_ELEMENT_INDEX.get(id);
|
|
156
|
+
}
|
|
157
|
+
export function getGameElementsByType(type) {
|
|
158
|
+
return GAME_ELEMENTS.filter((g) => g.type === type);
|
|
159
|
+
}
|
|
160
|
+
export const PROCESS_MODEL_VERSION = 1;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface Review {
|
|
2
|
+
reviewer: string;
|
|
3
|
+
rating: "like" | "dislike";
|
|
4
|
+
tags?: string[];
|
|
5
|
+
comment?: string;
|
|
6
|
+
orderRef?: string;
|
|
7
|
+
timestamp?: number;
|
|
8
|
+
verified: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ReviewStats {
|
|
11
|
+
total: number;
|
|
12
|
+
likes: number;
|
|
13
|
+
dislikes: number;
|
|
14
|
+
likeRate: number;
|
|
15
|
+
verifiedCount: number;
|
|
16
|
+
topTags: Array<{
|
|
17
|
+
tag: string;
|
|
18
|
+
count: number;
|
|
19
|
+
}>;
|
|
20
|
+
recentTrend: "improving" | "declining" | "stable";
|
|
21
|
+
}
|
|
22
|
+
export interface ReviewRepositorySetup {
|
|
23
|
+
repositoryName: string;
|
|
24
|
+
guardName: string;
|
|
25
|
+
guardRules: string;
|
|
26
|
+
setupSteps: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare const REPUTATION_RULES_VERSION = 1;
|
|
29
|
+
export declare function buildReviewRepositorySetup(serviceName: string): ReviewRepositorySetup;
|
|
30
|
+
export declare function computeReviewStats(reviews: Review[]): ReviewStats;
|
|
31
|
+
export declare function isVerifiedReview(review: Review, orderHistory: Array<{
|
|
32
|
+
id: string;
|
|
33
|
+
status: string;
|
|
34
|
+
}>): boolean;
|
|
35
|
+
export declare function filterVerifiedReviews(reviews: Review[], orderHistory: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
status: string;
|
|
38
|
+
}>): Review[];
|
|
39
|
+
export declare function detectReviewManipulation(reviews: Review[]): {
|
|
40
|
+
suspicious: boolean;
|
|
41
|
+
reasons: string[];
|
|
42
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const REPUTATION_RULES_VERSION = 1;
|
|
2
|
+
export function buildReviewRepositorySetup(serviceName) {
|
|
3
|
+
return {
|
|
4
|
+
repositoryName: `${serviceName}_reviews`,
|
|
5
|
+
guardName: `${serviceName}_review_guard`,
|
|
6
|
+
guardRules: "验证提交者有该 Service 的已完成订单(query order history == 已完成)—— 防刷评",
|
|
7
|
+
setupSteps: [
|
|
8
|
+
`1. 创建 Guard: name='${serviceName}_review_guard', 规则验证购买者身份`,
|
|
9
|
+
`2. 创建 Repository: name='${serviceName}_reviews', attach Guard`,
|
|
10
|
+
`3. 将 Repository 关联到 Service: onchain_operations service modify`,
|
|
11
|
+
`4. 用户提交评价时: onchain_operations repository write(Guard 自动验证)`,
|
|
12
|
+
`5. 查询评价: onchain_table_data repository query`,
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function computeReviewStats(reviews) {
|
|
17
|
+
if (reviews.length === 0) {
|
|
18
|
+
return {
|
|
19
|
+
total: 0,
|
|
20
|
+
likes: 0,
|
|
21
|
+
dislikes: 0,
|
|
22
|
+
likeRate: 0,
|
|
23
|
+
verifiedCount: 0,
|
|
24
|
+
topTags: [],
|
|
25
|
+
recentTrend: "stable",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const likes = reviews.filter((r) => r.rating === "like").length;
|
|
29
|
+
const dislikes = reviews.filter((r) => r.rating === "dislike").length;
|
|
30
|
+
const verifiedCount = reviews.filter((r) => r.verified).length;
|
|
31
|
+
const tagCounts = new Map();
|
|
32
|
+
for (const r of reviews) {
|
|
33
|
+
if (r.tags) {
|
|
34
|
+
for (const t of r.tags) {
|
|
35
|
+
tagCounts.set(t, (tagCounts.get(t) ?? 0) + 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const topTags = Array.from(tagCounts.entries())
|
|
40
|
+
.sort((a, b) => b[1] - a[1])
|
|
41
|
+
.slice(0, 5)
|
|
42
|
+
.map(([tag, count]) => ({ tag, count }));
|
|
43
|
+
const sorted = [...reviews].sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0));
|
|
44
|
+
const midPoint = Math.floor(sorted.length / 2);
|
|
45
|
+
const firstHalf = sorted.slice(0, midPoint);
|
|
46
|
+
const secondHalf = sorted.slice(midPoint);
|
|
47
|
+
const firstLikeRate = firstHalf.length > 0 ? firstHalf.filter((r) => r.rating === "like").length / firstHalf.length : 0.5;
|
|
48
|
+
const secondLikeRate = secondHalf.length > 0 ? secondHalf.filter((r) => r.rating === "like").length / secondHalf.length : 0.5;
|
|
49
|
+
let recentTrend = "stable";
|
|
50
|
+
if (secondLikeRate > firstLikeRate + 0.15)
|
|
51
|
+
recentTrend = "improving";
|
|
52
|
+
else if (secondLikeRate < firstLikeRate - 0.15)
|
|
53
|
+
recentTrend = "declining";
|
|
54
|
+
return {
|
|
55
|
+
total: reviews.length,
|
|
56
|
+
likes,
|
|
57
|
+
dislikes,
|
|
58
|
+
likeRate: likes / reviews.length,
|
|
59
|
+
verifiedCount,
|
|
60
|
+
topTags,
|
|
61
|
+
recentTrend,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function isVerifiedReview(review, orderHistory) {
|
|
65
|
+
if (!review.orderRef)
|
|
66
|
+
return false;
|
|
67
|
+
const order = orderHistory.find((o) => o.id === review.orderRef);
|
|
68
|
+
return order?.status === "completed" || order?.status === "success";
|
|
69
|
+
}
|
|
70
|
+
export function filterVerifiedReviews(reviews, orderHistory) {
|
|
71
|
+
return reviews.map((r) => ({
|
|
72
|
+
...r,
|
|
73
|
+
verified: isVerifiedReview(r, orderHistory),
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
export function detectReviewManipulation(reviews) {
|
|
77
|
+
const reasons = [];
|
|
78
|
+
const reviewerCounts = new Map();
|
|
79
|
+
for (const r of reviews) {
|
|
80
|
+
reviewerCounts.set(r.reviewer, (reviewerCounts.get(r.reviewer) ?? 0) + 1);
|
|
81
|
+
}
|
|
82
|
+
const duplicates = Array.from(reviewerCounts.entries()).filter(([, count]) => count > 1);
|
|
83
|
+
if (duplicates.length > 0) {
|
|
84
|
+
reasons.push(`${duplicates.length} 个地址提交了多次评价`);
|
|
85
|
+
}
|
|
86
|
+
const allLikes = reviews.every((r) => r.rating === "like");
|
|
87
|
+
const noneVerified = reviews.every((r) => !r.verified);
|
|
88
|
+
if (allLikes && reviews.length > 5 && noneVerified) {
|
|
89
|
+
reasons.push("全部好评但无带凭证评价,可能存在刷评");
|
|
90
|
+
}
|
|
91
|
+
if (reviews.length > 10) {
|
|
92
|
+
const sorted = [...reviews].sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0));
|
|
93
|
+
const timeSpan = (sorted[sorted.length - 1].timestamp ?? 0) - (sorted[0].timestamp ?? 0);
|
|
94
|
+
if (timeSpan > 0 && timeSpan < 3600 * 1000) {
|
|
95
|
+
reasons.push(`${reviews.length} 条评价在 1 小时内提交,时间异常集中`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { suspicious: reasons.length > 0, reasons };
|
|
99
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type RewardTemplateType = "first_order" | "referral" | "loyalty" | "flash_sale" | "bulk_discount" | "milestone" | "cashback";
|
|
2
|
+
export interface RewardTemplate {
|
|
3
|
+
type: RewardTemplateType;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
guardCondition: string;
|
|
7
|
+
amountRange: {
|
|
8
|
+
min: string;
|
|
9
|
+
max: string;
|
|
10
|
+
};
|
|
11
|
+
allocationStrategy: "fixed" | "proportional" | "tiered";
|
|
12
|
+
parameters: Array<{
|
|
13
|
+
name: string;
|
|
14
|
+
type: "string" | "number" | "address";
|
|
15
|
+
description: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
example: string;
|
|
19
|
+
relevantGuardOps: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare const REWARD_TEMPLATES: RewardTemplate[];
|
|
22
|
+
export declare function getRewardTemplate(type: string): RewardTemplate | undefined;
|
|
23
|
+
export declare function listRewardTemplates(): RewardTemplate[];
|
|
24
|
+
export declare function suggestRewardTemplate(intent: string): RewardTemplate | undefined;
|
|
25
|
+
export declare const REWARD_TEMPLATES_VERSION = 1;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export const REWARD_TEMPLATES = [
|
|
2
|
+
{
|
|
3
|
+
type: "first_order",
|
|
4
|
+
name: "首单奖励",
|
|
5
|
+
description: "新客户首次下单后获得奖励,降低尝试门槛,促进转化。",
|
|
6
|
+
guardCondition: "Guard 验证: order_address 的 holder == 当前 claim 者, 且 order.service == 本 Service, 且 order 是该 holder 的第一笔订单 (通过 Repository 查询历史)",
|
|
7
|
+
amountRange: { min: "0.1WOW", max: "5WOW" },
|
|
8
|
+
allocationStrategy: "fixed",
|
|
9
|
+
parameters: [
|
|
10
|
+
{ name: "amount", type: "string", description: "奖励金额 (如 '1WOW')", required: true },
|
|
11
|
+
{ name: "budget", type: "string", description: "总预算 (如 '100WOW')", required: true },
|
|
12
|
+
],
|
|
13
|
+
example: "新客户下单购买摄影服务,首单获得 1 WOW 返还,降低首次尝试成本。",
|
|
14
|
+
relevantGuardOps: ["query", "repository_read"],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "referral",
|
|
18
|
+
name: "裂变推荐奖励",
|
|
19
|
+
description: "老客户推荐新客户下单后,双方各获得奖励,形成口碑传播飞轮。",
|
|
20
|
+
guardCondition: "Guard 验证: 推荐人地址在 Repository 评价表中标记为 'referred_by', 且被推荐人的订单已完成 (Progress 到达终态)",
|
|
21
|
+
amountRange: { min: "0.5WOW", max: "10WOW" },
|
|
22
|
+
allocationStrategy: "proportional",
|
|
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 },
|
|
27
|
+
],
|
|
28
|
+
example: "Alice 推荐 Bob 购买服务,Bob 完成首单后 Alice 得 2 WOW、Bob 得 1 WOW。",
|
|
29
|
+
relevantGuardOps: ["query", "repository_read", "repository_write"],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "loyalty",
|
|
33
|
+
name: "忠诚度阶梯奖励",
|
|
34
|
+
description: "客户累计消费达到阶梯后解锁更高奖励,提升复购率和客单价。",
|
|
35
|
+
guardCondition: "Guard 验证: 通过 Repository 查询该地址历史订单数 >= N, N 为当前阶梯阈值",
|
|
36
|
+
amountRange: { min: "1WOW", max: "50WOW" },
|
|
37
|
+
allocationStrategy: "tiered",
|
|
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 },
|
|
45
|
+
],
|
|
46
|
+
example: "客户累计 3 单得 1 WOW,10 单得 5 WOW,30 单得 20 WOW,激励持续消费。",
|
|
47
|
+
relevantGuardOps: ["query", "repository_read"],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "flash_sale",
|
|
51
|
+
name: "限时闪购",
|
|
52
|
+
description: "在限定时间窗口内提供折扣或额外奖励,制造紧迫感促进即时转化。",
|
|
53
|
+
guardCondition: "Guard 验证: 当前区块时间在 [start_time, end_time] 范围内 (Guard 时间条件)",
|
|
54
|
+
amountRange: { min: "0.1WOW", max: "20WOW" },
|
|
55
|
+
allocationStrategy: "fixed",
|
|
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 },
|
|
61
|
+
],
|
|
62
|
+
example: "周末限时 48 小时闪购,下单客户额外获得 2 WOW 返还,前 100 名有效。",
|
|
63
|
+
relevantGuardOps: ["query", "time_condition"],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "cashback",
|
|
67
|
+
name: "消费返现",
|
|
68
|
+
description: "客户完成订单后按消费比例返现,提升复购意愿。",
|
|
69
|
+
guardCondition: "Guard 验证: order 已到达终态 (Progress completed), 且 order.service == 本 Service",
|
|
70
|
+
amountRange: { min: "0.1WOW", max: "100WOW" },
|
|
71
|
+
allocationStrategy: "proportional",
|
|
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 },
|
|
76
|
+
],
|
|
77
|
+
example: "客户消费 10 WOW,按 10% 比例返现 1 WOW,下次消费可抵扣。",
|
|
78
|
+
relevantGuardOps: ["query"],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "milestone",
|
|
82
|
+
name: "里程碑奖励",
|
|
83
|
+
description: "Service 达到特定里程碑(如 100 单、1000 客户)时给早期支持者发放额外奖励。",
|
|
84
|
+
guardCondition: "Guard 验证: Repository 查询 Service 累计订单数 >= milestone_threshold, 且 claim 者为早期客户 (order_index < milestone)",
|
|
85
|
+
amountRange: { min: "1WOW", max: "100WOW" },
|
|
86
|
+
allocationStrategy: "fixed",
|
|
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 },
|
|
91
|
+
],
|
|
92
|
+
example: "Service 达到 100 单里程碑,前 50 名客户每人获得 5 WOW 额外奖励。",
|
|
93
|
+
relevantGuardOps: ["query", "repository_read"],
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const TEMPLATE_INDEX = new Map(REWARD_TEMPLATES.map((t) => [t.type, t]));
|
|
97
|
+
export function getRewardTemplate(type) {
|
|
98
|
+
return TEMPLATE_INDEX.get(type);
|
|
99
|
+
}
|
|
100
|
+
export function listRewardTemplates() {
|
|
101
|
+
return REWARD_TEMPLATES;
|
|
102
|
+
}
|
|
103
|
+
export function suggestRewardTemplate(intent) {
|
|
104
|
+
const lower = intent.toLowerCase();
|
|
105
|
+
if (lower.includes("首单") || lower.includes("new") || lower.includes("first")) {
|
|
106
|
+
return getRewardTemplate("first_order");
|
|
107
|
+
}
|
|
108
|
+
if (lower.includes("推荐") || lower.includes("裂变") || lower.includes("referral")) {
|
|
109
|
+
return getRewardTemplate("referral");
|
|
110
|
+
}
|
|
111
|
+
if (lower.includes("复购") || lower.includes("忠诚") || lower.includes("loyalty")) {
|
|
112
|
+
return getRewardTemplate("loyalty");
|
|
113
|
+
}
|
|
114
|
+
if (lower.includes("限时") || lower.includes("闪购") || lower.includes("flash")) {
|
|
115
|
+
return getRewardTemplate("flash_sale");
|
|
116
|
+
}
|
|
117
|
+
if (lower.includes("返现") || lower.includes("cashback")) {
|
|
118
|
+
return getRewardTemplate("cashback");
|
|
119
|
+
}
|
|
120
|
+
if (lower.includes("里程碑") || lower.includes("milestone")) {
|
|
121
|
+
return getRewardTemplate("milestone");
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
export const REWARD_TEMPLATES_VERSION = 1;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type ConfirmLevel = "none" | "standard" | "amount" | "publish" | "irreversible";
|
|
2
|
+
export interface OperationPreview {
|
|
3
|
+
level: ConfirmLevel;
|
|
4
|
+
operation: string;
|
|
5
|
+
object?: string;
|
|
6
|
+
network?: string;
|
|
7
|
+
account?: string;
|
|
8
|
+
amount?: {
|
|
9
|
+
value: string;
|
|
10
|
+
token: string;
|
|
11
|
+
human_readable: string;
|
|
12
|
+
recipient?: string;
|
|
13
|
+
};
|
|
14
|
+
immutable_after?: string[];
|
|
15
|
+
warnings?: string[];
|
|
16
|
+
irreversible?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ConfirmationRule {
|
|
19
|
+
id: string;
|
|
20
|
+
when: (operation_type: string, data: any, env: any) => boolean;
|
|
21
|
+
level: ConfirmLevel;
|
|
22
|
+
preview: (operation_type: string, data: any, env: any) => OperationPreview;
|
|
23
|
+
bypass_on_explicit_intent?: string[];
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_VALUE_WARNINGS: {
|
|
26
|
+
readonly defaultAccount: "Using default account (env.account=\"\")";
|
|
27
|
+
readonly mainnet: "Operating on mainnet — irreversible";
|
|
28
|
+
readonly replaceExistName: "replaceExistName=true will unbind the existing name (breaking refs)";
|
|
29
|
+
readonly defaultToken: "Using default token 0x2::wow::WOW";
|
|
30
|
+
};
|
|
31
|
+
export declare const DEFAULT_AMOUNT_THRESHOLD: bigint;
|
|
32
|
+
export declare function getAmountThreshold(): bigint;
|
|
33
|
+
export declare function formatAmount(value: string | bigint, precision?: bigint): string;
|
|
34
|
+
export declare function collectDefaultWarnings(env: any, data: any): string[];
|
|
35
|
+
export declare const CONFIRMATION_RULES: ConfirmationRule[];
|
|
36
|
+
export declare const SAFETY_RULES_VERSION = 1;
|