@wowok/agent-mcp 2.7.1 → 2.7.3

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 (597) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/account-events.d.ts +32 -0
  4. package/dist/customer/account-events.js +1 -0
  5. package/dist/customer/customer-advice.d.ts +1 -0
  6. package/dist/customer/customer-advice.js +1 -130
  7. package/dist/customer/index.js +1 -11
  8. package/dist/customer/industry-risks.js +1 -438
  9. package/dist/customer/info-puzzle.js +1 -681
  10. package/dist/customer/order-monitor.js +1 -328
  11. package/dist/customer/order-strategy.d.ts +1 -1
  12. package/dist/customer/order-strategy.js +1 -373
  13. package/dist/customer/post-purchase.js +1 -351
  14. package/dist/customer/preorder-compare.js +1 -34
  15. package/dist/customer/reminder-system.d.ts +2 -0
  16. package/dist/customer/reminder-system.js +1 -316
  17. package/dist/customer/risk-assessment.d.ts +1 -0
  18. package/dist/customer/risk-assessment.js +1 -397
  19. package/dist/customer/types.d.ts +2 -0
  20. package/dist/customer/types.js +1 -13
  21. package/dist/customer/user-preferences.js +1 -460
  22. package/dist/evaluation/arbitration-game.d.ts +9 -2
  23. package/dist/evaluation/arbitration-game.js +1 -48
  24. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  25. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  26. package/dist/evaluation/builtins/demand-match.js +1 -153
  27. package/dist/evaluation/builtins/index.d.ts +1 -0
  28. package/dist/evaluation/builtins/index.js +1 -10
  29. package/dist/evaluation/builtins/service-risk.js +1 -55
  30. package/dist/evaluation/capability.js +1 -13
  31. package/dist/evaluation/category-match-rules.d.ts +30 -0
  32. package/dist/evaluation/category-match-rules.js +1 -0
  33. package/dist/evaluation/composer.js +1 -40
  34. package/dist/evaluation/engine.js +1 -175
  35. package/dist/evaluation/extract.js +1 -115
  36. package/dist/evaluation/game-strategy.d.ts +27 -0
  37. package/dist/evaluation/game-strategy.js +1 -0
  38. package/dist/evaluation/gap.js +1 -100
  39. package/dist/evaluation/index.d.ts +2 -0
  40. package/dist/evaluation/index.js +1 -11
  41. package/dist/evaluation/location-match.d.ts +42 -0
  42. package/dist/evaluation/location-match.js +1 -0
  43. package/dist/evaluation/node-game.d.ts +31 -3
  44. package/dist/evaluation/node-game.js +1 -57
  45. package/dist/evaluation/path-reasoning.d.ts +35 -0
  46. package/dist/evaluation/path-reasoning.js +1 -0
  47. package/dist/evaluation/region.d.ts +6 -0
  48. package/dist/evaluation/region.js +1 -36
  49. package/dist/evaluation/types.d.ts +18 -0
  50. package/dist/evaluation/types.js +1 -1
  51. package/dist/evaluation/user-injection.js +1 -27
  52. package/dist/experience/experience-reuse.js +1 -103
  53. package/dist/experience/index.js +1 -5
  54. package/dist/experience/intent-distill.js +1 -83
  55. package/dist/experience/realtime-feedback.js +1 -94
  56. package/dist/experience/types.js +1 -1
  57. package/dist/experience/user-profile.d.ts +1 -1
  58. package/dist/experience/user-profile.js +1 -171
  59. package/dist/extensions/business-modules.js +1 -287
  60. package/dist/extensions/capability-manifest.js +1 -781
  61. package/dist/extensions/constraint-registry.js +1 -198
  62. package/dist/extensions/index.d.ts +6 -0
  63. package/dist/extensions/index.js +1 -6
  64. package/dist/extensions/industry-layers.d.ts +75 -0
  65. package/dist/extensions/industry-layers.js +1 -0
  66. package/dist/extensions/industry-pack.d.ts +105 -0
  67. package/dist/extensions/industry-pack.js +1 -0
  68. package/dist/extensions/metric-registry.js +1 -257
  69. package/dist/extensions/mode-evaluator.d.ts +1 -1
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.d.ts +1 -0
  73. package/dist/extensions/registry.js +1 -717
  74. package/dist/extensions/types.js +1 -1
  75. package/dist/graph/base.d.ts +8 -0
  76. package/dist/graph/base.js +1 -0
  77. package/dist/harness/auto-escalation.js +1 -68
  78. package/dist/harness/checkpoint.js +1 -129
  79. package/dist/harness/index.d.ts +1 -0
  80. package/dist/harness/index.js +1 -78
  81. package/dist/harness/plan.d.ts +2 -0
  82. package/dist/harness/plan.js +1 -315
  83. package/dist/harness/recover.d.ts +1 -1
  84. package/dist/harness/recover.js +1 -139
  85. package/dist/harness/types.d.ts +2 -3
  86. package/dist/harness/types.js +1 -1
  87. package/dist/harness/verify.js +1 -237
  88. package/dist/index.js +1 -273
  89. package/dist/intent/enrich.js +1 -67
  90. package/dist/intent/index.js +1 -60
  91. package/dist/intent/matcher.js +1 -81
  92. package/dist/intent/store.js +1 -55
  93. package/dist/intent/types.js +1 -10
  94. package/dist/knowledge/acquisition-flywheel.js +1 -192
  95. package/dist/knowledge/allocation-confirm.js +1 -534
  96. package/dist/knowledge/allocation-context.js +1 -249
  97. package/dist/knowledge/allocation-ledger.js +1 -463
  98. package/dist/knowledge/allocation-puzzle.js +1 -298
  99. package/dist/knowledge/allocation-risk.js +1 -568
  100. package/dist/knowledge/allocation-templates.js +1 -970
  101. package/dist/knowledge/allocation-translation.js +1 -585
  102. package/dist/knowledge/anti-cheat.d.ts +37 -0
  103. package/dist/knowledge/anti-cheat.js +1 -0
  104. package/dist/knowledge/arb-confirm.d.ts +28 -0
  105. package/dist/knowledge/arb-confirm.js +1 -0
  106. package/dist/knowledge/arb-risk.js +1 -210
  107. package/dist/knowledge/arb-translation.d.ts +48 -0
  108. package/dist/knowledge/arb-translation.js +1 -0
  109. package/dist/knowledge/arbitration-confirm.js +1 -559
  110. package/dist/knowledge/arbitration-context.js +1 -505
  111. package/dist/knowledge/arbitration-ledger.js +1 -521
  112. package/dist/knowledge/arbitration-puzzle.js +1 -304
  113. package/dist/knowledge/arbitration-risk.js +1 -423
  114. package/dist/knowledge/arbitration-templates.js +1 -276
  115. package/dist/knowledge/arbitration-translation.js +1 -487
  116. package/dist/knowledge/audit-rules.js +1 -141
  117. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  118. package/dist/knowledge/bridge-confirm.js +1 -0
  119. package/dist/knowledge/bridge-risk.js +1 -263
  120. package/dist/knowledge/bridge-translation.d.ts +37 -0
  121. package/dist/knowledge/bridge-translation.js +1 -0
  122. package/dist/knowledge/contact-confirm.d.ts +27 -0
  123. package/dist/knowledge/contact-confirm.js +1 -0
  124. package/dist/knowledge/contact-risk.js +1 -200
  125. package/dist/knowledge/contact-templates.js +1 -60
  126. package/dist/knowledge/contact-translation.d.ts +39 -0
  127. package/dist/knowledge/contact-translation.js +1 -0
  128. package/dist/knowledge/demand-confirm.js +1 -206
  129. package/dist/knowledge/demand-context.d.ts +17 -0
  130. package/dist/knowledge/demand-context.js +1 -0
  131. package/dist/knowledge/demand-ledger.d.ts +26 -0
  132. package/dist/knowledge/demand-ledger.js +1 -0
  133. package/dist/knowledge/demand-matching.js +1 -132
  134. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  135. package/dist/knowledge/demand-puzzle.js +1 -0
  136. package/dist/knowledge/demand-risk.js +1 -240
  137. package/dist/knowledge/demand-templates.d.ts +12 -0
  138. package/dist/knowledge/demand-templates.js +1 -0
  139. package/dist/knowledge/demand-translation.js +1 -354
  140. package/dist/knowledge/deployment-scanner.js +1 -823
  141. package/dist/knowledge/dynamic-pricing.js +1 -87
  142. package/dist/knowledge/evidence-review.d.ts +12 -0
  143. package/dist/knowledge/evidence-review.js +1 -0
  144. package/dist/knowledge/examples-scanner-cli.js +1 -26
  145. package/dist/knowledge/examples-scanner.js +1 -843
  146. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  147. package/dist/knowledge/flywheel-loop.js +1 -404
  148. package/dist/knowledge/fund-layer.js +1 -973
  149. package/dist/knowledge/glossary.js +1 -211
  150. package/dist/knowledge/guard-confirm.js +1 -406
  151. package/dist/knowledge/guard-context.js +1 -287
  152. package/dist/knowledge/guard-design-patterns.js +1 -360
  153. package/dist/knowledge/guard-ledger.js +1 -260
  154. package/dist/knowledge/guard-lint.js +1 -670
  155. package/dist/knowledge/guard-migration.d.ts +1 -1
  156. package/dist/knowledge/guard-migration.js +1 -228
  157. package/dist/knowledge/guard-puzzle.js +1 -805
  158. package/dist/knowledge/guard-render.js +1 -700
  159. package/dist/knowledge/guard-risk.js +1 -1879
  160. package/dist/knowledge/guard-submission-prompt.js +1 -171
  161. package/dist/knowledge/guard-templates.js +1 -1105
  162. package/dist/knowledge/guard-translation.js +1 -1119
  163. package/dist/knowledge/index.d.ts +71 -3
  164. package/dist/knowledge/index.js +1 -436
  165. package/dist/knowledge/industry-evolution.js +1 -323
  166. package/dist/knowledge/industry-generalizer.js +1 -381
  167. package/dist/knowledge/industry-registry.js +1 -174
  168. package/dist/knowledge/intent-metrics.d.ts +4 -3
  169. package/dist/knowledge/intent-metrics.js +1 -566
  170. package/dist/knowledge/machine-confirm.js +1 -559
  171. package/dist/knowledge/machine-context.js +1 -833
  172. package/dist/knowledge/machine-ledger.js +1 -338
  173. package/dist/knowledge/machine-puzzle.js +1 -494
  174. package/dist/knowledge/machine-render.js +1 -565
  175. package/dist/knowledge/machine-risk.js +1 -669
  176. package/dist/knowledge/machine-templates.js +1 -1597
  177. package/dist/knowledge/machine-topology.js +1 -234
  178. package/dist/knowledge/machine-translation.js +1 -513
  179. package/dist/knowledge/market-metrics.d.ts +12 -0
  180. package/dist/knowledge/market-metrics.js +1 -0
  181. package/dist/knowledge/market-operations.d.ts +46 -0
  182. package/dist/knowledge/market-operations.js +1 -0
  183. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  184. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  185. package/dist/knowledge/mcp-schema-audit.js +1 -777
  186. package/dist/knowledge/onchain-constants.js +1 -35
  187. package/dist/knowledge/order-confirm.js +1 -573
  188. package/dist/knowledge/order-context.js +1 -390
  189. package/dist/knowledge/order-ledger.js +1 -341
  190. package/dist/knowledge/order-puzzle.js +1 -255
  191. package/dist/knowledge/order-risk.js +1 -653
  192. package/dist/knowledge/order-templates.js +1 -368
  193. package/dist/knowledge/order-translation.js +1 -550
  194. package/dist/knowledge/overrides-loader.js +1 -65
  195. package/dist/knowledge/passport-confirm.js +1 -531
  196. package/dist/knowledge/passport-context.js +1 -306
  197. package/dist/knowledge/passport-ledger.js +1 -282
  198. package/dist/knowledge/passport-puzzle.js +1 -333
  199. package/dist/knowledge/passport-risk.js +1 -450
  200. package/dist/knowledge/passport-templates.js +1 -568
  201. package/dist/knowledge/passport-translation.js +1 -516
  202. package/dist/knowledge/payment-confirm.d.ts +26 -0
  203. package/dist/knowledge/payment-confirm.js +1 -0
  204. package/dist/knowledge/payment-risk.js +1 -249
  205. package/dist/knowledge/payment-translation.d.ts +37 -0
  206. package/dist/knowledge/payment-translation.js +1 -0
  207. package/dist/knowledge/permission-confirm.js +1 -426
  208. package/dist/knowledge/permission-context.js +1 -224
  209. package/dist/knowledge/permission-ledger.d.ts +11 -0
  210. package/dist/knowledge/permission-ledger.js +1 -403
  211. package/dist/knowledge/permission-puzzle.js +1 -173
  212. package/dist/knowledge/permission-risk.js +1 -411
  213. package/dist/knowledge/permission-templates.js +1 -234
  214. package/dist/knowledge/permission-translation.js +1 -350
  215. package/dist/knowledge/personal-confirm.d.ts +29 -0
  216. package/dist/knowledge/personal-confirm.js +1 -0
  217. package/dist/knowledge/personal-risk.js +1 -212
  218. package/dist/knowledge/personal-translation.d.ts +37 -0
  219. package/dist/knowledge/personal-translation.js +1 -0
  220. package/dist/knowledge/process-model.d.ts +1 -11
  221. package/dist/knowledge/process-model.js +1 -160
  222. package/dist/knowledge/progress-confirm.js +1 -456
  223. package/dist/knowledge/progress-context.js +1 -452
  224. package/dist/knowledge/progress-ledger.js +1 -330
  225. package/dist/knowledge/progress-puzzle.js +1 -219
  226. package/dist/knowledge/progress-risk.js +1 -461
  227. package/dist/knowledge/progress-templates.js +1 -228
  228. package/dist/knowledge/progress-translation.js +1 -405
  229. package/dist/knowledge/proof-confirm.js +1 -187
  230. package/dist/knowledge/proof-context.d.ts +17 -0
  231. package/dist/knowledge/proof-context.js +1 -0
  232. package/dist/knowledge/proof-ledger.d.ts +34 -0
  233. package/dist/knowledge/proof-ledger.js +1 -0
  234. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  235. package/dist/knowledge/proof-puzzle.js +1 -0
  236. package/dist/knowledge/proof-risk.js +1 -207
  237. package/dist/knowledge/proof-templates.d.ts +22 -0
  238. package/dist/knowledge/proof-templates.js +1 -0
  239. package/dist/knowledge/proof-translation.js +1 -283
  240. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  241. package/dist/knowledge/registrar-confirm.js +1 -0
  242. package/dist/knowledge/registrar-risk.js +1 -217
  243. package/dist/knowledge/registrar-translation.d.ts +37 -0
  244. package/dist/knowledge/registrar-translation.js +1 -0
  245. package/dist/knowledge/repository-confirm.js +1 -286
  246. package/dist/knowledge/repository-context.d.ts +12 -0
  247. package/dist/knowledge/repository-context.js +1 -0
  248. package/dist/knowledge/repository-ledger.d.ts +25 -0
  249. package/dist/knowledge/repository-ledger.js +1 -0
  250. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  251. package/dist/knowledge/repository-puzzle.js +1 -0
  252. package/dist/knowledge/repository-risk.js +1 -373
  253. package/dist/knowledge/repository-templates.d.ts +14 -0
  254. package/dist/knowledge/repository-templates.js +1 -0
  255. package/dist/knowledge/repository-translation.js +1 -445
  256. package/dist/knowledge/reputation-rules.js +1 -99
  257. package/dist/knowledge/resource-confirm.d.ts +25 -0
  258. package/dist/knowledge/resource-confirm.js +1 -0
  259. package/dist/knowledge/resource-risk.js +1 -157
  260. package/dist/knowledge/resource-translation.d.ts +37 -0
  261. package/dist/knowledge/resource-translation.js +1 -0
  262. package/dist/knowledge/reward-confirm.js +1 -526
  263. package/dist/knowledge/reward-context.d.ts +2 -2
  264. package/dist/knowledge/reward-context.js +1 -504
  265. package/dist/knowledge/reward-ledger.js +1 -502
  266. package/dist/knowledge/reward-puzzle.js +1 -300
  267. package/dist/knowledge/reward-risk.js +1 -627
  268. package/dist/knowledge/reward-templates.js +1 -197
  269. package/dist/knowledge/reward-translation.js +1 -501
  270. package/dist/knowledge/safety-rules.d.ts +1 -0
  271. package/dist/knowledge/safety-rules.js +1 -404
  272. package/dist/knowledge/scenario-modes.js +1 -321
  273. package/dist/knowledge/service-confirm.js +1 -807
  274. package/dist/knowledge/service-context.js +1 -403
  275. package/dist/knowledge/service-ledger.js +1 -609
  276. package/dist/knowledge/service-puzzle.js +1 -236
  277. package/dist/knowledge/service-risk.d.ts +1 -1
  278. package/dist/knowledge/service-risk.js +1 -651
  279. package/dist/knowledge/service-templates.js +1 -456
  280. package/dist/knowledge/service-translation.js +1 -622
  281. package/dist/knowledge/template-registry.js +1 -353
  282. package/dist/knowledge/tool-constraints.js +1 -195
  283. package/dist/knowledge/tools-reference.js +1 -178
  284. package/dist/knowledge/treasury-confirm.js +1 -512
  285. package/dist/knowledge/treasury-context.js +1 -363
  286. package/dist/knowledge/treasury-ledger.js +1 -300
  287. package/dist/knowledge/treasury-puzzle.js +1 -216
  288. package/dist/knowledge/treasury-risk.js +1 -440
  289. package/dist/knowledge/treasury-templates.js +1 -358
  290. package/dist/knowledge/treasury-translation.js +1 -498
  291. package/dist/knowledge/trust-metrics.js +1 -198
  292. package/dist/knowledge/universal-template.d.ts +22 -0
  293. package/dist/knowledge/universal-template.js +1 -0
  294. package/dist/knowledge/util-confirm.d.ts +24 -0
  295. package/dist/knowledge/util-confirm.js +1 -0
  296. package/dist/knowledge/util-risk.js +1 -135
  297. package/dist/knowledge/util-translation.d.ts +38 -0
  298. package/dist/knowledge/util-translation.js +1 -0
  299. package/dist/knowledge/workflow-guidance.d.ts +116 -0
  300. package/dist/knowledge/workflow-guidance.js +1 -0
  301. package/dist/loop-engineering/aggregate.js +1 -132
  302. package/dist/loop-engineering/context-collect.js +1 -83
  303. package/dist/loop-engineering/diagnose.js +1 -273
  304. package/dist/loop-engineering/improve.js +1 -405
  305. package/dist/loop-engineering/index.js +1 -4
  306. package/dist/loop-engineering/pipeline.js +1 -56
  307. package/dist/mode-market/index.js +1 -3
  308. package/dist/mode-market/registry.js +1 -124
  309. package/dist/mode-market/review.js +1 -214
  310. package/dist/mode-market/submission.js +1 -85
  311. package/dist/participation/collaborator-interest.d.ts +23 -0
  312. package/dist/participation/collaborator-interest.js +1 -0
  313. package/dist/participation/customer-interest.d.ts +25 -0
  314. package/dist/participation/customer-interest.js +1 -0
  315. package/dist/participation/employee-kpi.d.ts +25 -0
  316. package/dist/participation/employee-kpi.js +1 -0
  317. package/dist/participation/employee-store.d.ts +16 -0
  318. package/dist/participation/employee-store.js +1 -0
  319. package/dist/participation/index.d.ts +2 -0
  320. package/dist/participation/index.js +1 -0
  321. package/dist/participation/merchant-interest.js +1 -100
  322. package/dist/participation/radar-core.d.ts +13 -3
  323. package/dist/participation/radar-core.js +1 -269
  324. package/dist/participation/supplier-interest.d.ts +25 -0
  325. package/dist/participation/supplier-interest.js +1 -0
  326. package/dist/persona/analyzer.js +1 -66
  327. package/dist/persona/bridge.js +1 -86
  328. package/dist/persona/defaults.js +1 -195
  329. package/dist/persona/experience-bridge.js +1 -23
  330. package/dist/persona/index.d.ts +9 -2
  331. package/dist/persona/index.js +1 -71
  332. package/dist/persona/local-region.d.ts +20 -0
  333. package/dist/persona/local-region.js +1 -0
  334. package/dist/persona/model.js +1 -111
  335. package/dist/persona/overrides.d.ts +10 -0
  336. package/dist/persona/overrides.js +1 -0
  337. package/dist/persona/pack-personae.d.ts +11 -0
  338. package/dist/persona/pack-personae.js +1 -0
  339. package/dist/persona/store.js +1 -62
  340. package/dist/persona/strategy-intent.d.ts +20 -0
  341. package/dist/persona/strategy-intent.js +1 -0
  342. package/dist/persona/types.d.ts +6 -2
  343. package/dist/persona/types.js +1 -5
  344. package/dist/project/business-puzzle.d.ts +1 -1
  345. package/dist/project/business-puzzle.js +1 -383
  346. package/dist/project/context-assembly.js +1 -254
  347. package/dist/project/deployment-bridge.js +1 -120
  348. package/dist/project/deployment-doc.js +1 -1126
  349. package/dist/project/edit-planner.js +1 -1342
  350. package/dist/project/evaluation.d.ts +37 -1
  351. package/dist/project/evaluation.js +1 -2011
  352. package/dist/project/game-theory.js +1 -177
  353. package/dist/project/graph-builder.js +1 -656
  354. package/dist/project/graph.d.ts +3 -6
  355. package/dist/project/graph.js +1 -340
  356. package/dist/project/handlers.d.ts +33 -2
  357. package/dist/project/handlers.js +1 -1784
  358. package/dist/project/index.d.ts +2 -0
  359. package/dist/project/index.js +1 -301
  360. package/dist/project/intent-analyzer.js +1 -149
  361. package/dist/project/machine-nodes.js +1 -36
  362. package/dist/project/merchant-guide.d.ts +19 -0
  363. package/dist/project/merchant-guide.js +1 -264
  364. package/dist/project/migration.js +1 -125
  365. package/dist/project/mode-actions.js +1 -309
  366. package/dist/project/namespace.js +1 -206
  367. package/dist/project/participation-radar.js +1 -428
  368. package/dist/project/pipeline-actions.js +1 -109
  369. package/dist/project/project-store.js +1 -422
  370. package/dist/project/query.js +1 -153
  371. package/dist/project/reverse-mapping.d.ts +34 -0
  372. package/dist/project/reverse-mapping.js +1 -0
  373. package/dist/project/risk-aggregator.js +1 -295
  374. package/dist/project/rollback-policy.js +1 -290
  375. package/dist/project/semantic-assembler.js +1 -345
  376. package/dist/project/semantic-graph.d.ts +3 -5
  377. package/dist/project/semantic-graph.js +1 -292
  378. package/dist/project/stage-gate.js +1 -369
  379. package/dist/project/substep-trace.js +1 -332
  380. package/dist/project/task-tracker.js +1 -78
  381. package/dist/project/workflow-design-assessment.d.ts +24 -0
  382. package/dist/project/workflow-design-assessment.js +1 -0
  383. package/dist/role/derivation.d.ts +18 -0
  384. package/dist/role/derivation.js +1 -0
  385. package/dist/role/index.d.ts +5 -0
  386. package/dist/role/index.js +1 -0
  387. package/dist/role/model.d.ts +8 -0
  388. package/dist/role/model.js +1 -0
  389. package/dist/role/resolution.d.ts +11 -0
  390. package/dist/role/resolution.js +1 -0
  391. package/dist/role/types.d.ts +11 -0
  392. package/dist/role/types.js +1 -0
  393. package/dist/rules.js +1 -52
  394. package/dist/safety/confirm-gate.d.ts +1 -1
  395. package/dist/safety/confirm-gate.js +1 -88
  396. package/dist/safety/index.js +1 -3
  397. package/dist/safety/preview.js +1 -52
  398. package/dist/schema/call/allocation.d.ts +186 -1385
  399. package/dist/schema/call/allocation.js +1 -34
  400. package/dist/schema/call/arbitration.d.ts +272 -1871
  401. package/dist/schema/call/arbitration.js +1 -113
  402. package/dist/schema/call/base.d.ts +1831 -9076
  403. package/dist/schema/call/base.js +1 -370
  404. package/dist/schema/call/bridge.d.ts +911 -3171
  405. package/dist/schema/call/bridge.js +1 -458
  406. package/dist/schema/call/contact.d.ts +135 -931
  407. package/dist/schema/call/contact.js +1 -37
  408. package/dist/schema/call/demand.d.ts +164 -1194
  409. package/dist/schema/call/demand.js +1 -47
  410. package/dist/schema/call/guard.d.ts +298 -1140
  411. package/dist/schema/call/guard.js +1 -161
  412. package/dist/schema/call/handler.js +1 -322
  413. package/dist/schema/call/index.js +1 -20
  414. package/dist/schema/call/machine.d.ts +459 -5403
  415. package/dist/schema/call/machine.js +1 -193
  416. package/dist/schema/call/order.d.ts +137 -844
  417. package/dist/schema/call/order.js +1 -35
  418. package/dist/schema/call/payment.d.ts +74 -561
  419. package/dist/schema/call/payment.js +1 -37
  420. package/dist/schema/call/permission-handler.js +1 -54
  421. package/dist/schema/call/permission.d.ts +335 -2791
  422. package/dist/schema/call/permission.js +1 -105
  423. package/dist/schema/call/personal.d.ts +227 -1814
  424. package/dist/schema/call/personal.js +1 -78
  425. package/dist/schema/call/progress.d.ts +140 -843
  426. package/dist/schema/call/progress.js +1 -47
  427. package/dist/schema/call/proof.d.ts +42 -258
  428. package/dist/schema/call/proof.js +1 -33
  429. package/dist/schema/call/repository.d.ts +324 -2222
  430. package/dist/schema/call/repository.js +1 -77
  431. package/dist/schema/call/reward.d.ts +153 -1183
  432. package/dist/schema/call/reward.js +1 -30
  433. package/dist/schema/call/semantic.js +1 -1679
  434. package/dist/schema/call/service.d.ts +376 -3431
  435. package/dist/schema/call/service.js +1 -184
  436. package/dist/schema/call/treasury.d.ts +252 -2158
  437. package/dist/schema/call/treasury.js +1 -71
  438. package/dist/schema/common/index.d.ts +222 -697
  439. package/dist/schema/common/index.js +1 -407
  440. package/dist/schema/config/index.d.ts +18 -161
  441. package/dist/schema/config/index.js +1 -68
  442. package/dist/schema/employee/index.d.ts +99 -0
  443. package/dist/schema/employee/index.js +1 -0
  444. package/dist/schema/evaluation/index.d.ts +1062 -3748
  445. package/dist/schema/evaluation/index.js +1 -356
  446. package/dist/schema/index.d.ts +3 -0
  447. package/dist/schema/index.js +1 -17
  448. package/dist/schema/industry-pack/index.d.ts +132 -0
  449. package/dist/schema/industry-pack/index.js +1 -0
  450. package/dist/schema/intent-radar/index.d.ts +92 -245
  451. package/dist/schema/intent-radar/index.js +1 -89
  452. package/dist/schema/local/index.d.ts +2045 -18080
  453. package/dist/schema/local/index.js +1 -927
  454. package/dist/schema/local/wip.d.ts +61 -651
  455. package/dist/schema/local/wip.js +1 -187
  456. package/dist/schema/messenger/index.d.ts +949 -5557
  457. package/dist/schema/messenger/index.js +1 -475
  458. package/dist/schema/operations.d.ts +2969 -26518
  459. package/dist/schema/operations.js +1 -520
  460. package/dist/schema/persona/index.d.ts +469 -1820
  461. package/dist/schema/persona/index.js +1 -148
  462. package/dist/schema/project/index.d.ts +1027 -8408
  463. package/dist/schema/project/index.js +1 -2057
  464. package/dist/schema/query/index.d.ts +12041 -75261
  465. package/dist/schema/query/index.js +1 -1646
  466. package/dist/schema/schema-query/index.d.ts +35 -98
  467. package/dist/schema/schema-query/index.js +1 -104
  468. package/dist/schema/schema-version.js +1 -76
  469. package/dist/schema/task-status.d.ts +26 -132
  470. package/dist/schema/task-status.js +1 -36
  471. package/dist/schema/trust/index.d.ts +194 -1290
  472. package/dist/schema/trust/index.js +1 -314
  473. package/dist/schema/utils/guard-parser.js +1 -419
  474. package/dist/schema/utils/guard-query-utils.js +1 -46
  475. package/dist/schema/utils/node-parser.js +1 -369
  476. package/dist/schema/utils/object-type-utils.js +1 -35
  477. package/dist/schema/utils/permission-index-utils.js +1 -7
  478. package/dist/schema/utils/permission-machine-check.js +1 -121
  479. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  480. package/dist/schema/utils/skills-recommendation.js +1 -77
  481. package/dist/schema/workspace/index.d.ts +69 -0
  482. package/dist/schema/workspace/index.js +1 -0
  483. package/dist/schema-query-impl/index.js +1 -0
  484. package/dist/schemas/account_operation.output.json +3147 -1652
  485. package/dist/schemas/account_operation.schema.json +225 -218
  486. package/dist/schemas/bridge_operation.output.json +1168 -650
  487. package/dist/schemas/bridge_operation.schema.json +736 -504
  488. package/dist/schemas/config_operation.output.json +185 -179
  489. package/dist/schemas/config_operation.schema.json +21 -26
  490. package/dist/schemas/employee_operation.output.json +207 -0
  491. package/dist/schemas/employee_operation.schema.json +176 -0
  492. package/dist/schemas/evaluation_operation.output.json +2329 -557
  493. package/dist/schemas/evaluation_operation.schema.json +2939 -720
  494. package/dist/schemas/guard2file.output.json +58 -64
  495. package/dist/schemas/guard2file.schema.json +79 -81
  496. package/dist/schemas/index.json +29 -11
  497. package/dist/schemas/industry_pack_operation.output.json +594 -0
  498. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  499. package/dist/schemas/intent_radar.output.json +275 -200
  500. package/dist/schemas/intent_radar.schema.json +124 -123
  501. package/dist/schemas/local_info_operation.output.json +1174 -657
  502. package/dist/schemas/local_info_operation.schema.json +119 -125
  503. package/dist/schemas/local_mark_operation.output.json +1239 -689
  504. package/dist/schemas/local_mark_operation.schema.json +91 -96
  505. package/dist/schemas/machineNode2file.output.json +63 -69
  506. package/dist/schemas/machineNode2file.schema.json +79 -81
  507. package/dist/schemas/messenger_operation.output.json +2722 -1528
  508. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  509. package/dist/schemas/onchain_events.output.json +2590 -975
  510. package/dist/schemas/onchain_events.schema.json +117 -99
  511. package/dist/schemas/onchain_operations.output.json +3957 -2309
  512. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  513. package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
  514. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  515. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  516. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  517. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  518. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  519. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  520. package/dist/schemas/onchain_operations_machine.schema.json +537 -164
  521. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  522. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  523. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  524. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  525. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  526. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  527. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  528. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  529. package/dist/schemas/onchain_operations_service.schema.json +679 -221
  530. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  531. package/dist/schemas/onchain_table_data.output.json +6018 -2430
  532. package/dist/schemas/onchain_table_data.schema.json +544 -430
  533. package/dist/schemas/persona_operation.output.json +1568 -265
  534. package/dist/schemas/persona_operation.schema.json +346 -202
  535. package/dist/schemas/project_operation.output.json +6957 -5147
  536. package/dist/schemas/project_operation.schema.json +1050 -1020
  537. package/dist/schemas/query_task_status.output.json +195 -99
  538. package/dist/schemas/query_task_status.schema.json +12 -18
  539. package/dist/schemas/query_toolkit.output.json +18870 -14566
  540. package/dist/schemas/query_toolkit.schema.json +614 -522
  541. package/dist/schemas/schema_query.output.json +127 -129
  542. package/dist/schemas/schema_query.schema.json +64 -69
  543. package/dist/schemas/trust_score.output.json +678 -587
  544. package/dist/schemas/trust_score.schema.json +289 -277
  545. package/dist/schemas/wip_file.output.json +116 -124
  546. package/dist/schemas/wip_file.schema.json +142 -143
  547. package/dist/schemas/workspace_operation.output.json +277 -0
  548. package/dist/schemas/workspace_operation.schema.json +45 -0
  549. package/dist/schemas/wowok_buildin_info.output.json +1693 -723
  550. package/dist/schemas/wowok_buildin_info.schema.json +576 -512
  551. package/dist/telemetry/index.js +1 -112
  552. package/dist/telemetry/redact.js +1 -23
  553. package/dist/telemetry/storage.js +1 -80
  554. package/dist/tools/handlers/bridge.d.ts +8 -1
  555. package/dist/tools/handlers/bridge.js +1 -1
  556. package/dist/tools/handlers/config.js +1 -74
  557. package/dist/tools/handlers/employee.d.ts +2 -0
  558. package/dist/tools/handlers/employee.js +1 -0
  559. package/dist/tools/handlers/evaluation.js +1 -123
  560. package/dist/tools/handlers/file-export.js +1 -90
  561. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  562. package/dist/tools/handlers/industry-pack.js +1 -0
  563. package/dist/tools/handlers/intent-radar.js +1 -76
  564. package/dist/tools/handlers/local.js +1 -53
  565. package/dist/tools/handlers/messenger.js +1 -188
  566. package/dist/tools/handlers/onchain.js +1 -1180
  567. package/dist/tools/handlers/persona.js +1 -89
  568. package/dist/tools/handlers/project.js +1 -211
  569. package/dist/tools/handlers/query.js +1 -434
  570. package/dist/tools/handlers/schema-query.js +1 -176
  571. package/dist/tools/handlers/task-status.js +1 -26
  572. package/dist/tools/handlers/trust.js +1 -380
  573. package/dist/tools/handlers/wip.js +1 -90
  574. package/dist/tools/handlers/workspace.d.ts +2 -0
  575. package/dist/tools/handlers/workspace.js +1 -0
  576. package/dist/tools/index.d.ts +2 -1
  577. package/dist/tools/index.js +1 -1382
  578. package/dist/tools/retry.js +1 -85
  579. package/dist/tools/rules-hook.d.ts +1 -1
  580. package/dist/tools/rules-hook.js +1 -23
  581. package/dist/tools/shared.d.ts +1 -1
  582. package/dist/tools/shared.js +1 -130
  583. package/dist/tools/types.d.ts +2 -1
  584. package/dist/tools/types.js +1 -1
  585. package/dist/tools/upgrade-check.d.ts +19 -0
  586. package/dist/tools/upgrade-check.js +1 -0
  587. package/dist/tools/wip-deploy-assist.js +1 -306
  588. package/dist/tools/wrap.js +1 -500
  589. package/package.json +7 -6
  590. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  591. package/dist/knowledge/arbitration-trust.js +0 -117
  592. package/dist/schema/call/bridge-handler.d.ts +0 -8
  593. package/dist/schema/call/bridge-handler.js +0 -265
  594. package/dist/schema/sync-layer4.d.ts +0 -21
  595. package/dist/schema/sync-layer4.js +0 -286
  596. package/dist/schema-query/index.js +0 -810
  597. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -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']+')'};}
