@wowok/agent-mcp 2.3.13 → 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.
- 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/industry-risks.d.ts +36 -0
- package/dist/customer/industry-risks.js +424 -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 +67 -0
- package/dist/customer/user-preferences.js +451 -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 +77 -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/harness/checkpoint.d.ts +8 -0
- package/dist/harness/checkpoint.js +129 -0
- package/dist/harness/index.d.ts +33 -0
- package/dist/harness/index.js +75 -0
- package/dist/harness/plan.d.ts +18 -0
- package/dist/harness/plan.js +252 -0
- package/dist/harness/recover.d.ts +17 -0
- package/dist/harness/recover.js +139 -0
- package/dist/harness/types.d.ts +137 -0
- package/dist/harness/types.js +1 -0
- package/dist/harness/verify.d.ts +42 -0
- package/dist/harness/verify.js +237 -0
- package/dist/index.js +667 -201
- package/dist/knowledge/acquisition-flywheel.d.ts +50 -0
- package/dist/knowledge/acquisition-flywheel.js +183 -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/index.d.ts +64 -0
- package/dist/knowledge/index.js +66 -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 +49 -0
- package/dist/knowledge/industry-registry.js +167 -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 +171 -0
- package/dist/knowledge/tool-constraints.d.ts +30 -0
- package/dist/knowledge/tool-constraints.js +185 -0
- package/dist/knowledge/trust-metrics.d.ts +37 -0
- package/dist/knowledge/trust-metrics.js +138 -0
- package/dist/loop-engineering/aggregate.d.ts +50 -0
- package/dist/loop-engineering/aggregate.js +132 -0
- package/dist/loop-engineering/diagnose.d.ts +22 -0
- package/dist/loop-engineering/diagnose.js +273 -0
- package/dist/loop-engineering/improve.d.ts +26 -0
- package/dist/loop-engineering/improve.js +229 -0
- package/dist/loop-engineering/index.d.ts +4 -0
- package/dist/loop-engineering/index.js +4 -0
- package/dist/loop-engineering/pipeline.d.ts +17 -0
- package/dist/loop-engineering/pipeline.js +56 -0
- package/dist/mode-market/index.d.ts +3 -0
- package/dist/mode-market/index.js +3 -0
- package/dist/mode-market/registry.d.ts +53 -0
- package/dist/mode-market/registry.js +124 -0
- package/dist/mode-market/review.d.ts +27 -0
- package/dist/mode-market/review.js +214 -0
- package/dist/mode-market/submission.d.ts +25 -0
- package/dist/mode-market/submission.js +85 -0
- 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 +15 -0
- package/dist/safety/confirm-gate.js +44 -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 +55 -40
- package/dist/schema/call/arbitration.d.ts +201 -186
- package/dist/schema/call/base.d.ts +2104 -24
- package/dist/schema/call/base.js +168 -22
- package/dist/schema/call/bridge-handler.js +36 -18
- package/dist/schema/call/bridge.d.ts +777 -120
- package/dist/schema/call/bridge.js +13 -2
- package/dist/schema/call/contact.d.ts +15 -0
- package/dist/schema/call/demand.d.ts +69 -54
- package/dist/schema/call/guard.d.ts +125 -80
- package/dist/schema/call/handler.d.ts +5 -1
- package/dist/schema/call/handler.js +108 -3
- package/dist/schema/call/index.d.ts +1 -0
- package/dist/schema/call/index.js +1 -0
- package/dist/schema/call/machine.d.ts +830 -800
- package/dist/schema/call/order.d.ts +27 -12
- package/dist/schema/call/payment.d.ts +15 -0
- package/dist/schema/call/permission.d.ts +15 -0
- package/dist/schema/call/personal.d.ts +15 -0
- package/dist/schema/call/progress.d.ts +21 -6
- package/dist/schema/call/proof.d.ts +42 -12
- package/dist/schema/call/proof.js +3 -3
- package/dist/schema/call/repository.d.ts +91 -76
- package/dist/schema/call/reward.d.ts +51 -36
- package/dist/schema/call/semantic.d.ts +24 -0
- package/dist/schema/call/semantic.js +981 -0
- package/dist/schema/call/service.d.ts +444 -429
- package/dist/schema/call/treasury.d.ts +219 -204
- package/dist/schema/common/index.js +3 -3
- package/dist/schema/local/index.d.ts +341 -74
- package/dist/schema/local/index.js +44 -7
- package/dist/schema/messenger/index.d.ts +1034 -92
- package/dist/schema/messenger/index.js +18 -0
- package/dist/schema/operations.d.ts +2634 -1817
- package/dist/schema/operations.js +16 -5
- package/dist/schema/query/index.d.ts +2293 -2289
- package/dist/schema/query/index.js +34 -28
- package/dist/schemas/account_operation.output.json +28 -16
- package/dist/schemas/account_operation.schema.json +2 -2
- package/dist/schemas/bridge_operation.output.json +520 -0
- package/dist/schemas/bridge_operation.schema.json +15 -0
- package/dist/schemas/guard2file.schema.json +15 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +26 -0
- package/dist/schemas/local_info_operation.schema.json +1 -1
- package/dist/schemas/local_mark_operation.output.json +27 -1
- package/dist/schemas/local_mark_operation.schema.json +4 -4
- package/dist/schemas/machineNode2file.schema.json +15 -0
- package/dist/schemas/messenger_operation.output.json +549 -0
- package/dist/schemas/messenger_operation.schema.json +21 -0
- package/dist/schemas/onchain_events.output.json +3 -0
- package/dist/schemas/onchain_operations.output.json +814 -37
- package/dist/schemas/onchain_operations.schema.json +117 -40
- package/dist/schemas/onchain_operations_allocation.schema.json +26 -9
- package/dist/schemas/onchain_operations_arbitration.schema.json +26 -9
- package/dist/schemas/onchain_operations_contact.schema.json +26 -9
- package/dist/schemas/onchain_operations_demand.schema.json +26 -9
- package/dist/schemas/onchain_operations_gen_passport.schema.json +51 -17
- package/dist/schemas/onchain_operations_guard.schema.json +26 -9
- package/dist/schemas/onchain_operations_machine.schema.json +92 -32
- package/dist/schemas/onchain_operations_order.schema.json +26 -9
- package/dist/schemas/onchain_operations_payment.schema.json +26 -9
- package/dist/schemas/onchain_operations_permission.schema.json +26 -9
- package/dist/schemas/onchain_operations_personal.schema.json +26 -9
- package/dist/schemas/onchain_operations_progress.schema.json +26 -9
- package/dist/schemas/onchain_operations_repository.schema.json +26 -9
- package/dist/schemas/onchain_operations_reward.schema.json +26 -9
- package/dist/schemas/onchain_operations_service.schema.json +26 -9
- package/dist/schemas/onchain_operations_treasury.schema.json +26 -9
- package/dist/schemas/onchain_table_data.output.json +224 -69
- package/dist/schemas/onchain_table_data.schema.json +2 -2
- package/dist/schemas/query_toolkit.schema.json +5 -1
- package/dist/telemetry/index.d.ts +19 -0
- package/dist/telemetry/index.js +112 -0
- package/dist/telemetry/redact.d.ts +2 -0
- package/dist/telemetry/redact.js +23 -0
- package/dist/telemetry/storage.d.ts +8 -0
- package/dist/telemetry/storage.js +80 -0
- package/package.json +6 -3
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
|
|
2
|
+
const DEFAULT_THRESHOLDS = {
|
|
3
|
+
progress_stall_hours: 0,
|
|
4
|
+
compensation_drop_ratio: 0.3,
|
|
5
|
+
compensation_coverage_min: 1.0,
|
|
6
|
+
messenger_timeout_hours: 24,
|
|
7
|
+
review_window_closing_days: 3,
|
|
8
|
+
arb_window_closing_days: 3,
|
|
9
|
+
};
|
|
10
|
+
export function monitorOrder(ctx) {
|
|
11
|
+
const alerts = [];
|
|
12
|
+
const t = { ...DEFAULT_THRESHOLDS, ...(ctx.thresholds ?? {}) };
|
|
13
|
+
const cur = ctx.current;
|
|
14
|
+
if (cur.completed) {
|
|
15
|
+
alerts.push(...detectPostCompletionAlerts(cur, t));
|
|
16
|
+
return sortAlerts(alerts);
|
|
17
|
+
}
|
|
18
|
+
if (cur.refunded) {
|
|
19
|
+
alerts.push({
|
|
20
|
+
id: "refund_received",
|
|
21
|
+
category: "refund_received",
|
|
22
|
+
severity: "info",
|
|
23
|
+
title: "退款已到账",
|
|
24
|
+
message: `订单 ${cur.order_id} 已退款到账`,
|
|
25
|
+
timestamp: cur.now,
|
|
26
|
+
order_id: cur.order_id,
|
|
27
|
+
service_id: cur.service_id,
|
|
28
|
+
});
|
|
29
|
+
return sortAlerts(alerts);
|
|
30
|
+
}
|
|
31
|
+
alerts.push(...detectProgressStall(cur, ctx.previous, t));
|
|
32
|
+
alerts.push(...detectCompensationChange(cur, ctx.previous, t));
|
|
33
|
+
alerts.push(...detectMessengerTimeout(cur, t));
|
|
34
|
+
if (cur.pending_user_action) {
|
|
35
|
+
alerts.push({
|
|
36
|
+
id: "user_action_required",
|
|
37
|
+
category: "user_action_required",
|
|
38
|
+
severity: "info",
|
|
39
|
+
title: "等待用户操作",
|
|
40
|
+
message: `订单 ${cur.order_id} 已推进到节点 ${cur.current_node ?? "未知"},需要您操作才能继续`,
|
|
41
|
+
action: "查看 Machine 节点要求并提交对应 Guard submission",
|
|
42
|
+
timestamp: cur.now,
|
|
43
|
+
order_id: cur.order_id,
|
|
44
|
+
service_id: cur.service_id,
|
|
45
|
+
node: cur.current_node,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return sortAlerts(alerts);
|
|
49
|
+
}
|
|
50
|
+
function detectProgressStall(cur, prev, t) {
|
|
51
|
+
const alerts = [];
|
|
52
|
+
if (!cur.current_node)
|
|
53
|
+
return alerts;
|
|
54
|
+
const stallSince = cur.last_progress_at ?? cur.created_at;
|
|
55
|
+
const stallMs = cur.now - stallSince;
|
|
56
|
+
const stallHours = stallMs / 3_600_000;
|
|
57
|
+
const expected = cur.expected_progress_hours ?? 24;
|
|
58
|
+
const threshold = t.progress_stall_hours > 0 ? t.progress_stall_hours : expected * 2;
|
|
59
|
+
if (stallHours > threshold) {
|
|
60
|
+
const severity = stallHours > threshold * 2 ? "critical" : "warning";
|
|
61
|
+
alerts.push({
|
|
62
|
+
id: "progress_stall",
|
|
63
|
+
category: "progress_stall",
|
|
64
|
+
severity,
|
|
65
|
+
title: severity === "critical" ? "订单严重停滞" : "订单推进停滞",
|
|
66
|
+
message: `订单已停留在节点 ${cur.current_node} 超过 ${Math.round(stallHours)} 小时(预期 ${expected} 小时)`,
|
|
67
|
+
action: severity === "critical"
|
|
68
|
+
? "建议立即通过 Messenger 联系商家;若商家持续无响应,可考虑发起仲裁"
|
|
69
|
+
: "建议通过 Messenger 联系商家询问进度",
|
|
70
|
+
timestamp: cur.now,
|
|
71
|
+
order_id: cur.order_id,
|
|
72
|
+
service_id: cur.service_id,
|
|
73
|
+
node: cur.current_node,
|
|
74
|
+
metric: {
|
|
75
|
+
label: "停滞时长",
|
|
76
|
+
value: Math.round(stallHours),
|
|
77
|
+
threshold: Math.round(threshold),
|
|
78
|
+
unit: "小时",
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (prev && prev.previous_node === cur.current_node) {
|
|
83
|
+
const sincePrev = cur.now - prev.snapshot_at;
|
|
84
|
+
const sincePrevHours = sincePrev / 3_600_000;
|
|
85
|
+
if (sincePrevHours > expected) {
|
|
86
|
+
alerts.push({
|
|
87
|
+
id: "node_unchanged",
|
|
88
|
+
category: "progress_stall",
|
|
89
|
+
severity: "warning",
|
|
90
|
+
title: "节点未变化",
|
|
91
|
+
message: `自上次检查以来(${Math.round(sincePrevHours)} 小时),订单仍停留在 ${cur.current_node}`,
|
|
92
|
+
action: "确认是否为预期行为;如非预期,联系商家",
|
|
93
|
+
timestamp: cur.now,
|
|
94
|
+
order_id: cur.order_id,
|
|
95
|
+
service_id: cur.service_id,
|
|
96
|
+
node: cur.current_node,
|
|
97
|
+
metric: {
|
|
98
|
+
label: "节点停留时长",
|
|
99
|
+
value: Math.round(sincePrevHours),
|
|
100
|
+
threshold: Math.round(expected),
|
|
101
|
+
unit: "小时",
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return alerts;
|
|
107
|
+
}
|
|
108
|
+
function detectCompensationChange(cur, prev, t) {
|
|
109
|
+
const alerts = [];
|
|
110
|
+
if (cur.compensation_balance === undefined)
|
|
111
|
+
return alerts;
|
|
112
|
+
if (cur.order_amount !== undefined && cur.order_amount > 0n) {
|
|
113
|
+
const ratio = Number((cur.compensation_balance * 100n) / cur.order_amount) / 100;
|
|
114
|
+
if (ratio < t.compensation_coverage_min) {
|
|
115
|
+
const severity = ratio < 0.5 ? "critical" : "warning";
|
|
116
|
+
alerts.push({
|
|
117
|
+
id: "compensation_insufficient",
|
|
118
|
+
category: "compensation_insufficient",
|
|
119
|
+
severity,
|
|
120
|
+
title: "赔偿金覆盖率不足",
|
|
121
|
+
message: `商家赔偿金仅覆盖订单金额的 ${Math.round(ratio * 100)}%(要求 ${Math.round(t.compensation_coverage_min * 100)}%)`,
|
|
122
|
+
action: "下单前要求商家补充赔偿金,或通过 Messenger 协商提高覆盖率",
|
|
123
|
+
timestamp: cur.now,
|
|
124
|
+
order_id: cur.order_id,
|
|
125
|
+
service_id: cur.service_id,
|
|
126
|
+
metric: {
|
|
127
|
+
label: "赔偿金覆盖率",
|
|
128
|
+
value: Math.round(ratio * 100),
|
|
129
|
+
threshold: Math.round(t.compensation_coverage_min * 100),
|
|
130
|
+
unit: "%",
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (prev && prev.previous_compensation_balance !== undefined) {
|
|
136
|
+
const prevBal = prev.previous_compensation_balance;
|
|
137
|
+
if (prevBal > 0n && cur.compensation_balance < prevBal) {
|
|
138
|
+
const dropRatio = Number((prevBal - cur.compensation_balance) * 100n / prevBal) / 100;
|
|
139
|
+
if (dropRatio >= t.compensation_drop_ratio) {
|
|
140
|
+
const severity = dropRatio >= 0.5 ? "critical" : "warning";
|
|
141
|
+
alerts.push({
|
|
142
|
+
id: "compensation_drop",
|
|
143
|
+
category: "compensation_drop",
|
|
144
|
+
severity,
|
|
145
|
+
title: "赔偿金余额显著下降",
|
|
146
|
+
message: `商家赔偿金从 ${prevBal} 下降到 ${cur.compensation_balance}(下降 ${Math.round(dropRatio * 100)}%)`,
|
|
147
|
+
action: "立即询问商家原因;若持续下降,可能表明商家正在处理其他订单的赔付,存在风险",
|
|
148
|
+
timestamp: cur.now,
|
|
149
|
+
order_id: cur.order_id,
|
|
150
|
+
service_id: cur.service_id,
|
|
151
|
+
metric: {
|
|
152
|
+
label: "赔偿金下降比例",
|
|
153
|
+
value: Math.round(dropRatio * 100),
|
|
154
|
+
threshold: Math.round(t.compensation_drop_ratio * 100),
|
|
155
|
+
unit: "%",
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return alerts;
|
|
162
|
+
}
|
|
163
|
+
function detectMessengerTimeout(cur, t) {
|
|
164
|
+
const alerts = [];
|
|
165
|
+
if (cur.has_messenger === false) {
|
|
166
|
+
alerts.push({
|
|
167
|
+
id: "no_messenger_channel",
|
|
168
|
+
category: "messenger_timeout",
|
|
169
|
+
severity: "info",
|
|
170
|
+
title: "商家无 Messenger 通道",
|
|
171
|
+
message: "商家未配置 Messenger,无法在线协商或售后",
|
|
172
|
+
action: "下单前确认其他联系方式;建议要求商家配置 Messenger",
|
|
173
|
+
timestamp: cur.now,
|
|
174
|
+
order_id: cur.order_id,
|
|
175
|
+
service_id: cur.service_id,
|
|
176
|
+
});
|
|
177
|
+
return alerts;
|
|
178
|
+
}
|
|
179
|
+
if (cur.last_user_message_at && !cur.last_merchant_reply_at) {
|
|
180
|
+
const unansweredMs = cur.now - cur.last_user_message_at;
|
|
181
|
+
const unansweredHours = unansweredMs / 3_600_000;
|
|
182
|
+
if (unansweredHours > t.messenger_timeout_hours) {
|
|
183
|
+
const severity = unansweredHours > t.messenger_timeout_hours * 2 ? "critical" : "warning";
|
|
184
|
+
alerts.push({
|
|
185
|
+
id: "messenger_unanswered",
|
|
186
|
+
category: "messenger_timeout",
|
|
187
|
+
severity,
|
|
188
|
+
title: "商家 Messenger 未回复",
|
|
189
|
+
message: `商家已 ${Math.round(unansweredHours)} 小时未回复您的 Messenger 消息`,
|
|
190
|
+
action: cur.has_arbitration
|
|
191
|
+
? "可考虑发起仲裁申请(仲裁窗口有限)"
|
|
192
|
+
: "商家未配置仲裁,建议通过其他联系方式催促;若无回应,资金可能冻结",
|
|
193
|
+
timestamp: cur.now,
|
|
194
|
+
order_id: cur.order_id,
|
|
195
|
+
service_id: cur.service_id,
|
|
196
|
+
metric: {
|
|
197
|
+
label: "未回复时长",
|
|
198
|
+
value: Math.round(unansweredHours),
|
|
199
|
+
threshold: Math.round(t.messenger_timeout_hours),
|
|
200
|
+
unit: "小时",
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (cur.last_merchant_reply_at && cur.last_user_message_at &&
|
|
206
|
+
cur.last_user_message_at > cur.last_merchant_reply_at) {
|
|
207
|
+
const unansweredMs = cur.now - cur.last_user_message_at;
|
|
208
|
+
const unansweredHours = unansweredMs / 3_600_000;
|
|
209
|
+
if (unansweredHours > t.messenger_timeout_hours) {
|
|
210
|
+
alerts.push({
|
|
211
|
+
id: "messenger_re_unanswered",
|
|
212
|
+
category: "messenger_timeout",
|
|
213
|
+
severity: "warning",
|
|
214
|
+
title: "商家再次未回复",
|
|
215
|
+
message: `您 ${Math.round(unansweredHours)} 小时前的消息商家尚未回复`,
|
|
216
|
+
action: "可发送催促消息;若商家持续无响应,考虑仲裁",
|
|
217
|
+
timestamp: cur.now,
|
|
218
|
+
order_id: cur.order_id,
|
|
219
|
+
service_id: cur.service_id,
|
|
220
|
+
metric: {
|
|
221
|
+
label: "再次未回复时长",
|
|
222
|
+
value: Math.round(unansweredHours),
|
|
223
|
+
threshold: Math.round(t.messenger_timeout_hours),
|
|
224
|
+
unit: "小时",
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return alerts;
|
|
230
|
+
}
|
|
231
|
+
function detectPostCompletionAlerts(cur, t) {
|
|
232
|
+
const alerts = [];
|
|
233
|
+
if (cur.review_window_days !== undefined && cur.review_window_days > 0) {
|
|
234
|
+
if (cur.review_window_days <= t.review_window_closing_days) {
|
|
235
|
+
alerts.push({
|
|
236
|
+
id: "review_window_closing",
|
|
237
|
+
category: "review_window",
|
|
238
|
+
severity: "info",
|
|
239
|
+
title: "评价窗口即将关闭",
|
|
240
|
+
message: `评价窗口将在 ${cur.review_window_days} 天后关闭`,
|
|
241
|
+
action: "尽快提交评价(如有证据可一并提交)",
|
|
242
|
+
timestamp: cur.now,
|
|
243
|
+
order_id: cur.order_id,
|
|
244
|
+
service_id: cur.service_id,
|
|
245
|
+
metric: {
|
|
246
|
+
label: "剩余天数",
|
|
247
|
+
value: cur.review_window_days,
|
|
248
|
+
threshold: t.review_window_closing_days,
|
|
249
|
+
unit: "天",
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
alerts.push({
|
|
255
|
+
id: "review_reminder",
|
|
256
|
+
category: "review_window",
|
|
257
|
+
severity: "info",
|
|
258
|
+
title: "订单已完成",
|
|
259
|
+
message: `订单已完成,评价窗口剩余 ${cur.review_window_days} 天`,
|
|
260
|
+
action: "可提交评价帮助其他用户决策",
|
|
261
|
+
timestamp: cur.now,
|
|
262
|
+
order_id: cur.order_id,
|
|
263
|
+
service_id: cur.service_id,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (cur.arb_window_days !== undefined && cur.arb_window_days > 0) {
|
|
268
|
+
if (cur.arb_window_days <= t.arb_window_closing_days) {
|
|
269
|
+
alerts.push({
|
|
270
|
+
id: "arb_window_closing",
|
|
271
|
+
category: "arb_window",
|
|
272
|
+
severity: "warning",
|
|
273
|
+
title: "仲裁申请窗口即将关闭",
|
|
274
|
+
message: `仲裁申请窗口将在 ${cur.arb_window_days} 天后关闭`,
|
|
275
|
+
action: "若有未解决争议,立即发起仲裁申请",
|
|
276
|
+
timestamp: cur.now,
|
|
277
|
+
order_id: cur.order_id,
|
|
278
|
+
service_id: cur.service_id,
|
|
279
|
+
metric: {
|
|
280
|
+
label: "剩余天数",
|
|
281
|
+
value: cur.arb_window_days,
|
|
282
|
+
threshold: t.arb_window_closing_days,
|
|
283
|
+
unit: "天",
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return alerts;
|
|
289
|
+
}
|
|
290
|
+
export function sortAlerts(alerts) {
|
|
291
|
+
const rank = { critical: 3, warning: 2, info: 1 };
|
|
292
|
+
return [...alerts].sort((a, b) => rank[b.severity] - rank[a.severity]);
|
|
293
|
+
}
|
|
294
|
+
export function getCriticalAlerts(alerts) {
|
|
295
|
+
return alerts.filter((a) => a.severity === "critical");
|
|
296
|
+
}
|
|
297
|
+
export function getActionableAlerts(alerts) {
|
|
298
|
+
return alerts.filter((a) => a.severity === "critical" || a.severity === "warning");
|
|
299
|
+
}
|
|
300
|
+
export function summarizeAlerts(alerts) {
|
|
301
|
+
if (alerts.length === 0)
|
|
302
|
+
return "✅ 暂无告警,订单状态正常";
|
|
303
|
+
const critical = alerts.filter((a) => a.severity === "critical");
|
|
304
|
+
const warning = alerts.filter((a) => a.severity === "warning");
|
|
305
|
+
const info = alerts.filter((a) => a.severity === "info");
|
|
306
|
+
const parts = [];
|
|
307
|
+
if (critical.length > 0)
|
|
308
|
+
parts.push(`🔴 ${critical.length} 条严重告警`);
|
|
309
|
+
if (warning.length > 0)
|
|
310
|
+
parts.push(`🟠 ${warning.length} 条警告`);
|
|
311
|
+
if (info.length > 0)
|
|
312
|
+
parts.push(`ℹ️ ${info.length} 条提示`);
|
|
313
|
+
return parts.join(",");
|
|
314
|
+
}
|
|
315
|
+
export function isBlockingAlert(alert) {
|
|
316
|
+
return alert.severity === "critical";
|
|
317
|
+
}
|
|
318
|
+
export function alertsToReminders(alerts) {
|
|
319
|
+
return alerts.map((a) => ({
|
|
320
|
+
id: a.id,
|
|
321
|
+
priority: a.severity === "critical" ? "required"
|
|
322
|
+
: a.severity === "warning" ? "recommended"
|
|
323
|
+
: "info",
|
|
324
|
+
message: `${a.title}:${a.message}`,
|
|
325
|
+
}));
|
|
326
|
+
}
|
|
327
|
+
export { CUSTOMER_INTELLIGENCE_VERSION };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { InfoPuzzle, UserPreferences, GameStrategy, GameScenario } from "./types.js";
|
|
2
|
+
import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
|
|
3
|
+
export interface StrategyContext {
|
|
4
|
+
puzzle: InfoPuzzle;
|
|
5
|
+
prefs?: UserPreferences;
|
|
6
|
+
merchant_signals?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface StrategyRecommendation {
|
|
9
|
+
scenario: GameScenario;
|
|
10
|
+
strategy: GameStrategy;
|
|
11
|
+
confidence: number;
|
|
12
|
+
fallback?: string;
|
|
13
|
+
rationale: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function recommendStrategy(scenario: GameScenario, ctx: StrategyContext): StrategyRecommendation;
|
|
16
|
+
export declare function detectScenarios(puzzle: InfoPuzzle): GameScenario[];
|
|
17
|
+
export declare function flowMigrationStrategy(puzzle: InfoPuzzle): {
|
|
18
|
+
strategy: string;
|
|
19
|
+
risk: "low" | "medium" | "high";
|
|
20
|
+
advice: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function repeatGameStrategy(puzzle: InfoPuzzle, history: {
|
|
23
|
+
completed: number;
|
|
24
|
+
disputes: number;
|
|
25
|
+
refunds: number;
|
|
26
|
+
}): {
|
|
27
|
+
strategy: string;
|
|
28
|
+
is_long_term_partner: boolean;
|
|
29
|
+
advice: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function rightsProtectionStrategy(puzzle: InfoPuzzle, prefs?: UserPreferences): {
|
|
32
|
+
required_rights: string[];
|
|
33
|
+
negotiable_rights: string[];
|
|
34
|
+
red_lines: string[];
|
|
35
|
+
};
|
|
36
|
+
export { CUSTOMER_INTELLIGENCE_VERSION };
|