@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.
Files changed (375) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,460 +1 @@
1
- import { CUSTOMER_INTELLIGENCE_VERSION } from "./types.js";
2
- export const SUPPORTED_INDUSTRIES = [
3
- "freelance", "rental", "education", "travel", "subscription", "retail",
4
- ];
5
- const INDUSTRY_TEMPLATES = {
6
- freelance: {
7
- max_acceptable_cycle: 30, response_time_expectation: 4,
8
- require_arbitration: true, require_compensation_fund: true,
9
- risk_appetite: "balanced", delivery_speed_priority: "normal",
10
- after_sales_expectation: "full",
11
- },
12
- rental: {
13
- max_acceptable_cycle: 7, response_time_expectation: 8,
14
- require_arbitration: true, require_compensation_fund: true,
15
- risk_appetite: "conservative", delivery_speed_priority: "normal",
16
- after_sales_expectation: "full",
17
- },
18
- education: {
19
- max_acceptable_cycle: 90, response_time_expectation: 24,
20
- require_arbitration: true, require_compensation_fund: true,
21
- risk_appetite: "conservative", delivery_speed_priority: "flexible",
22
- after_sales_expectation: "full",
23
- },
24
- travel: {
25
- max_acceptable_cycle: 14, response_time_expectation: 2,
26
- require_arbitration: true, require_compensation_fund: true,
27
- risk_appetite: "conservative", delivery_speed_priority: "urgent",
28
- after_sales_expectation: "full",
29
- },
30
- subscription: {
31
- max_acceptable_cycle: 30, response_time_expectation: 24,
32
- require_arbitration: false, require_compensation_fund: false,
33
- risk_appetite: "aggressive", delivery_speed_priority: "normal",
34
- after_sales_expectation: "basic",
35
- },
36
- retail: {
37
- max_acceptable_cycle: 7, response_time_expectation: 8,
38
- require_arbitration: true, require_compensation_fund: true,
39
- risk_appetite: "balanced", delivery_speed_priority: "normal",
40
- after_sales_expectation: "full",
41
- },
42
- };
43
- const BASE_DEFAULTS = {
44
- price_sensitivity: "medium",
45
- value_orientation: "balanced",
46
- discount_sensitivity: 0.3,
47
- delivery_speed_priority: "normal",
48
- max_acceptable_cycle: 14,
49
- response_time_expectation: 8,
50
- merchant_preference: "neutral",
51
- min_order_history: 3,
52
- bargain_hunting: 0.3,
53
- reward_seeking: false,
54
- referral_participation: false,
55
- communication_style: "friendly",
56
- transparency_demand: 0.5,
57
- after_sales_expectation: "basic",
58
- risk_appetite: "balanced",
59
- min_trust_score: 50,
60
- require_arbitration: true,
61
- require_compensation_fund: true,
62
- preferred_industries: [],
63
- preferred_tokens: ["0x2::wow::WOW"],
64
- preferred_merchants: [],
65
- };
66
- export function getDefaultPreferences(industry) {
67
- if (!industry || !INDUSTRY_TEMPLATES[industry]) {
68
- return { ...BASE_DEFAULTS };
69
- }
70
- const tpl = INDUSTRY_TEMPLATES[industry];
71
- return {
72
- ...BASE_DEFAULTS,
73
- max_acceptable_cycle: tpl.max_acceptable_cycle,
74
- response_time_expectation: tpl.response_time_expectation,
75
- require_arbitration: tpl.require_arbitration,
76
- require_compensation_fund: tpl.require_compensation_fund,
77
- risk_appetite: tpl.risk_appetite,
78
- delivery_speed_priority: tpl.delivery_speed_priority,
79
- after_sales_expectation: tpl.after_sales_expectation,
80
- };
81
- }
82
- let _registryLookup = null;
83
- export function _setRegistryLookup(fn) {
84
- _registryLookup = fn;
85
- }
86
- export function getIndustryTemplate(industry) {
87
- if (_registryLookup) {
88
- const profile = _registryLookup(industry);
89
- if (profile?.preference_template)
90
- return { ...profile.preference_template };
91
- }
92
- return { ...INDUSTRY_TEMPLATES[industry] };
93
- }
94
- export function inferPreferences(history, basePrefs) {
95
- const prefs = { ...(basePrefs ?? getDefaultPreferences()) };
96
- const confidence = {};
97
- const signals = [];
98
- if (history.length < 3) {
99
- signals.push(`history=${history.length} < 3, keeping default preferences`);
100
- return { preferences: prefs, confidence, signals };
101
- }
102
- const lowPricePicks = history.filter((h) => h.avg_market_price > 0n && h.price < (h.avg_market_price * 90n) / 100n);
103
- if (lowPricePicks.length >= 3) {
104
- prefs.price_sensitivity = "high";
105
- prefs.value_orientation = "budget";
106
- confidence.price_sensitivity = 0.8;
107
- confidence.value_orientation = 0.7;
108
- signals.push(`Consecutive ${lowPricePicks.length} picks of Service priced 10%+ below average → price_sensitivity=high`);
109
- }
110
- else if (lowPricePicks.length >= 1) {
111
- prefs.price_sensitivity = "medium";
112
- confidence.price_sensitivity = 0.5;
113
- signals.push(`${lowPricePicks.length} low-price picks → price_sensitivity=medium`);
114
- }
115
- const discountUsers = history.filter((h) => h.used_discount);
116
- if (discountUsers.length >= 2) {
117
- prefs.discount_sensitivity = 0.8;
118
- confidence.discount_sensitivity = 0.85;
119
- signals.push(`Used discount ${discountUsers.length} times → discount_sensitivity=0.8`);
120
- }
121
- if (history.some((h) => h.used_referral)) {
122
- prefs.referral_participation = true;
123
- confidence.referral_participation = 1.0;
124
- signals.push("Has used a referral code → referral_participation=true");
125
- }
126
- if (discountUsers.length >= 2 || history.some((h) => h.used_referral)) {
127
- prefs.reward_seeking = true;
128
- confidence.reward_seeking = 0.75;
129
- signals.push("Reward behavior detected → reward_seeking=true");
130
- }
131
- const bargainSignals = discountUsers.length + (history.some((h) => h.used_referral) ? 1 : 0);
132
- if (bargainSignals >= 3) {
133
- prefs.bargain_hunting = 0.8;
134
- confidence.bargain_hunting = 0.8;
135
- }
136
- else if (bargainSignals >= 1) {
137
- prefs.bargain_hunting = 0.5;
138
- confidence.bargain_hunting = 0.6;
139
- }
140
- const industryCounts = new Map();
141
- for (const h of history) {
142
- if (h.industry) {
143
- industryCounts.set(h.industry, (industryCounts.get(h.industry) ?? 0) + 1);
144
- }
145
- }
146
- const preferredIndustries = Array.from(industryCounts.entries())
147
- .filter(([, c]) => c >= 1)
148
- .sort((a, b) => b[1] - a[1])
149
- .slice(0, 3)
150
- .map(([ind]) => ind);
151
- if (preferredIndustries.length > 0) {
152
- prefs.preferred_industries = preferredIndustries;
153
- confidence.preferred_industries = Math.min(1, (industryCounts.get(preferredIndustries[0]) ?? 0) / 5);
154
- signals.push(`Preferred industries: ${preferredIndustries.join(", ")}`);
155
- }
156
- const arbPicks = history.filter((h) => h.has_arbitration);
157
- if (arbPicks.length >= 3 && arbPicks.length === history.length) {
158
- prefs.require_arbitration = true;
159
- confidence.require_arbitration = 0.85;
160
- signals.push("100% of historical orders picked Services with arbitration → require_arbitration=true (confirmed)");
161
- }
162
- else if (arbPicks.length < history.length / 2) {
163
- prefs.require_arbitration = false;
164
- confidence.require_arbitration = 0.5;
165
- signals.push(`${arbPicks.length}/${history.length} orders had arbitration → require_arbitration=false`);
166
- }
167
- const compPicks = history.filter((h) => h.has_compensation);
168
- if (compPicks.length >= 3 && compPicks.length === history.length) {
169
- prefs.require_compensation_fund = true;
170
- confidence.require_compensation_fund = 0.85;
171
- signals.push("100% of historical orders had compensation fund → require_compensation_fund=true (confirmed)");
172
- }
173
- else if (compPicks.length < history.length / 2) {
174
- prefs.require_compensation_fund = false;
175
- confidence.require_compensation_fund = 0.5;
176
- }
177
- const riskScores = history
178
- .map((h) => h.risk_score_at_purchase)
179
- .filter((s) => typeof s === "number");
180
- if (riskScores.length >= 5) {
181
- const minRisk = Math.min(...riskScores);
182
- if (minRisk >= 70) {
183
- prefs.risk_appetite = "conservative";
184
- prefs.min_trust_score = 70;
185
- confidence.risk_appetite = 0.8;
186
- confidence.min_trust_score = 0.7;
187
- signals.push(`Lowest risk score in history ${minRisk} ≥ 70 → risk_appetite=conservative`);
188
- }
189
- else if (minRisk < 50) {
190
- prefs.risk_appetite = "aggressive";
191
- prefs.min_trust_score = Math.max(0, minRisk - 10);
192
- confidence.risk_appetite = 0.7;
193
- signals.push(`Lowest risk score in history ${minRisk} < 50 → risk_appetite=aggressive`);
194
- }
195
- }
196
- const messengerUsers = history.filter((h) => h.used_messenger);
197
- if (messengerUsers.length >= 2) {
198
- const avgMsgs = messengerUsers.reduce((s, h) => s + (h.messenger_messages ?? 0), 0) / messengerUsers.length;
199
- if (avgMsgs >= 10) {
200
- prefs.communication_style = "formal";
201
- confidence.communication_style = 0.6;
202
- signals.push(`Average ${avgMsgs.toFixed(1)} Messenger messages → communication_style=formal`);
203
- }
204
- else if (avgMsgs <= 3) {
205
- prefs.communication_style = "casual";
206
- confidence.communication_style = 0.5;
207
- signals.push(`Average ${avgMsgs.toFixed(1)} Messenger messages → communication_style=casual`);
208
- }
209
- prefs.transparency_demand = Math.min(1, avgMsgs / 20);
210
- confidence.transparency_demand = 0.6;
211
- }
212
- const disputedCount = history.filter((h) => h.has_dispute).length;
213
- if (disputedCount > 0) {
214
- prefs.transparency_demand = Math.max(prefs.transparency_demand, 0.7);
215
- prefs.after_sales_expectation = "full";
216
- confidence.transparency_demand = Math.max(confidence.transparency_demand ?? 0, 0.7);
217
- confidence.after_sales_expectation = 0.7;
218
- signals.push(`${disputedCount} disputes → transparency_demand increased, after_sales=full`);
219
- }
220
- const merchantCounts = new Map();
221
- for (const h of history) {
222
- if (h.service_owner) {
223
- merchantCounts.set(h.service_owner, (merchantCounts.get(h.service_owner) ?? 0) + 1);
224
- }
225
- }
226
- prefs.preferred_merchants = Array.from(merchantCounts.entries())
227
- .filter(([, c]) => c >= 2)
228
- .sort((a, b) => b[1] - a[1])
229
- .slice(0, 5)
230
- .map(([m]) => m);
231
- if (prefs.preferred_merchants.length > 0) {
232
- confidence.preferred_merchants = 0.8;
233
- signals.push(`Patronized ${prefs.preferred_merchants.length} merchants ≥2 times`);
234
- }
235
- return { preferences: prefs, confidence, signals };
236
- }
237
- export function matchServiceToPreferences(service, prefs) {
238
- const matches = [];
239
- const mismatches = [];
240
- const warnings = [];
241
- let score = 0;
242
- let maxScore = 0;
243
- maxScore += 25;
244
- if (prefs.budget_range) {
245
- if (service.price >= prefs.budget_range.min && service.price <= prefs.budget_range.max) {
246
- score += 20;
247
- matches.push("Price within budget range");
248
- }
249
- else if (service.price < prefs.budget_range.min) {
250
- score += 15;
251
- matches.push("Price below budget minimum");
252
- }
253
- else {
254
- mismatches.push("Price exceeds budget maximum");
255
- }
256
- }
257
- else if (service.avg_market_price && service.avg_market_price > 0n) {
258
- const ratio = Number((service.price * 100n) / service.avg_market_price) / 100;
259
- if (prefs.price_sensitivity === "high") {
260
- if (ratio <= 0.9) {
261
- score += 25;
262
- matches.push(`Price is ${(1 - ratio) * 100 | 0}% below average (bonus for high-sensitivity user)`);
263
- }
264
- else if (ratio <= 1.1) {
265
- score += 15;
266
- matches.push("Price on par with average");
267
- }
268
- else {
269
- mismatches.push(`Price is ${((ratio - 1) * 100 | 0)}% above average (high-sensitivity user)`);
270
- }
271
- }
272
- else if (prefs.price_sensitivity === "low") {
273
- score += 20;
274
- matches.push("Low price sensitivity");
275
- }
276
- else {
277
- if (ratio <= 1.0) {
278
- score += 20;
279
- matches.push("Price not above average");
280
- }
281
- else if (ratio <= 1.2) {
282
- score += 12;
283
- }
284
- else {
285
- mismatches.push("Price significantly above average");
286
- }
287
- }
288
- }
289
- else {
290
- score += 12;
291
- }
292
- maxScore += 15;
293
- const cycle = service.estimated_cycle_days ?? 0;
294
- if (cycle > 0) {
295
- if (cycle <= prefs.max_acceptable_cycle) {
296
- score += 10;
297
- matches.push(`Delivery cycle ${cycle} days ≤ expected ${prefs.max_acceptable_cycle} days`);
298
- if (prefs.delivery_speed_priority === "urgent" && cycle <= Math.max(1, prefs.max_acceptable_cycle / 3)) {
299
- score += 5;
300
- matches.push("Urgent delivery need satisfied");
301
- }
302
- else if (prefs.delivery_speed_priority === "urgent") {
303
- warnings.push("Urgent delivery need but cycle is long");
304
- }
305
- }
306
- else {
307
- mismatches.push(`Delivery cycle ${cycle} days > expected ${prefs.max_acceptable_cycle} days`);
308
- }
309
- }
310
- else {
311
- score += 7;
312
- }
313
- maxScore += 10;
314
- if (prefs.preferred_region) {
315
- if (service.merchant_region && service.merchant_region === prefs.preferred_region) {
316
- score += 10;
317
- matches.push(`Merchant region ${service.merchant_region} matches preference`);
318
- }
319
- else if (service.merchant_region) {
320
- mismatches.push(`Merchant region ${service.merchant_region} does not match preference ${prefs.preferred_region}`);
321
- }
322
- else {
323
- score += 5;
324
- }
325
- }
326
- else {
327
- score += 7;
328
- }
329
- maxScore += 10;
330
- if (service.merchant_order_history_count >= prefs.min_order_history) {
331
- score += 7;
332
- matches.push(`Merchant history ${service.merchant_order_history_count} orders ≥ required ${prefs.min_order_history} orders`);
333
- }
334
- else {
335
- mismatches.push(`Merchant history ${service.merchant_order_history_count} orders < required ${prefs.min_order_history} orders`);
336
- }
337
- if (prefs.merchant_preference !== "neutral") {
338
- if (service.merchant_age === prefs.merchant_preference) {
339
- score += 3;
340
- matches.push(`Merchant type ${service.merchant_age} matches preference`);
341
- }
342
- else if (service.merchant_age !== "unknown") {
343
- mismatches.push(`Merchant type ${service.merchant_age} ≠ preference ${prefs.merchant_preference}`);
344
- }
345
- }
346
- else {
347
- score += 3;
348
- }
349
- maxScore += 15;
350
- let bargainScore = 0;
351
- if (service.has_reward_activity) {
352
- bargainScore += 8;
353
- matches.push("Has Reward activity");
354
- }
355
- if (service.has_discount) {
356
- bargainScore += 7;
357
- matches.push("Has discount");
358
- }
359
- if (prefs.bargain_hunting >= 0.7 && bargainScore === 0) {
360
- mismatches.push("User has high bargain_hunting but no Reward/discount");
361
- }
362
- else if (prefs.bargain_hunting < 0.3) {
363
- if (bargainScore === 0)
364
- bargainScore = 10;
365
- else
366
- bargainScore = Math.min(bargainScore, 5);
367
- }
368
- else if (prefs.bargain_hunting < 0.7 && bargainScore === 0) {
369
- bargainScore = 5;
370
- }
371
- score += bargainScore;
372
- maxScore += 10;
373
- if (service.after_sales_support_level === prefs.after_sales_expectation) {
374
- score += 5;
375
- matches.push(`After-sales support ${service.after_sales_support_level} matches expectation`);
376
- }
377
- else if ((prefs.after_sales_expectation === "full" && service.after_sales_support_level === "basic") ||
378
- (prefs.after_sales_expectation === "full" && service.after_sales_support_level === "minimal") ||
379
- (prefs.after_sales_expectation === "basic" && service.after_sales_support_level === "minimal")) {
380
- mismatches.push(`After-sales support ${service.after_sales_support_level} < expectation ${prefs.after_sales_expectation}`);
381
- }
382
- else {
383
- score += 3;
384
- }
385
- if (prefs.transparency_demand >= 0.7 && service.requires_messenger) {
386
- score += 5;
387
- matches.push("Merchant supports Messenger communication (high transparency demand)");
388
- }
389
- else if (prefs.transparency_demand >= 0.7 && !service.requires_messenger) {
390
- mismatches.push("High transparency demand but merchant has no Messenger");
391
- }
392
- else {
393
- score += 3;
394
- }
395
- maxScore += 15;
396
- if (service.risk_score >= prefs.min_trust_score) {
397
- score += 8;
398
- matches.push(`Risk score ${service.risk_score} ≥ required ${prefs.min_trust_score}`);
399
- }
400
- else {
401
- mismatches.push(`Risk score ${service.risk_score} < required ${prefs.min_trust_score}`);
402
- }
403
- if (prefs.require_arbitration) {
404
- if (service.has_arbitration) {
405
- score += 4;
406
- matches.push("Arbitration configured");
407
- }
408
- else {
409
- mismatches.push("User requires arbitration but Service is not configured");
410
- warnings.push("⚠️ No arbitration: user preference requires arbitration as mandatory");
411
- }
412
- }
413
- else {
414
- score += 4;
415
- }
416
- if (prefs.require_compensation_fund) {
417
- if (service.has_compensation_fund) {
418
- score += 3;
419
- matches.push("Has compensation fund");
420
- }
421
- else {
422
- mismatches.push("User requires compensation fund but Service has none");
423
- warnings.push("⚠️ No compensation fund: user preference requires it as mandatory");
424
- }
425
- }
426
- else {
427
- score += 3;
428
- }
429
- const normalized = maxScore > 0 ? Math.round((score / maxScore) * 100) : 0;
430
- return { score: normalized, matches, mismatches, warnings };
431
- }
432
- export function mergePreferences(inferred, manual) {
433
- return { ...inferred, ...manual };
434
- }
435
- export function validatePreferences(prefs) {
436
- const issues = [];
437
- if (prefs.budget_range && prefs.budget_range.min > prefs.budget_range.max) {
438
- issues.push("budget_range.min > budget_range.max");
439
- }
440
- if (prefs.discount_sensitivity < 0 || prefs.discount_sensitivity > 1) {
441
- issues.push("discount_sensitivity must be in [0,1]");
442
- }
443
- if (prefs.bargain_hunting < 0 || prefs.bargain_hunting > 1) {
444
- issues.push("bargain_hunting must be in [0,1]");
445
- }
446
- if (prefs.transparency_demand < 0 || prefs.transparency_demand > 1) {
447
- issues.push("transparency_demand must be in [0,1]");
448
- }
449
- if (prefs.min_trust_score < 0 || prefs.min_trust_score > 100) {
450
- issues.push("min_trust_score must be in [0,100]");
451
- }
452
- if (prefs.max_acceptable_cycle < 0) {
453
- issues.push("max_acceptable_cycle must be ≥ 0");
454
- }
455
- if (prefs.response_time_expectation < 0) {
456
- issues.push("response_time_expectation must be ≥ 0");
457
- }
458
- return issues;
459
- }
460
- export { CUSTOMER_INTELLIGENCE_VERSION };
1
+ import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export const SUPPORTED_INDUSTRIES=['freelance','rental','education','travel','subscription','retail'];const INDUSTRY_TEMPLATES={'freelance':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x4,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'},'rental':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'normal','after_sales_expectation':'full'},'education':{'max_acceptable_cycle':0x5a,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'travel':{'max_acceptable_cycle':0xe,'response_time_expectation':0x2,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'urgent','after_sales_expectation':'full'},'subscription':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x18,'require_arbitration':![],'require_compensation_fund':![],'risk_appetite':'aggressive','delivery_speed_priority':'normal','after_sales_expectation':'basic'},'retail':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'}},BASE_DEFAULTS={'price_sensitivity':'medium','value_orientation':'balanced','discount_sensitivity':0.3,'delivery_speed_priority':'normal','max_acceptable_cycle':0xe,'response_time_expectation':0x8,'merchant_preference':'neutral','min_order_history':0x3,'bargain_hunting':0.3,'reward_seeking':![],'referral_participation':![],'communication_style':'friendly','transparency_demand':0.5,'after_sales_expectation':'basic','risk_appetite':'balanced','min_trust_score':0x32,'require_arbitration':!![],'require_compensation_fund':!![],'preferred_industries':[],'preferred_tokens':['0x2::wow::WOW'],'preferred_merchants':[]};export function getDefaultPreferences(a){if(!a||!INDUSTRY_TEMPLATES[a])return{...BASE_DEFAULTS};const b=INDUSTRY_TEMPLATES[a];return{...BASE_DEFAULTS,'max_acceptable_cycle':b['max_acceptable_cycle'],'response_time_expectation':b['response_time_expectation'],'require_arbitration':b['require_arbitration'],'require_compensation_fund':b['require_compensation_fund'],'risk_appetite':b['risk_appetite'],'delivery_speed_priority':b['delivery_speed_priority'],'after_sales_expectation':b['after_sales_expectation']};}let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getIndustryTemplate(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['preference_template'])return{...b['preference_template']};}return{...INDUSTRY_TEMPLATES[a]};}export function inferPreferences(a,b){const c={...b??getDefaultPreferences()},d={},e=[];if(a['length']<0x3)return e['push']('history='+a['length']+'\x20<\x203,\x20keeping\x20default\x20preferences'),{'preferences':c,'confidence':d,'signals':e};const f=a['filter'](r=>r['avg_market_price']>0x0n&&r['price']<r['avg_market_price']*0x5an/0x64n);if(f['length']>=0x3)c['price_sensitivity']='high',c['value_orientation']='budget',d['price_sensitivity']=0.8,d['value_orientation']=0.7,e['push']('Consecutive\x20'+f['length']+'\x20picks\x20of\x20Service\x20priced\x2010%+\x20below\x20average\x20→\x20price_sensitivity=high');else f['length']>=0x1&&(c['price_sensitivity']='medium',d['price_sensitivity']=0.5,e['push'](f['length']+'\x20low-price\x20picks\x20→\x20price_sensitivity=medium'));const g=a['filter'](r=>r['used_discount']);g['length']>=0x2&&(c['discount_sensitivity']=0.8,d['discount_sensitivity']=0.85,e['push']('Used\x20discount\x20'+g['length']+'\x20times\x20→\x20discount_sensitivity=0.8'));a['some'](r=>r['used_referral'])&&(c['referral_participation']=!![],d['referral_participation']=0x1,e['push']('Has\x20used\x20a\x20referral\x20code\x20→\x20referral_participation=true'));(g['length']>=0x2||a['some'](r=>r['used_referral']))&&(c['reward_seeking']=!![],d['reward_seeking']=0.75,e['push']('Reward\x20behavior\x20detected\x20→\x20reward_seeking=true'));const i=g['length']+(a['some'](r=>r['used_referral'])?0x1:0x0);if(i>=0x3)c['bargain_hunting']=0.8,d['bargain_hunting']=0.8;else i>=0x1&&(c['bargain_hunting']=0.5,d['bargain_hunting']=0.6);const j=new Map();for(const r of a){r['industry']&&j['set'](r['industry'],(j['get'](r['industry'])??0x0)+0x1);}const k=Array['from'](j['entries']())['filter'](([,s])=>s>=0x1)['sort']((s,t)=>t[0x1]-s[0x1])['slice'](0x0,0x3)['map'](([s])=>s);k['length']>0x0&&(c['preferred_industries']=k,d['preferred_industries']=Math['min'](0x1,(j['get'](k[0x0])??0x0)/0x5),e['push']('Preferred\x20industries:\x20'+k['join'](',\x20')));const l=a['filter'](s=>s['has_arbitration']);if(l['length']>=0x3&&l['length']===a['length'])c['require_arbitration']=!![],d['require_arbitration']=0.85,e['push']('100%\x20of\x20historical\x20orders\x20picked\x20Services\x20with\x20arbitration\x20→\x20require_arbitration=true\x20(confirmed)');else l['length']<a['length']/0x2&&(c['require_arbitration']=![],d['require_arbitration']=0.5,e['push'](l['length']+'/'+a['length']+'\x20orders\x20had\x20arbitration\x20→\x20require_arbitration=false'));const m=a['filter'](s=>s['has_compensation']);if(m['length']>=0x3&&m['length']===a['length'])c['require_compensation_fund']=!![],d['require_compensation_fund']=0.85,e['push']('100%\x20of\x20historical\x20orders\x20had\x20compensation\x20fund\x20→\x20require_compensation_fund=true\x20(confirmed)');else m['length']<a['length']/0x2&&(c['require_compensation_fund']=![],d['require_compensation_fund']=0.5);const n=a['map'](s=>s['risk_score_at_purchase'])['filter'](t=>typeof t==='number');if(n['length']>=0x5){const s=Math['min'](...n);if(s>=0x46)c['risk_appetite']='conservative',c['min_trust_score']=0x46,d['risk_appetite']=0.8,d['min_trust_score']=0.7,e['push']('Lowest\x20risk\x20score\x20in\x20history\x20'+s+'\x20≥\x2070\x20→\x20risk_appetite=conservative');else s<0x32&&(c['risk_appetite']='aggressive',c['min_trust_score']=Math['max'](0x0,s-0xa),d['risk_appetite']=0.7,e['push']('Lowest\x20risk\x20score\x20in\x20history\x20'+s+'\x20<\x2050\x20→\x20risk_appetite=aggressive'));}const o=a['filter'](t=>t['used_messenger']);if(o['length']>=0x2){const t=o['reduce']((u,v)=>u+(v['messenger_messages']??0x0),0x0)/o['length'];if(t>=0xa)c['communication_style']='formal',d['communication_style']=0.6,e['push']('Average\x20'+t['toFixed'](0x1)+'\x20Messenger\x20messages\x20→\x20communication_style=formal');else t<=0x3&&(c['communication_style']='casual',d['communication_style']=0.5,e['push']('Average\x20'+t['toFixed'](0x1)+'\x20Messenger\x20messages\x20→\x20communication_style=casual'));c['transparency_demand']=Math['min'](0x1,t/0x14),d['transparency_demand']=0.6;}const p=a['filter'](u=>u['has_dispute'])['length'];p>0x0&&(c['transparency_demand']=Math['max'](c['transparency_demand'],0.7),c['after_sales_expectation']='full',d['transparency_demand']=Math['max'](d['transparency_demand']??0x0,0.7),d['after_sales_expectation']=0.7,e['push'](p+'\x20disputes\x20→\x20transparency_demand\x20increased,\x20after_sales=full'));const q=new Map();for(const u of a){u['service_owner']&&q['set'](u['service_owner'],(q['get'](u['service_owner'])??0x0)+0x1);}return c['preferred_merchants']=Array['from'](q['entries']())['filter'](([,v])=>v>=0x2)['sort']((v,w)=>w[0x1]-v[0x1])['slice'](0x0,0x5)['map'](([v])=>v),c['preferred_merchants']['length']>0x0&&(d['preferred_merchants']=0.8,e['push']('Patronized\x20'+c['preferred_merchants']['length']+'\x20merchants\x20≥2\x20times')),{'preferences':c,'confidence':d,'signals':e};}export function matchServiceToPreferences(a,b){const c=[],d=[],e=[];let f=0x0,g=0x0;g+=0x19;if(b['budget_range']){if(a['price']>=b['budget_range']['min']&&a['price']<=b['budget_range']['max'])f+=0x14,c['push']('Price\x20within\x20budget\x20range');else a['price']<b['budget_range']['min']?(f+=0xf,c['push']('Price\x20below\x20budget\x20minimum')):d['push']('Price\x20exceeds\x20budget\x20maximum');}else{if(a['avg_market_price']&&a['avg_market_price']>0x0n){const k=Number(a['price']*0x64n/a['avg_market_price'])/0x64;if(b['price_sensitivity']==='high'){if(k<=0.9)f+=0x19,c['push']('Price\x20is\x20'+((0x1-k)*0x64|0x0)+'%\x20below\x20average\x20(bonus\x20for\x20high-sensitivity\x20user)');else k<=1.1?(f+=0xf,c['push']('Price\x20on\x20par\x20with\x20average')):d['push']('Price\x20is\x20'+((k-0x1)*0x64|0x0)+'%\x20above\x20average\x20(high-sensitivity\x20user)');}else{if(b['price_sensitivity']==='low')f+=0x14,c['push']('Low\x20price\x20sensitivity');else{if(k<=0x1)f+=0x14,c['push']('Price\x20not\x20above\x20average');else k<=1.2?f+=0xc:d['push']('Price\x20significantly\x20above\x20average');}}}else f+=0xc;}g+=0xf;const h=a['estimated_cycle_days']??0x0;if(h>0x0){if(h<=b['max_acceptable_cycle']){f+=0xa,c['push']('Delivery\x20cycle\x20'+h+'\x20days\x20≤\x20expected\x20'+b['max_acceptable_cycle']+'\x20days');if(b['delivery_speed_priority']==='urgent'&&h<=Math['max'](0x1,b['max_acceptable_cycle']/0x3))f+=0x5,c['push']('Urgent\x20delivery\x20need\x20satisfied');else b['delivery_speed_priority']==='urgent'&&e['push']('Urgent\x20delivery\x20need\x20but\x20cycle\x20is\x20long');}else d['push']('Delivery\x20cycle\x20'+h+'\x20days\x20>\x20expected\x20'+b['max_acceptable_cycle']+'\x20days');}else f+=0x7;g+=0xa;if(b['preferred_region']){if(a['merchant_region']&&a['merchant_region']===b['preferred_region'])f+=0xa,c['push']('Merchant\x20region\x20'+a['merchant_region']+'\x20matches\x20preference');else a['merchant_region']?d['push']('Merchant\x20region\x20'+a['merchant_region']+'\x20does\x20not\x20match\x20preference\x20'+b['preferred_region']):f+=0x5;}else f+=0x7;g+=0xa;a['merchant_order_history_count']>=b['min_order_history']?(f+=0x7,c['push']('Merchant\x20history\x20'+a['merchant_order_history_count']+'\x20orders\x20≥\x20required\x20'+b['min_order_history']+'\x20orders')):d['push']('Merchant\x20history\x20'+a['merchant_order_history_count']+'\x20orders\x20<\x20required\x20'+b['min_order_history']+'\x20orders');if(b['merchant_preference']!=='neutral'){if(a['merchant_age']===b['merchant_preference'])f+=0x3,c['push']('Merchant\x20type\x20'+a['merchant_age']+'\x20matches\x20preference');else a['merchant_age']!=='unknown'&&d['push']('Merchant\x20type\x20'+a['merchant_age']+'\x20≠\x20preference\x20'+b['merchant_preference']);}else f+=0x3;g+=0xf;let i=0x0;a['has_reward_activity']&&(i+=0x8,c['push']('Has\x20Reward\x20activity'));a['has_discount']&&(i+=0x7,c['push']('Has\x20discount'));if(b['bargain_hunting']>=0.7&&i===0x0)d['push']('User\x20has\x20high\x20bargain_hunting\x20but\x20no\x20Reward/discount');else{if(b['bargain_hunting']<0.3){if(i===0x0)i=0xa;else i=Math['min'](i,0x5);}else b['bargain_hunting']<0.7&&i===0x0&&(i=0x5);}f+=i,g+=0xa;if(a['after_sales_support_level']===b['after_sales_expectation'])f+=0x5,c['push']('After-sales\x20support\x20'+a['after_sales_support_level']+'\x20matches\x20expectation');else b['after_sales_expectation']==='full'&&a['after_sales_support_level']==='basic'||b['after_sales_expectation']==='full'&&a['after_sales_support_level']==='minimal'||b['after_sales_expectation']==='basic'&&a['after_sales_support_level']==='minimal'?d['push']('After-sales\x20support\x20'+a['after_sales_support_level']+'\x20<\x20expectation\x20'+b['after_sales_expectation']):f+=0x3;if(b['transparency_demand']>=0.7&&a['requires_messenger'])f+=0x5,c['push']('Merchant\x20supports\x20Messenger\x20communication\x20(high\x20transparency\x20demand)');else b['transparency_demand']>=0.7&&!a['requires_messenger']?d['push']('High\x20transparency\x20demand\x20but\x20merchant\x20has\x20no\x20Messenger'):f+=0x3;g+=0xf;a['risk_score']>=b['min_trust_score']?(f+=0x8,c['push']('Risk\x20score\x20'+a['risk_score']+'\x20≥\x20required\x20'+b['min_trust_score'])):d['push']('Risk\x20score\x20'+a['risk_score']+'\x20<\x20required\x20'+b['min_trust_score']);b['require_arbitration']?a['has_arbitration']?(f+=0x4,c['push']('Arbitration\x20configured')):(d['push']('User\x20requires\x20arbitration\x20but\x20Service\x20is\x20not\x20configured'),e['push']('⚠️\x20No\x20arbitration:\x20user\x20preference\x20requires\x20arbitration\x20as\x20mandatory')):f+=0x4;b['require_compensation_fund']?a['has_compensation_fund']?(f+=0x3,c['push']('Has\x20compensation\x20fund')):(d['push']('User\x20requires\x20compensation\x20fund\x20but\x20Service\x20has\x20none'),e['push']('⚠️\x20No\x20compensation\x20fund:\x20user\x20preference\x20requires\x20it\x20as\x20mandatory')):f+=0x3;const j=g>0x0?Math['round'](f/g*0x64):0x0;return{'score':j,'matches':c,'mismatches':d,'warnings':e};}export function mergePreferences(a,b){return{...a,...b};}export function validatePreferences(a){const b=[];return a['budget_range']&&a['budget_range']['min']>a['budget_range']['max']&&b['push']('budget_range.min\x20>\x20budget_range.max'),(a['discount_sensitivity']<0x0||a['discount_sensitivity']>0x1)&&b['push']('discount_sensitivity\x20must\x20be\x20in\x20[0,1]'),(a['bargain_hunting']<0x0||a['bargain_hunting']>0x1)&&b['push']('bargain_hunting\x20must\x20be\x20in\x20[0,1]'),(a['transparency_demand']<0x0||a['transparency_demand']>0x1)&&b['push']('transparency_demand\x20must\x20be\x20in\x20[0,1]'),(a['min_trust_score']<0x0||a['min_trust_score']>0x64)&&b['push']('min_trust_score\x20must\x20be\x20in\x20[0,100]'),a['max_acceptable_cycle']<0x0&&b['push']('max_acceptable_cycle\x20must\x20be\x20≥\x200'),a['response_time_expectation']<0x0&&b['push']('response_time_expectation\x20must\x20be\x20≥\x200'),b;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1,8 +1,11 @@
1
1
  import type { ArbStatus } from "../knowledge/arbitration-ledger.js";
2
- export type ArbGamePerspective = "disputant" | "arbitrator" | "voter" | "both";
2
+ import { type RiskAppetite } from "./game-strategy.js";
3
+ export type ArbGamePerspective = "customer" | "merchant" | "arbitrator";
3
4
  export interface ArbGameAction {
4
5
  action: string;
5
6
  favorability: number;
7
+ gain_score: number;
8
+ risk_score: number;
6
9
  is_optimal: boolean;
7
10
  payoff_note: string;
8
11
  risk: "low" | "medium" | "high";
@@ -13,4 +16,8 @@ export interface ArbGameAdvice {
13
16
  actions: ArbGameAction[];
14
17
  summary: string;
15
18
  }
16
- export declare function evaluateArbGame(status: ArbStatus, perspective: ArbGamePerspective): ArbGameAdvice;
19
+ export interface ArbPersonaDrive {
20
+ risk_appetite?: RiskAppetite;
21
+ requirements?: string[];
22
+ }
23
+ export declare function evaluateArbGame(status: ArbStatus, perspective: ArbGamePerspective, drive?: ArbPersonaDrive): ArbGameAdvice;
@@ -1,48 +1 @@
1
- const GAME_MATRIX = {
2
- Principal_confirming: [
3
- { action: "principal_confirm", perspective: "disputant", favorability: 80, payoff: "confirm the proposition to move to arbitrator confirmation", risk: "low" },
4
- { action: "proposition_change", perspective: "disputant", favorability: 50, payoff: "modify the proposition before confirming", risk: "medium" },
5
- ],
6
- Arbitrator_confirming: [
7
- { action: "confirm", perspective: "arbitrator", favorability: 80, payoff: "confirm to open voting", risk: "low" },
8
- { action: "reset", perspective: "arbitrator", favorability: 30, payoff: "reset back to principal confirmation (extends the case)", risk: "high" },
9
- ],
10
- Voting: [
11
- { action: "vote", perspective: "voter", favorability: 80, payoff: "vote before the deadline", risk: "low" },
12
- ],
13
- Arbitrated: [
14
- { action: "objection", perspective: "disputant", favorability: 60, payoff: "object the ruling (only window)", risk: "medium" },
15
- { action: "accept", perspective: "disputant", favorability: 40, payoff: "accept and await compensation", risk: "low" },
16
- ],
17
- Objectionable: [
18
- { action: "reset", perspective: "arbitrator", favorability: 60, payoff: "reset to re-review", risk: "medium" },
19
- ],
20
- Finished: [
21
- { action: "arb_withdraw", perspective: "both", favorability: 80, payoff: "withdraw fees / compensation", risk: "low" },
22
- ],
23
- Withdrawn: [
24
- { action: "done", perspective: "both", favorability: 100, payoff: "case closed", risk: "low" },
25
- ],
26
- };
27
- export function evaluateArbGame(status, perspective) {
28
- const entries = GAME_MATRIX[status] ?? [];
29
- const visible = entries.filter((e) => e.perspective === "both" || e.perspective === perspective);
30
- const actions = visible
31
- .slice()
32
- .sort((a, b) => b.favorability - a.favorability)
33
- .map((e, i) => ({
34
- action: e.action,
35
- favorability: e.favorability,
36
- is_optimal: i === 0,
37
- payoff_note: e.payoff,
38
- risk: e.risk,
39
- }));
40
- return {
41
- status,
42
- perspective,
43
- actions,
44
- summary: actions.length === 0
45
- ? `No recommended moves for ${perspective} in status '${status}'`
46
- : `Optimal for ${perspective} in '${status}': '${actions[0].action}' (${actions[0].payoff_note})`,
47
- };
48
- }
1
+ import{appetiteMultiplier}from'./game-strategy.js';const ARB_ROLE_INTERESTS={'arbitrator':{'prefer':['case_advanced','fees_received','case_closed'],'avoid':['case_extended'],'sensitivity':0x1},'customer':{'prefer':['reversal_chance','case_closed'],'avoid':['adverse_ruling','case_extended'],'sensitivity':0x1},'merchant':{'prefer':['case_closed','fees_received'],'avoid':['adverse_ruling','reversal_chance','case_extended'],'sensitivity':0x1}},ARB_MOVE_SEMANTICS={'Principal_confirming':[{'action':'principal_confirm','perspective':'customer','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20the\x20proposition\x20to\x20move\x20to\x20arbitrator\x20confirmation','base_risk':'low'},{'action':'proposition_change','perspective':'customer','gain':[],'risk':['case_extended'],'payoff':'modify\x20the\x20proposition\x20before\x20confirming\x20(extends\x20the\x20case)','base_risk':'medium'}],'Arbitrator_confirming':[{'action':'confirm','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20to\x20open\x20voting','base_risk':'low'},{'action':'reset','perspective':'arbitrator','gain':[],'risk':['case_extended'],'payoff':'reset\x20back\x20to\x20principal\x20confirmation\x20(extends\x20the\x20case)','base_risk':'high'}],'Voting':[{'action':'vote','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'vote\x20before\x20the\x20deadline','base_risk':'low'}],'Arbitrated':[{'action':'objection','perspective':'customer','gain':['reversal_chance'],'risk':[],'payoff':'object\x20the\x20ruling\x20(only\x20window\x20to\x20overturn)','base_risk':'medium'},{'action':'accept','perspective':'customer','gain':['case_closed'],'risk':['adverse_ruling'],'payoff':'accept\x20and\x20await\x20compensation','base_risk':'low'}],'Objectionable':[{'action':'reset','perspective':'arbitrator','gain':['case_advanced'],'risk':['case_extended'],'payoff':'reset\x20to\x20re-review\x20(extends\x20the\x20case)','base_risk':'medium'}],'Finished':[{'action':'arb_withdraw','perspective':'all','gain':['fees_received','case_closed'],'risk':[],'payoff':'withdraw\x20fees\x20/\x20compensation','base_risk':'low'}],'Withdrawn':[{'action':'done','perspective':'all','gain':['case_closed'],'risk':[],'payoff':'case\x20closed','base_risk':'low'}]};function dedupe(a){return Array['from'](new Set(a));}function resolveArbInterests(a,b){const c=ARB_ROLE_INTERESTS[a],d=c['sensitivity']*appetiteMultiplier(b?.['risk_appetite']),e=[...c['prefer']],f=[...c['avoid']];for(const g of b?.['requirements']??[]){const h=g['toLowerCase'](),i=/forbid|never|\bno\b/['test'](h);if(h['includes']('arbitration')&&i)f['push']('case_extended');if(h['includes']('refund')&&!i)e['push']('reversal_chance');if(h['includes']('prolong')||h['includes']('delay')||h['includes']('拖延'))f['push']('case_extended');}return{'prefer':dedupe(e),'avoid':dedupe(f),'sensitivity':d};}function scoreMove(a,b,c){const d=resolveArbInterests(b,c),e=a['gain']['filter'](j=>d['prefer']['includes'](j)),f=a['risk']['filter'](j=>d['avoid']['includes'](j)),g=e['length']*0x14,h=Math['round'](f['length']*0x19*d['sensitivity']),i=Math['max'](0x0,Math['min'](0x64,0x3c+g-h));return{'favorability':i,'gain_score':g,'risk_score':h};}export function evaluateArbGame(a,b,c){const d=ARB_MOVE_SEMANTICS[a]??[],e=d['filter'](g=>g['perspective']==='all'||g['perspective']===b),f=e['map'](g=>{const h=scoreMove(g,b,c);return{'action':g['action'],'favorability':h['favorability'],'gain_score':h['gain_score'],'risk_score':h['risk_score'],'is_optimal':![],'payoff_note':g['payoff'],'risk':g['base_risk']};})['sort']((g,h)=>h['favorability']-g['favorability']);return f['length']>0x0&&(f[0x0]['is_optimal']=!![]),{'status':a,'perspective':b,'actions':f,'summary':f['length']===0x0?'No\x20recommended\x20moves\x20for\x20'+b+'\x20in\x20status\x20\x27'+a+'\x27':'Optimal\x20for\x20'+b+'\x20in\x20\x27'+a+'\x27:\x20\x27'+f[0x0]['action']+'\x27\x20('+f[0x0]['payoff_note']+')'};}