@@ -0,0 +1,41 @@
1
+ import type { EvaluationResult, UserInjection } from "../types.js";
2
+ export declare const ARBITRATION_TRUST_EVALUATION = "arbitration_trust";
3
+ export declare const ARBITRATION_FAIRNESS_EVALUATION = "arbitration_fairness";
4
+ export interface ArbitrationConfigInput {
5
+ object?: string;
6
+ fee?: number | bigint | string;
7
+ balance?: number | bigint | string;
8
+ voting_guard_count?: number;
9
+ bPaused?: boolean;
10
+ location?: string;
11
+ has_verified_identity?: boolean;
12
+ }
13
+ export interface ArbCaseInput {
14
+ status?: number | string;
15
+ time?: number;
16
+ resolved_time?: number;
17
+ indemnity_amount?: number | bigint | string;
18
+ feedback_positive?: boolean;
19
+ objected?: boolean;
20
+ customer?: string;
21
+ merchant?: string;
22
+ }
23
+ export interface EntityReputationInput {
24
+ like_ratio?: number;
25
+ affiliation?: boolean;
26
+ }
27
+ export interface ArbitrationScoreInput {
28
+ arbitration: ArbitrationConfigInput;
29
+ history?: ArbCaseInput[];
30
+ entity_votes?: EntityReputationInput;
31
+ fee_median?: number | bigint | string;
32
+ }
33
+ export interface ArbitrationScoreResult {
34
+ trust: EvaluationResult;
35
+ fairness: EvaluationResult;
36
+ combined: number;
37
+ summary: string;
38
+ cold_start?: boolean;
39
+ }
40
+ export declare function registerArbitrationScoreEvaluation(engine?: import("../engine.js").EvaluationEngine): void;
41
+ export declare function assessArbitration(input: ArbitrationScoreInput, injection?: UserInjection): Promise<ArbitrationScoreResult>;
@@ -0,0 +1 @@
1
+ import{MAX_VOTING_GUARD_COUNT}from'@wowok/wowok';import{getEvaluationEngine}from'../engine.js';export const ARBITRATION_TRUST_EVALUATION='arbitration_trust';export const ARBITRATION_FAIRNESS_EVALUATION='arbitration_fairness';function toBigInt(a){if(a===undefined||a===null)return undefined;try{return BigInt(a);}catch{return undefined;}}function clamp01(a){return Math['max'](0x0,Math['min'](0x1,a));}const dsArbitration={'id':'ds_arbitration','description':'Aggregate\x20Arbitration\x20config\x20+\x20historical\x20Arb\x20cases\x20into\x20scoring\x20facts','evaluation_ids':[ARBITRATION_TRUST_EVALUATION,ARBITRATION_FAIRNESS_EVALUATION],'extract':a=>{const b=a['entities']['arbitration']??{},c=a['entities']['history']??[],d=a['entities']['entity_votes'],e=a['entities']['fee_median'],f=c['length'],g=c['filter'](n=>n['objected'])['length'],h=c['filter'](n=>(toBigInt(n['indemnity_amount'])??0x0n)>0x0n)['length'],i=c['filter'](n=>n['feedback_positive'])['length'],j=c['filter'](n=>n['time']&&n['resolved_time']&&n['resolved_time']>n['time']),k=j['filter'](n=>(toBigInt(n['indemnity_amount'])??0x0n)>0x0n)['length'],l=j['length']?k/j['length']:undefined,m=j['length']?j['reduce']((n,o)=>n+(o['resolved_time']-o['time'])/0x5265c00,0x0)/j['length']:undefined;return{'fee':toBigInt(b['fee']),'balance':toBigInt(b['balance']),'voting_guard_count':b['voting_guard_count']??0x0,'paused':b['bPaused']===!![],'fee_median':toBigInt(e),'case_count':f,'objection_rate':f?g/f:0x0,'indemnity_rate':f?h/f:0x0,'feedback_rate':f?i/f:0x0,'avg_resolution_days':m,'resolved_case_count':j['length'],'customer_favor_rate':l,'like_ratio':clamp01(d?.['like_ratio']??0.5),'affiliation':d?.['affiliation']===!![],'identity_known':b['has_verified_identity']!==undefined,'verified_identity':b['has_verified_identity']===!![]};}},trustTimeliness={'id':'trust_timeliness','description':'Average\x20dispute\x20resolution\x20speed','dimension':'trust','weight':0xa,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['avg_resolution_days'];if(b===undefined)return{'score':0x32,'weight':0xa,'reason':'no\x20resolved\x20cases\x20(neutral)'};const c=b<=0x1?0x64:b<=0x3?0x55:b<=0x7?0x3c:b<=0xe?0x1e:0x0;return{'score':c,'weight':0xa,'reason':'avg\x20'+b['toFixed'](0x1)+'\x20days'};}},trustObjection={'id':'trust_objection','description':'Objection\x20rate\x20(contested\x20as\x20unfair)','dimension':'trust','weight':0x14,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['objection_rate'],c=Math['round']((0x1-b)*0x64);return{'score':c,'weight':0x14,'reason':(b*0x64)['toFixed'](0x0)+'%\x20objected'};}},trustIndemnity={'id':'trust_indemnity','description':'Indemnity\x20payout\x20rate\x20(willingness\x20to\x20compensate)','dimension':'trust','weight':0x14,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['indemnity_rate'];if(a['facts']['case_count']===0x0)return{'score':0x32,'weight':0x14,'reason':'no\x20cases\x20(neutral)'};return{'score':Math['round'](b*0x64),'weight':0x14,'reason':(b*0x64)['toFixed'](0x0)+'%\x20paid\x20indemnity'};}},trustFeedback={'id':'trust_feedback','description':'Positive\x20feedback\x20rate','dimension':'trust','weight':0xa,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['feedback_rate'];if(a['facts']['case_count']===0x0)return{'score':0x32,'weight':0xa,'reason':'no\x20feedback\x20(neutral)'};return{'score':Math['round'](b*0x64),'weight':0xa,'reason':(b*0x64)['toFixed'](0x0)+'%\x20positive\x20feedback'};}},trustIdentity={'id':'trust_identity','description':'Verified\x20on-chain\x20identity\x20(Personal\x20object)','dimension':'trust','weight':0xa,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['identity_known'],c=a['facts']['verified_identity'];if(!b)return{'score':0x32,'weight':0xa,'reason':'identity\x20status\x20unknown\x20(neutral)'};if(c)return{'score':0x64,'weight':0xa,'reason':'verified\x20on-chain\x20Personal\x20identity'};return{'score':0x0,'weight':0xa,'reason':'no\x20verified\x20on-chain\x20identity\x20(anonymous\x20arbitrator)','red_flag':!![]};}},trustExperience={'id':'trust_experience','description':'Handled\x20case\x20count\x20(experience)','dimension':'trust','weight':0xa,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['case_count'],c=b>=0x14?0x64:b>=0xa?0x50:b>=0x5?0x3c:b>=0x1?0x28:0x0;return{'score':c,'weight':0xa,'reason':b+'\x20case(s)'};}},trustCapital={'id':'trust_capital','description':'Capital\x20pool\x20(ability\x20to\x20pay\x20out)','dimension':'trust','weight':0x14,'evaluation_ids':[ARBITRATION_TRUST_EVALUATION],'evaluate':a=>{const b=a['facts']['balance'];if(b===undefined)return{'score':0x1e,'weight':0x14,'reason':'no\x20balance\x20data\x20(weak)'};if(b<=0x0n)return{'score':0x0,'weight':0x14,'reason':'empty\x20capital\x20pool'};const c=b>=0xe8d4a51000n?0x64:b>=0x174876e800n?0x50:b>=0x3b9aca00n?0x3c:0x28;return{'score':c,'weight':0x14,'reason':'capital\x20'+b};}},fairnessFee={'id':'fairness_fee','description':'Fee\x20reasonableness\x20vs\x20market\x20median','dimension':'fairness','weight':0x1e,'evaluation_ids':[ARBITRATION_FAIRNESS_EVALUATION],'evaluate':a=>{const b=a['facts']['fee'],c=a['facts']['fee_median'];if(b===undefined)return{'score':0x32,'weight':0x1e,'reason':'no\x20fee\x20set\x20(neutral)'};if(c===undefined||c<=0x0n)return{'score':0x32,'weight':0x1e,'reason':'no\x20market\x20median\x20reference\x20(neutral)'};const d=Number(b*0x64n/c)/0x64,e=d<=0x1?0x64:d<=1.5?0x4b:d<=0x2?0x32:d<=0x3?0x19:0x0;return{'score':e,'weight':0x1e,'reason':'fee\x20'+d['toFixed'](0x2)+'x\x20median'};}},fairnessImpartiality={'id':'fairness_impartiality','description':'Indemnity-direction\x20skew\x20(systematic\x20bias\x20toward\x20customer\x20vs\x20merchant)','dimension':'fairness','weight':0x19,'evaluation_ids':[ARBITRATION_FAIRNESS_EVALUATION],'evaluate':a=>{const b=a['facts']['resolved_case_count'],c=a['facts']['customer_favor_rate'];if(c===undefined||b<0x3)return{'score':0x32,'weight':0x19,'reason':'insufficient\x20resolved\x20cases\x20(neutral)'};const d=c<=0.1||c>=0.9?0x14:c<=0.25||c>=0.75?0x3c:0x64;return{'score':d,'weight':0x19,'reason':(c*0x64)['toFixed'](0x0)+'%\x20favour\x20customer\x20('+b+'\x20resolved)'};}},fairnessGovernance={'id':'fairness_governance','description':'Voting-guard\x20distribution\x20(decentralized,\x20hard\x20to\x20manipulate)','dimension':'fairness','weight':0x28,'evaluation_ids':[ARBITRATION_FAIRNESS_EVALUATION],'evaluate':a=>{const b=a['facts']['voting_guard_count'],c=b>=0x5?0x64:b>=0x3?0x50:b>=0x2?0x3c:b>=0x1?0x28:0x0;return{'score':c,'weight':0x28,'reason':b+'\x20voting\x20guard(s),\x20on-chain\x20cap\x20'+MAX_VOTING_GUARD_COUNT};}},fairnessOperational={'id':'fairness_operational','description':'Operational\x20status\x20(not\x20paused,\x20has\x20capital)','dimension':'fairness','weight':0x1e,'evaluation_ids':[ARBITRATION_FAIRNESS_EVALUATION],'evaluate':a=>{const b=a['facts']['paused'],c=a['facts']['balance'];if(b)return{'score':0x0,'weight':0x1e,'reason':'paused','red_flag':!![]};if(c===undefined||c<=0x0n)return{'score':0x1e,'weight':0x1e,'reason':'no\x20capital\x20(operational\x20risk)'};return{'score':0x64,'weight':0x1e,'reason':'operational'};}},TRUST_RULES=[trustTimeliness,trustObjection,trustIndemnity,trustFeedback,trustExperience,trustCapital,trustIdentity],FAIRNESS_RULES=[fairnessFee,fairnessImpartiality,fairnessGovernance,fairnessOperational];export function registerArbitrationScoreEvaluation(a=getEvaluationEngine()){a['registerDataSource'](dsArbitration);for(const b of[...TRUST_RULES,...FAIRNESS_RULES]){a['registerRule'](b);}}export async function assessArbitration(a,b){const c=getEvaluationEngine(),d={'arbitration':a['arbitration'],'history':a['history']??[],'entity_votes':a['entity_votes'],'fee_median':a['fee_median']},[e,f]=await Promise['all']([c['evaluate'](ARBITRATION_TRUST_EVALUATION,d,b),c['evaluate'](ARBITRATION_FAIRNESS_EVALUATION,d,b)]),g=Math['round']((e['total']+f['total'])/0x2),h=!a['history']||a['history']['length']===0x0;return{'trust':e,'fairness':f,'combined':g,'cold_start':h,'summary':h?'cold\x20start\x20(no\x20history)\x20—\x20trust\x20'+e['total']+'/100\x20·\x20fairness\x20'+f['total']+'/100\x20·\x20combined\x20'+g+'/100':'trust\x20'+e['total']+'/100\x20·\x20fairness\x20'+f['total']+'/100\x20·\x20combined\x20'+g+'/100'};}