@wowok/agent-mcp 2.7.1 â 2.7.2
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.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,328 +1 @@
|
|
|
1
|
-
import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
|
|
2
|
-
import { formatAmountText } from "../knowledge/fund-layer.js";
|
|
3
|
-
const DEFAULT_THRESHOLDS = {
|
|
4
|
-
progress_stall_hours: 0,
|
|
5
|
-
compensation_drop_ratio: 0.3,
|
|
6
|
-
compensation_coverage_min: 1.0,
|
|
7
|
-
messenger_timeout_hours: 24,
|
|
8
|
-
review_window_closing_days: 3,
|
|
9
|
-
arb_window_closing_days: 3,
|
|
10
|
-
};
|
|
11
|
-
export function monitorOrder(ctx) {
|
|
12
|
-
const alerts = [];
|
|
13
|
-
const t = { ...DEFAULT_THRESHOLDS, ...(ctx.thresholds ?? {}) };
|
|
14
|
-
const cur = ctx.current;
|
|
15
|
-
if (cur.completed) {
|
|
16
|
-
alerts.push(...detectPostCompletionAlerts(cur, t));
|
|
17
|
-
return sortAlerts(alerts);
|
|
18
|
-
}
|
|
19
|
-
if (cur.refunded) {
|
|
20
|
-
alerts.push({
|
|
21
|
-
id: "refund_received",
|
|
22
|
-
category: "refund_received",
|
|
23
|
-
severity: "info",
|
|
24
|
-
title: "Refund received",
|
|
25
|
-
message: `Order ${cur.order_id} refund has been received`,
|
|
26
|
-
timestamp: cur.now,
|
|
27
|
-
order_id: cur.order_id,
|
|
28
|
-
service_id: cur.service_id,
|
|
29
|
-
});
|
|
30
|
-
return sortAlerts(alerts);
|
|
31
|
-
}
|
|
32
|
-
alerts.push(...detectProgressStall(cur, ctx.previous, t));
|
|
33
|
-
alerts.push(...detectCompensationChange(cur, ctx.previous, t));
|
|
34
|
-
alerts.push(...detectMessengerTimeout(cur, t));
|
|
35
|
-
if (cur.pending_user_action) {
|
|
36
|
-
alerts.push({
|
|
37
|
-
id: "user_action_required",
|
|
38
|
-
category: "user_action_required",
|
|
39
|
-
severity: "info",
|
|
40
|
-
title: "Waiting for user action",
|
|
41
|
-
message: `Order ${cur.order_id} advanced to node ${cur.current_node ?? "unknown"}; your action is required to continue`,
|
|
42
|
-
action: "View the Machine node requirements and submit the corresponding Guard submission",
|
|
43
|
-
timestamp: cur.now,
|
|
44
|
-
order_id: cur.order_id,
|
|
45
|
-
service_id: cur.service_id,
|
|
46
|
-
node: cur.current_node,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return sortAlerts(alerts);
|
|
50
|
-
}
|
|
51
|
-
function detectProgressStall(cur, prev, t) {
|
|
52
|
-
const alerts = [];
|
|
53
|
-
if (!cur.current_node)
|
|
54
|
-
return alerts;
|
|
55
|
-
const stallSince = cur.last_progress_at ?? cur.created_at;
|
|
56
|
-
const stallMs = cur.now - stallSince;
|
|
57
|
-
const stallHours = stallMs / 3_600_000;
|
|
58
|
-
const expected = cur.expected_progress_hours ?? 24;
|
|
59
|
-
const threshold = t.progress_stall_hours > 0 ? t.progress_stall_hours : expected * 2;
|
|
60
|
-
if (stallHours > threshold) {
|
|
61
|
-
const severity = stallHours > threshold * 2 ? "critical" : "warning";
|
|
62
|
-
alerts.push({
|
|
63
|
-
id: "progress_stall",
|
|
64
|
-
category: "progress_stall",
|
|
65
|
-
severity,
|
|
66
|
-
title: severity === "critical" ? "Order severely stalled" : "Order progress stalled",
|
|
67
|
-
message: `Order has been stuck at node ${cur.current_node} for over ${Math.round(stallHours)} hours (expected ${expected} hours)`,
|
|
68
|
-
action: severity === "critical"
|
|
69
|
-
? "Recommend contacting the merchant immediately via Messenger; if the merchant remains unresponsive, consider initiating arbitration"
|
|
70
|
-
: "Recommend contacting the merchant via Messenger to ask about progress",
|
|
71
|
-
timestamp: cur.now,
|
|
72
|
-
order_id: cur.order_id,
|
|
73
|
-
service_id: cur.service_id,
|
|
74
|
-
node: cur.current_node,
|
|
75
|
-
metric: {
|
|
76
|
-
label: "Stall duration",
|
|
77
|
-
value: Math.round(stallHours),
|
|
78
|
-
threshold: Math.round(threshold),
|
|
79
|
-
unit: "hours",
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (prev && prev.previous_node === cur.current_node) {
|
|
84
|
-
const sincePrev = cur.now - prev.snapshot_at;
|
|
85
|
-
const sincePrevHours = sincePrev / 3_600_000;
|
|
86
|
-
if (sincePrevHours > expected) {
|
|
87
|
-
alerts.push({
|
|
88
|
-
id: "node_unchanged",
|
|
89
|
-
category: "progress_stall",
|
|
90
|
-
severity: "warning",
|
|
91
|
-
title: "Node unchanged",
|
|
92
|
-
message: `Since the last check (${Math.round(sincePrevHours)} hours), the order is still at ${cur.current_node}`,
|
|
93
|
-
action: "Confirm whether this is expected; if not, contact the merchant",
|
|
94
|
-
timestamp: cur.now,
|
|
95
|
-
order_id: cur.order_id,
|
|
96
|
-
service_id: cur.service_id,
|
|
97
|
-
node: cur.current_node,
|
|
98
|
-
metric: {
|
|
99
|
-
label: "Node stay duration",
|
|
100
|
-
value: Math.round(sincePrevHours),
|
|
101
|
-
threshold: Math.round(expected),
|
|
102
|
-
unit: "hours",
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return alerts;
|
|
108
|
-
}
|
|
109
|
-
function detectCompensationChange(cur, prev, t) {
|
|
110
|
-
const alerts = [];
|
|
111
|
-
if (cur.compensation_balance === undefined)
|
|
112
|
-
return alerts;
|
|
113
|
-
if (cur.order_amount !== undefined && cur.order_amount > 0n) {
|
|
114
|
-
const ratio = Number((cur.compensation_balance * 100n) / cur.order_amount) / 100;
|
|
115
|
-
if (ratio < t.compensation_coverage_min) {
|
|
116
|
-
const severity = ratio < 0.5 ? "critical" : "warning";
|
|
117
|
-
alerts.push({
|
|
118
|
-
id: "compensation_insufficient",
|
|
119
|
-
category: "compensation_insufficient",
|
|
120
|
-
severity,
|
|
121
|
-
title: "Compensation fund coverage insufficient",
|
|
122
|
-
message: `Merchant compensation fund covers only ${Math.round(ratio * 100)}% of the order amount (required ${Math.round(t.compensation_coverage_min * 100)}%): fund ${formatAmountText(cur.compensation_balance, cur.token?.decimals, cur.token?.symbol)} vs order ${formatAmountText(cur.order_amount, cur.token?.decimals, cur.token?.symbol)}`,
|
|
123
|
-
action: "Require the merchant to top up the compensation fund before ordering, or negotiate higher coverage via Messenger",
|
|
124
|
-
timestamp: cur.now,
|
|
125
|
-
order_id: cur.order_id,
|
|
126
|
-
service_id: cur.service_id,
|
|
127
|
-
metric: {
|
|
128
|
-
label: "Compensation coverage",
|
|
129
|
-
value: Math.round(ratio * 100),
|
|
130
|
-
threshold: Math.round(t.compensation_coverage_min * 100),
|
|
131
|
-
unit: "%",
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (prev && prev.previous_compensation_balance !== undefined) {
|
|
137
|
-
const prevBal = prev.previous_compensation_balance;
|
|
138
|
-
if (prevBal > 0n && cur.compensation_balance < prevBal) {
|
|
139
|
-
const dropRatio = Number((prevBal - cur.compensation_balance) * 100n / prevBal) / 100;
|
|
140
|
-
if (dropRatio >= t.compensation_drop_ratio) {
|
|
141
|
-
const severity = dropRatio >= 0.5 ? "critical" : "warning";
|
|
142
|
-
alerts.push({
|
|
143
|
-
id: "compensation_drop",
|
|
144
|
-
category: "compensation_drop",
|
|
145
|
-
severity,
|
|
146
|
-
title: "Compensation fund balance dropped significantly",
|
|
147
|
-
message: `Merchant compensation fund dropped from ${formatAmountText(prevBal, cur.token?.decimals, cur.token?.symbol)} to ${formatAmountText(cur.compensation_balance, cur.token?.decimals, cur.token?.symbol)} (down ${Math.round(dropRatio * 100)}%)`,
|
|
148
|
-
action: "Immediately ask the merchant for the reason; if it keeps dropping, the merchant may be processing payouts for other orders, which is a risk",
|
|
149
|
-
timestamp: cur.now,
|
|
150
|
-
order_id: cur.order_id,
|
|
151
|
-
service_id: cur.service_id,
|
|
152
|
-
metric: {
|
|
153
|
-
label: "Compensation drop ratio",
|
|
154
|
-
value: Math.round(dropRatio * 100),
|
|
155
|
-
threshold: Math.round(t.compensation_drop_ratio * 100),
|
|
156
|
-
unit: "%",
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return alerts;
|
|
163
|
-
}
|
|
164
|
-
function detectMessengerTimeout(cur, t) {
|
|
165
|
-
const alerts = [];
|
|
166
|
-
if (cur.has_messenger === false) {
|
|
167
|
-
alerts.push({
|
|
168
|
-
id: "no_messenger_channel",
|
|
169
|
-
category: "messenger_timeout",
|
|
170
|
-
severity: "info",
|
|
171
|
-
title: "Merchant has no Messenger channel",
|
|
172
|
-
message: "Merchant has not configured Messenger; no way to negotiate online or get post-sale support",
|
|
173
|
-
action: "Confirm other contact methods before ordering; recommend requiring the merchant to configure Messenger",
|
|
174
|
-
timestamp: cur.now,
|
|
175
|
-
order_id: cur.order_id,
|
|
176
|
-
service_id: cur.service_id,
|
|
177
|
-
});
|
|
178
|
-
return alerts;
|
|
179
|
-
}
|
|
180
|
-
if (cur.last_user_message_at && !cur.last_merchant_reply_at) {
|
|
181
|
-
const unansweredMs = cur.now - cur.last_user_message_at;
|
|
182
|
-
const unansweredHours = unansweredMs / 3_600_000;
|
|
183
|
-
if (unansweredHours > t.messenger_timeout_hours) {
|
|
184
|
-
const severity = unansweredHours > t.messenger_timeout_hours * 2 ? "critical" : "warning";
|
|
185
|
-
alerts.push({
|
|
186
|
-
id: "messenger_unanswered",
|
|
187
|
-
category: "messenger_timeout",
|
|
188
|
-
severity,
|
|
189
|
-
title: "Merchant Messenger no reply",
|
|
190
|
-
message: `Merchant has not replied to your Messenger message for ${Math.round(unansweredHours)} hours`,
|
|
191
|
-
action: cur.has_arbitration
|
|
192
|
-
? "Consider initiating an arbitration application (arbitration window is limited)"
|
|
193
|
-
: "Merchant has no arbitration configured; recommend urging via other contact methods; if there is no response, funds may be frozen",
|
|
194
|
-
timestamp: cur.now,
|
|
195
|
-
order_id: cur.order_id,
|
|
196
|
-
service_id: cur.service_id,
|
|
197
|
-
metric: {
|
|
198
|
-
label: "No-reply duration",
|
|
199
|
-
value: Math.round(unansweredHours),
|
|
200
|
-
threshold: Math.round(t.messenger_timeout_hours),
|
|
201
|
-
unit: "hours",
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (cur.last_merchant_reply_at && cur.last_user_message_at &&
|
|
207
|
-
cur.last_user_message_at > cur.last_merchant_reply_at) {
|
|
208
|
-
const unansweredMs = cur.now - cur.last_user_message_at;
|
|
209
|
-
const unansweredHours = unansweredMs / 3_600_000;
|
|
210
|
-
if (unansweredHours > t.messenger_timeout_hours) {
|
|
211
|
-
alerts.push({
|
|
212
|
-
id: "messenger_re_unanswered",
|
|
213
|
-
category: "messenger_timeout",
|
|
214
|
-
severity: "warning",
|
|
215
|
-
title: "Merchant did not reply again",
|
|
216
|
-
message: `The merchant has not replied to your message from ${Math.round(unansweredHours)} hours ago`,
|
|
217
|
-
action: "Send a follow-up message; if the merchant remains unresponsive, consider arbitration",
|
|
218
|
-
timestamp: cur.now,
|
|
219
|
-
order_id: cur.order_id,
|
|
220
|
-
service_id: cur.service_id,
|
|
221
|
-
metric: {
|
|
222
|
-
label: "Re-no-reply duration",
|
|
223
|
-
value: Math.round(unansweredHours),
|
|
224
|
-
threshold: Math.round(t.messenger_timeout_hours),
|
|
225
|
-
unit: "hours",
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return alerts;
|
|
231
|
-
}
|
|
232
|
-
function detectPostCompletionAlerts(cur, t) {
|
|
233
|
-
const alerts = [];
|
|
234
|
-
if (cur.review_window_days !== undefined && cur.review_window_days > 0) {
|
|
235
|
-
if (cur.review_window_days <= t.review_window_closing_days) {
|
|
236
|
-
alerts.push({
|
|
237
|
-
id: "review_window_closing",
|
|
238
|
-
category: "review_window",
|
|
239
|
-
severity: "info",
|
|
240
|
-
title: "Review window about to close",
|
|
241
|
-
message: `The review window will close in ${cur.review_window_days} day(s)`,
|
|
242
|
-
action: "Submit a review as soon as possible (evidence can be submitted together if available)",
|
|
243
|
-
timestamp: cur.now,
|
|
244
|
-
order_id: cur.order_id,
|
|
245
|
-
service_id: cur.service_id,
|
|
246
|
-
metric: {
|
|
247
|
-
label: "Remaining days",
|
|
248
|
-
value: cur.review_window_days,
|
|
249
|
-
threshold: t.review_window_closing_days,
|
|
250
|
-
unit: "days",
|
|
251
|
-
},
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
alerts.push({
|
|
256
|
-
id: "review_reminder",
|
|
257
|
-
category: "review_window",
|
|
258
|
-
severity: "info",
|
|
259
|
-
title: "Order completed",
|
|
260
|
-
message: `Order completed; review window has ${cur.review_window_days} day(s) remaining`,
|
|
261
|
-
action: "Submit a review to help other users decide",
|
|
262
|
-
timestamp: cur.now,
|
|
263
|
-
order_id: cur.order_id,
|
|
264
|
-
service_id: cur.service_id,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (cur.arb_window_days !== undefined && cur.arb_window_days > 0) {
|
|
269
|
-
if (cur.arb_window_days <= t.arb_window_closing_days) {
|
|
270
|
-
alerts.push({
|
|
271
|
-
id: "arb_window_closing",
|
|
272
|
-
category: "arb_window",
|
|
273
|
-
severity: "warning",
|
|
274
|
-
title: "Arbitration application window about to close",
|
|
275
|
-
message: `The arbitration application window will close in ${cur.arb_window_days} day(s)`,
|
|
276
|
-
action: "If there are unresolved disputes, initiate an arbitration application immediately",
|
|
277
|
-
timestamp: cur.now,
|
|
278
|
-
order_id: cur.order_id,
|
|
279
|
-
service_id: cur.service_id,
|
|
280
|
-
metric: {
|
|
281
|
-
label: "Remaining days",
|
|
282
|
-
value: cur.arb_window_days,
|
|
283
|
-
threshold: t.arb_window_closing_days,
|
|
284
|
-
unit: "days",
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return alerts;
|
|
290
|
-
}
|
|
291
|
-
export function sortAlerts(alerts) {
|
|
292
|
-
const rank = { critical: 3, warning: 2, info: 1 };
|
|
293
|
-
return [...alerts].sort((a, b) => rank[b.severity] - rank[a.severity]);
|
|
294
|
-
}
|
|
295
|
-
export function getCriticalAlerts(alerts) {
|
|
296
|
-
return alerts.filter((a) => a.severity === "critical");
|
|
297
|
-
}
|
|
298
|
-
export function getActionableAlerts(alerts) {
|
|
299
|
-
return alerts.filter((a) => a.severity === "critical" || a.severity === "warning");
|
|
300
|
-
}
|
|
301
|
-
export function summarizeAlerts(alerts) {
|
|
302
|
-
if (alerts.length === 0)
|
|
303
|
-
return "â
No alerts; order status is normal";
|
|
304
|
-
const critical = alerts.filter((a) => a.severity === "critical");
|
|
305
|
-
const warning = alerts.filter((a) => a.severity === "warning");
|
|
306
|
-
const info = alerts.filter((a) => a.severity === "info");
|
|
307
|
-
const parts = [];
|
|
308
|
-
if (critical.length > 0)
|
|
309
|
-
parts.push(`đ´ ${critical.length} critical alert(s)`);
|
|
310
|
-
if (warning.length > 0)
|
|
311
|
-
parts.push(`đ ${warning.length} warning(s)`);
|
|
312
|
-
if (info.length > 0)
|
|
313
|
-
parts.push(`âšī¸ ${info.length} info`);
|
|
314
|
-
return parts.join(", ");
|
|
315
|
-
}
|
|
316
|
-
export function isBlockingAlert(alert) {
|
|
317
|
-
return alert.severity === "critical";
|
|
318
|
-
}
|
|
319
|
-
export function alertsToReminders(alerts) {
|
|
320
|
-
return alerts.map((a) => ({
|
|
321
|
-
id: a.id,
|
|
322
|
-
priority: a.severity === "critical" ? "required"
|
|
323
|
-
: a.severity === "warning" ? "recommended"
|
|
324
|
-
: "info",
|
|
325
|
-
message: `${a.title}: ${a.message}`,
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
export { CUSTOMER_INTELLIGENCE_VERSION };
|
|
1
|
+
import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';import{formatAmountText}from'../knowledge/fund-layer.js';const DEFAULT_THRESHOLDS={'progress_stall_hours':0x0,'compensation_drop_ratio':0.3,'compensation_coverage_min':0x1,'messenger_timeout_hours':0x18,'review_window_closing_days':0x3,'arb_window_closing_days':0x3};export function monitorOrder(a){const b=[],c={...DEFAULT_THRESHOLDS,...a['thresholds']??{}},d=a['current'];if(d['completed'])return b['push'](...detectPostCompletionAlerts(d,c)),sortAlerts(b);if(d['refunded'])return b['push']({'id':'refund_received','category':'refund_received','severity':'info','title':'Refund\x20received','message':'Order\x20'+d['order_id']+'\x20refund\x20has\x20been\x20received','timestamp':d['now'],'order_id':d['order_id'],'service_id':d['service_id']}),sortAlerts(b);return b['push'](...detectProgressStall(d,a['previous'],c)),b['push'](...detectCompensationChange(d,a['previous'],c)),b['push'](...detectMessengerTimeout(d,c)),d['pending_user_action']&&b['push']({'id':'user_action_required','category':'user_action_required','severity':'info','title':'Waiting\x20for\x20user\x20action','message':'Order\x20'+d['order_id']+'\x20advanced\x20to\x20node\x20'+(d['current_node']??'unknown')+';\x20your\x20action\x20is\x20required\x20to\x20continue','action':'View\x20the\x20Machine\x20node\x20requirements\x20and\x20submit\x20the\x20corresponding\x20Guard\x20submission','timestamp':d['now'],'order_id':d['order_id'],'service_id':d['service_id'],'node':d['current_node']}),sortAlerts(b);}function detectProgressStall(a,b,c){const d=[];if(!a['current_node'])return d;const e=a['last_progress_at']??a['created_at'],f=a['now']-e,g=f/0x36ee80,h=a['expected_progress_hours']??0x18,i=c['progress_stall_hours']>0x0?c['progress_stall_hours']:h*0x2;if(g>i){const j=g>i*0x2?'critical':'warning';d['push']({'id':'progress_stall','category':'progress_stall','severity':j,'title':j==='critical'?'Order\x20severely\x20stalled':'Order\x20progress\x20stalled','message':'Order\x20has\x20been\x20stuck\x20at\x20node\x20'+a['current_node']+'\x20for\x20over\x20'+Math['round'](g)+'\x20hours\x20(expected\x20'+h+'\x20hours)','action':j==='critical'?'Recommend\x20contacting\x20the\x20merchant\x20immediately\x20via\x20Messenger;\x20if\x20the\x20merchant\x20remains\x20unresponsive,\x20consider\x20initiating\x20arbitration':'Recommend\x20contacting\x20the\x20merchant\x20via\x20Messenger\x20to\x20ask\x20about\x20progress','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'node':a['current_node'],'metric':{'label':'Stall\x20duration','value':Math['round'](g),'threshold':Math['round'](i),'unit':'hours'}});}if(b&&b['previous_node']===a['current_node']){const k=a['now']-b['snapshot_at'],l=k/0x36ee80;l>h&&d['push']({'id':'node_unchanged','category':'progress_stall','severity':'warning','title':'Node\x20unchanged','message':'Since\x20the\x20last\x20check\x20('+Math['round'](l)+'\x20hours),\x20the\x20order\x20is\x20still\x20at\x20'+a['current_node'],'action':'Confirm\x20whether\x20this\x20is\x20expected;\x20if\x20not,\x20contact\x20the\x20merchant','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'node':a['current_node'],'metric':{'label':'Node\x20stay\x20duration','value':Math['round'](l),'threshold':Math['round'](h),'unit':'hours'}});}return d;}function detectCompensationChange(a,b,c){const d=[];if(a['compensation_balance']===undefined)return d;if(a['order_amount']!==undefined&&a['order_amount']>0x0n){const e=Number(a['compensation_balance']*0x64n/a['order_amount'])/0x64;if(e<c['compensation_coverage_min']){const f=e<0.5?'critical':'warning';d['push']({'id':'compensation_insufficient','category':'compensation_insufficient','severity':f,'title':'Compensation\x20fund\x20coverage\x20insufficient','message':'Merchant\x20compensation\x20fund\x20covers\x20only\x20'+Math['round'](e*0x64)+'%\x20of\x20the\x20order\x20amount\x20(required\x20'+Math['round'](c['compensation_coverage_min']*0x64)+'%):\x20fund\x20'+formatAmountText(a['compensation_balance'],a['token']?.['decimals'],a['token']?.['symbol'])+'\x20vs\x20order\x20'+formatAmountText(a['order_amount'],a['token']?.['decimals'],a['token']?.['symbol']),'action':'Require\x20the\x20merchant\x20to\x20top\x20up\x20the\x20compensation\x20fund\x20before\x20ordering,\x20or\x20negotiate\x20higher\x20coverage\x20via\x20Messenger','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'metric':{'label':'Compensation\x20coverage','value':Math['round'](e*0x64),'threshold':Math['round'](c['compensation_coverage_min']*0x64),'unit':'%'}});}}if(b&&b['previous_compensation_balance']!==undefined){const g=b['previous_compensation_balance'];if(g>0x0n&&a['compensation_balance']<g){const h=Number((g-a['compensation_balance'])*0x64n/g)/0x64;if(h>=c['compensation_drop_ratio']){const i=h>=0.5?'critical':'warning';d['push']({'id':'compensation_drop','category':'compensation_drop','severity':i,'title':'Compensation\x20fund\x20balance\x20dropped\x20significantly','message':'Merchant\x20compensation\x20fund\x20dropped\x20from\x20'+formatAmountText(g,a['token']?.['decimals'],a['token']?.['symbol'])+'\x20to\x20'+formatAmountText(a['compensation_balance'],a['token']?.['decimals'],a['token']?.['symbol'])+'\x20(down\x20'+Math['round'](h*0x64)+'%)','action':'Immediately\x20ask\x20the\x20merchant\x20for\x20the\x20reason;\x20if\x20it\x20keeps\x20dropping,\x20the\x20merchant\x20may\x20be\x20processing\x20payouts\x20for\x20other\x20orders,\x20which\x20is\x20a\x20risk','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'metric':{'label':'Compensation\x20drop\x20ratio','value':Math['round'](h*0x64),'threshold':Math['round'](c['compensation_drop_ratio']*0x64),'unit':'%'}});}}}return d;}function detectMessengerTimeout(a,b){const c=[];if(a['has_messenger']===![])return c['push']({'id':'no_messenger_channel','category':'messenger_timeout','severity':'info','title':'Merchant\x20has\x20no\x20Messenger\x20channel','message':'Merchant\x20has\x20not\x20configured\x20Messenger;\x20no\x20way\x20to\x20negotiate\x20online\x20or\x20get\x20post-sale\x20support','action':'Confirm\x20other\x20contact\x20methods\x20before\x20ordering;\x20recommend\x20requiring\x20the\x20merchant\x20to\x20configure\x20Messenger','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id']}),c;if(a['last_user_message_at']&&!a['last_merchant_reply_at']){const d=a['now']-a['last_user_message_at'],e=d/0x36ee80;if(e>b['messenger_timeout_hours']){const f=e>b['messenger_timeout_hours']*0x2?'critical':'warning';c['push']({'id':'messenger_unanswered','category':'messenger_timeout','severity':f,'title':'Merchant\x20Messenger\x20no\x20reply','message':'Merchant\x20has\x20not\x20replied\x20to\x20your\x20Messenger\x20message\x20for\x20'+Math['round'](e)+'\x20hours','action':a['has_arbitration']?'Consider\x20initiating\x20an\x20arbitration\x20application\x20(arbitration\x20window\x20is\x20limited)':'Merchant\x20has\x20no\x20arbitration\x20configured;\x20recommend\x20urging\x20via\x20other\x20contact\x20methods;\x20if\x20there\x20is\x20no\x20response,\x20funds\x20may\x20be\x20frozen','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'metric':{'label':'No-reply\x20duration','value':Math['round'](e),'threshold':Math['round'](b['messenger_timeout_hours']),'unit':'hours'}});}}if(a['last_merchant_reply_at']&&a['last_user_message_at']&&a['last_user_message_at']>a['last_merchant_reply_at']){const g=a['now']-a['last_user_message_at'],h=g/0x36ee80;h>b['messenger_timeout_hours']&&c['push']({'id':'messenger_re_unanswered','category':'messenger_timeout','severity':'warning','title':'Merchant\x20did\x20not\x20reply\x20again','message':'The\x20merchant\x20has\x20not\x20replied\x20to\x20your\x20message\x20from\x20'+Math['round'](h)+'\x20hours\x20ago','action':'Send\x20a\x20follow-up\x20message;\x20if\x20the\x20merchant\x20remains\x20unresponsive,\x20consider\x20arbitration','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'metric':{'label':'Re-no-reply\x20duration','value':Math['round'](h),'threshold':Math['round'](b['messenger_timeout_hours']),'unit':'hours'}});}return c;}function detectPostCompletionAlerts(a,b){const c=[];return a['review_window_days']!==undefined&&a['review_window_days']>0x0&&(a['review_window_days']<=b['review_window_closing_days']?c['push']({'id':'review_window_closing','category':'review_window','severity':'info','title':'Review\x20window\x20about\x20to\x20close','message':'The\x20review\x20window\x20will\x20close\x20in\x20'+a['review_window_days']+'\x20day(s)','action':'Submit\x20a\x20review\x20as\x20soon\x20as\x20possible\x20(evidence\x20can\x20be\x20submitted\x20together\x20if\x20available)','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'metric':{'label':'Remaining\x20days','value':a['review_window_days'],'threshold':b['review_window_closing_days'],'unit':'days'}}):c['push']({'id':'review_reminder','category':'review_window','severity':'info','title':'Order\x20completed','message':'Order\x20completed;\x20review\x20window\x20has\x20'+a['review_window_days']+'\x20day(s)\x20remaining','action':'Submit\x20a\x20review\x20to\x20help\x20other\x20users\x20decide','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id']})),a['arb_window_days']!==undefined&&a['arb_window_days']>0x0&&(a['arb_window_days']<=b['arb_window_closing_days']&&c['push']({'id':'arb_window_closing','category':'arb_window','severity':'warning','title':'Arbitration\x20application\x20window\x20about\x20to\x20close','message':'The\x20arbitration\x20application\x20window\x20will\x20close\x20in\x20'+a['arb_window_days']+'\x20day(s)','action':'If\x20there\x20are\x20unresolved\x20disputes,\x20initiate\x20an\x20arbitration\x20application\x20immediately','timestamp':a['now'],'order_id':a['order_id'],'service_id':a['service_id'],'metric':{'label':'Remaining\x20days','value':a['arb_window_days'],'threshold':b['arb_window_closing_days'],'unit':'days'}})),c;}export function sortAlerts(a){const b={'critical':0x3,'warning':0x2,'info':0x1};return[...a]['sort']((c,d)=>b[d['severity']]-b[c['severity']]);}export function getCriticalAlerts(a){return a['filter'](b=>b['severity']==='critical');}export function getActionableAlerts(a){return a['filter'](b=>b['severity']==='critical'||b['severity']==='warning');}export function summarizeAlerts(a){if(a['length']===0x0)return'â
\x20No\x20alerts;\x20order\x20status\x20is\x20normal';const b=a['filter'](f=>f['severity']==='critical'),c=a['filter'](f=>f['severity']==='warning'),d=a['filter'](f=>f['severity']==='info'),e=[];if(b['length']>0x0)e['push']('đ´\x20'+b['length']+'\x20critical\x20alert(s)');if(c['length']>0x0)e['push']('đ \x20'+c['length']+'\x20warning(s)');if(d['length']>0x0)e['push']('âšī¸\x20'+d['length']+'\x20info');return e['join'](',\x20');}export function isBlockingAlert(a){return a['severity']==='critical';}export function alertsToReminders(a){return a['map'](b=>({'id':b['id'],'priority':b['severity']==='critical'?'required':b['severity']==='warning'?'recommended':'info','message':b['title']+':\x20'+b['message']}));}export{CUSTOMER_INTELLIGENCE_VERSION};
|