@wowok/agent-mcp 2.7.2 โ†’ 2.7.4

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 (383) hide show
  1. package/dist/config/runtime.js +1 -1
  2. package/dist/customer/account-events.d.ts +32 -0
  3. package/dist/customer/account-events.js +1 -0
  4. package/dist/customer/customer-advice.d.ts +1 -0
  5. package/dist/customer/customer-advice.js +1 -1
  6. package/dist/customer/info-puzzle.js +1 -1
  7. package/dist/customer/order-strategy.d.ts +1 -1
  8. package/dist/customer/reminder-system.d.ts +2 -0
  9. package/dist/customer/reminder-system.js +1 -1
  10. package/dist/customer/risk-assessment.d.ts +1 -0
  11. package/dist/customer/risk-assessment.js +1 -1
  12. package/dist/customer/types.d.ts +2 -0
  13. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  14. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  15. package/dist/evaluation/builtins/index.d.ts +1 -0
  16. package/dist/evaluation/builtins/index.js +1 -1
  17. package/dist/evaluation/category-match-rules.d.ts +30 -0
  18. package/dist/evaluation/category-match-rules.js +1 -0
  19. package/dist/evaluation/engine.js +1 -1
  20. package/dist/evaluation/extract.js +1 -1
  21. package/dist/evaluation/index.d.ts +1 -0
  22. package/dist/evaluation/index.js +1 -1
  23. package/dist/evaluation/location-match.d.ts +42 -0
  24. package/dist/evaluation/location-match.js +1 -0
  25. package/dist/evaluation/path-reasoning.d.ts +35 -0
  26. package/dist/evaluation/path-reasoning.js +1 -0
  27. package/dist/evaluation/region.d.ts +6 -0
  28. package/dist/evaluation/region.js +1 -1
  29. package/dist/evaluation/types.d.ts +17 -0
  30. package/dist/experience/realtime-feedback.js +1 -1
  31. package/dist/experience/user-profile.d.ts +1 -1
  32. package/dist/extensions/index.d.ts +6 -0
  33. package/dist/extensions/index.js +1 -1
  34. package/dist/extensions/industry-layers.d.ts +75 -0
  35. package/dist/extensions/industry-layers.js +1 -0
  36. package/dist/extensions/industry-pack.d.ts +105 -0
  37. package/dist/extensions/industry-pack.js +1 -0
  38. package/dist/extensions/metric-registry.js +1 -1
  39. package/dist/extensions/mode-evaluator.d.ts +1 -1
  40. package/dist/extensions/registry.d.ts +1 -0
  41. package/dist/extensions/registry.js +1 -1
  42. package/dist/graph/base.d.ts +8 -0
  43. package/dist/graph/base.js +1 -0
  44. package/dist/harness/index.d.ts +1 -0
  45. package/dist/harness/index.js +1 -1
  46. package/dist/harness/plan.d.ts +2 -0
  47. package/dist/harness/plan.js +1 -1
  48. package/dist/harness/recover.d.ts +1 -1
  49. package/dist/harness/types.d.ts +2 -3
  50. package/dist/index.js +1 -1
  51. package/dist/knowledge/allocation-confirm.js +1 -1
  52. package/dist/knowledge/anti-cheat.d.ts +37 -0
  53. package/dist/knowledge/anti-cheat.js +1 -0
  54. package/dist/knowledge/arb-confirm.d.ts +28 -0
  55. package/dist/knowledge/arb-confirm.js +1 -0
  56. package/dist/knowledge/arb-translation.d.ts +48 -0
  57. package/dist/knowledge/arb-translation.js +1 -0
  58. package/dist/knowledge/arbitration-context.js +1 -1
  59. package/dist/knowledge/arbitration-ledger.js +1 -1
  60. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  61. package/dist/knowledge/bridge-confirm.js +1 -0
  62. package/dist/knowledge/bridge-translation.d.ts +37 -0
  63. package/dist/knowledge/bridge-translation.js +1 -0
  64. package/dist/knowledge/contact-confirm.d.ts +27 -0
  65. package/dist/knowledge/contact-confirm.js +1 -0
  66. package/dist/knowledge/contact-translation.d.ts +39 -0
  67. package/dist/knowledge/contact-translation.js +1 -0
  68. package/dist/knowledge/demand-confirm.js +1 -1
  69. package/dist/knowledge/demand-context.d.ts +17 -0
  70. package/dist/knowledge/demand-context.js +1 -0
  71. package/dist/knowledge/demand-ledger.d.ts +26 -0
  72. package/dist/knowledge/demand-ledger.js +1 -0
  73. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  74. package/dist/knowledge/demand-puzzle.js +1 -0
  75. package/dist/knowledge/demand-risk.js +1 -1
  76. package/dist/knowledge/demand-templates.d.ts +12 -0
  77. package/dist/knowledge/demand-templates.js +1 -0
  78. package/dist/knowledge/demand-translation.js +1 -1
  79. package/dist/knowledge/deployment-scanner.js +1 -1
  80. package/dist/knowledge/evidence-review.d.ts +12 -0
  81. package/dist/knowledge/evidence-review.js +1 -0
  82. package/dist/knowledge/examples-scanner-cli.js +1 -1
  83. package/dist/knowledge/examples-scanner.js +1 -1
  84. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  85. package/dist/knowledge/flywheel-loop.js +1 -1
  86. package/dist/knowledge/guard-design-patterns.js +1 -1
  87. package/dist/knowledge/guard-migration.d.ts +1 -1
  88. package/dist/knowledge/index.d.ts +71 -3
  89. package/dist/knowledge/index.js +1 -1
  90. package/dist/knowledge/industry-registry.js +1 -1
  91. package/dist/knowledge/machine-render.js +1 -1
  92. package/dist/knowledge/market-metrics.d.ts +12 -0
  93. package/dist/knowledge/market-metrics.js +1 -0
  94. package/dist/knowledge/market-operations.d.ts +46 -0
  95. package/dist/knowledge/market-operations.js +1 -0
  96. package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
  97. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  98. package/dist/knowledge/mcp-schema-audit.js +1 -1
  99. package/dist/knowledge/onchain-constants.d.ts +2 -2
  100. package/dist/knowledge/onchain-constants.js +1 -1
  101. package/dist/knowledge/payment-confirm.d.ts +26 -0
  102. package/dist/knowledge/payment-confirm.js +1 -0
  103. package/dist/knowledge/payment-risk.js +1 -1
  104. package/dist/knowledge/payment-translation.d.ts +37 -0
  105. package/dist/knowledge/payment-translation.js +1 -0
  106. package/dist/knowledge/permission-context.d.ts +11 -0
  107. package/dist/knowledge/permission-context.js +1 -1
  108. package/dist/knowledge/permission-ledger.d.ts +11 -0
  109. package/dist/knowledge/permission-ledger.js +1 -1
  110. package/dist/knowledge/personal-confirm.d.ts +29 -0
  111. package/dist/knowledge/personal-confirm.js +1 -0
  112. package/dist/knowledge/personal-risk.js +1 -1
  113. package/dist/knowledge/personal-translation.d.ts +37 -0
  114. package/dist/knowledge/personal-translation.js +1 -0
  115. package/dist/knowledge/process-model.d.ts +1 -11
  116. package/dist/knowledge/process-model.js +1 -1
  117. package/dist/knowledge/progress-ledger.js +1 -1
  118. package/dist/knowledge/progress-risk.js +1 -1
  119. package/dist/knowledge/progress-templates.js +1 -1
  120. package/dist/knowledge/progress-translation.js +1 -1
  121. package/dist/knowledge/proof-context.d.ts +17 -0
  122. package/dist/knowledge/proof-context.js +1 -0
  123. package/dist/knowledge/proof-ledger.d.ts +34 -0
  124. package/dist/knowledge/proof-ledger.js +1 -0
  125. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  126. package/dist/knowledge/proof-puzzle.js +1 -0
  127. package/dist/knowledge/proof-templates.d.ts +22 -0
  128. package/dist/knowledge/proof-templates.js +1 -0
  129. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  130. package/dist/knowledge/registrar-confirm.js +1 -0
  131. package/dist/knowledge/registrar-risk.js +1 -1
  132. package/dist/knowledge/registrar-translation.d.ts +37 -0
  133. package/dist/knowledge/registrar-translation.js +1 -0
  134. package/dist/knowledge/repository-context.d.ts +12 -0
  135. package/dist/knowledge/repository-context.js +1 -0
  136. package/dist/knowledge/repository-ledger.d.ts +25 -0
  137. package/dist/knowledge/repository-ledger.js +1 -0
  138. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  139. package/dist/knowledge/repository-puzzle.js +1 -0
  140. package/dist/knowledge/repository-templates.d.ts +14 -0
  141. package/dist/knowledge/repository-templates.js +1 -0
  142. package/dist/knowledge/resource-confirm.d.ts +25 -0
  143. package/dist/knowledge/resource-confirm.js +1 -0
  144. package/dist/knowledge/resource-translation.d.ts +37 -0
  145. package/dist/knowledge/resource-translation.js +1 -0
  146. package/dist/knowledge/reward-context.d.ts +2 -2
  147. package/dist/knowledge/reward-ledger.js +1 -1
  148. package/dist/knowledge/reward-translation.js +1 -1
  149. package/dist/knowledge/safety-rules.d.ts +1 -0
  150. package/dist/knowledge/safety-rules.js +1 -1
  151. package/dist/knowledge/service-risk.d.ts +1 -1
  152. package/dist/knowledge/service-risk.js +1 -1
  153. package/dist/knowledge/template-registry.js +1 -1
  154. package/dist/knowledge/tools-reference.js +1 -1
  155. package/dist/knowledge/treasury-context.d.ts +1 -1
  156. package/dist/knowledge/treasury-context.js +1 -1
  157. package/dist/knowledge/treasury-ledger.js +1 -1
  158. package/dist/knowledge/treasury-risk.js +1 -1
  159. package/dist/knowledge/universal-template.d.ts +22 -0
  160. package/dist/knowledge/universal-template.js +1 -0
  161. package/dist/knowledge/util-confirm.d.ts +24 -0
  162. package/dist/knowledge/util-confirm.js +1 -0
  163. package/dist/knowledge/util-risk.js +1 -1
  164. package/dist/knowledge/util-translation.d.ts +39 -0
  165. package/dist/knowledge/util-translation.js +1 -0
  166. package/dist/knowledge/workflow-guidance.d.ts +180 -0
  167. package/dist/knowledge/workflow-guidance.js +1 -0
  168. package/dist/participation/employee-kpi.d.ts +25 -0
  169. package/dist/participation/employee-kpi.js +1 -0
  170. package/dist/participation/employee-store.d.ts +16 -0
  171. package/dist/participation/employee-store.js +1 -0
  172. package/dist/participation/index.d.ts +2 -0
  173. package/dist/participation/index.js +1 -0
  174. package/dist/persona/defaults.js +1 -1
  175. package/dist/persona/index.d.ts +9 -2
  176. package/dist/persona/index.js +1 -1
  177. package/dist/persona/local-region.d.ts +20 -0
  178. package/dist/persona/local-region.js +1 -0
  179. package/dist/persona/model.js +1 -1
  180. package/dist/persona/overrides.d.ts +10 -0
  181. package/dist/persona/overrides.js +1 -0
  182. package/dist/persona/pack-personae.d.ts +11 -0
  183. package/dist/persona/pack-personae.js +1 -0
  184. package/dist/persona/strategy-intent.d.ts +20 -0
  185. package/dist/persona/strategy-intent.js +1 -0
  186. package/dist/persona/types.d.ts +3 -1
  187. package/dist/project/business-puzzle.d.ts +1 -1
  188. package/dist/project/business-puzzle.js +1 -1
  189. package/dist/project/deployment-doc.js +1 -1
  190. package/dist/project/edit-planner.js +1 -1
  191. package/dist/project/evaluation.d.ts +37 -1
  192. package/dist/project/evaluation.js +1 -1
  193. package/dist/project/graph-builder.d.ts +2 -2
  194. package/dist/project/graph-builder.js +1 -1
  195. package/dist/project/graph.d.ts +3 -6
  196. package/dist/project/handlers.d.ts +33 -2
  197. package/dist/project/handlers.js +1 -1
  198. package/dist/project/index.d.ts +1 -0
  199. package/dist/project/index.js +1 -1
  200. package/dist/project/merchant-guide.d.ts +19 -0
  201. package/dist/project/merchant-guide.js +1 -1
  202. package/dist/project/mode-actions.js +1 -1
  203. package/dist/project/rollback-policy.js +1 -1
  204. package/dist/project/semantic-assembler.d.ts +2 -2
  205. package/dist/project/semantic-assembler.js +1 -1
  206. package/dist/project/semantic-graph.d.ts +3 -5
  207. package/dist/project/workflow-design-assessment.d.ts +24 -0
  208. package/dist/project/workflow-design-assessment.js +1 -0
  209. package/dist/safety/confirm-gate.d.ts +1 -1
  210. package/dist/safety/confirm-gate.js +1 -1
  211. package/dist/schema/call/allocation.d.ts +186 -1385
  212. package/dist/schema/call/arbitration.d.ts +272 -1871
  213. package/dist/schema/call/base.d.ts +1831 -9076
  214. package/dist/schema/call/base.js +1 -1
  215. package/dist/schema/call/bridge.d.ts +911 -3171
  216. package/dist/schema/call/contact.d.ts +135 -931
  217. package/dist/schema/call/demand.d.ts +164 -1194
  218. package/dist/schema/call/guard.d.ts +298 -1140
  219. package/dist/schema/call/guard.js +1 -1
  220. package/dist/schema/call/machine.d.ts +459 -5403
  221. package/dist/schema/call/machine.js +1 -1
  222. package/dist/schema/call/order.d.ts +137 -844
  223. package/dist/schema/call/payment.d.ts +74 -561
  224. package/dist/schema/call/permission.d.ts +335 -2791
  225. package/dist/schema/call/personal.d.ts +227 -1814
  226. package/dist/schema/call/progress.d.ts +140 -843
  227. package/dist/schema/call/proof.d.ts +42 -258
  228. package/dist/schema/call/repository.d.ts +324 -2222
  229. package/dist/schema/call/reward.d.ts +153 -1183
  230. package/dist/schema/call/semantic.js +1 -1
  231. package/dist/schema/call/service.d.ts +376 -3431
  232. package/dist/schema/call/treasury.d.ts +252 -2158
  233. package/dist/schema/common/index.d.ts +222 -697
  234. package/dist/schema/common/index.js +1 -1
  235. package/dist/schema/config/index.d.ts +18 -161
  236. package/dist/schema/employee/index.d.ts +99 -0
  237. package/dist/schema/employee/index.js +1 -0
  238. package/dist/schema/evaluation/index.d.ts +1035 -3918
  239. package/dist/schema/evaluation/index.js +1 -1
  240. package/dist/schema/index.d.ts +5 -0
  241. package/dist/schema/index.js +1 -1
  242. package/dist/schema/industry-pack/index.d.ts +132 -0
  243. package/dist/schema/industry-pack/index.js +1 -0
  244. package/dist/schema/intent-radar/index.d.ts +92 -245
  245. package/dist/schema/intent-radar/index.js +1 -1
  246. package/dist/schema/local/index.d.ts +2045 -18080
  247. package/dist/schema/local/index.js +1 -1
  248. package/dist/schema/local/wip.d.ts +61 -651
  249. package/dist/schema/local/wip.js +1 -1
  250. package/dist/schema/messenger/index.d.ts +949 -5557
  251. package/dist/schema/messenger/index.js +1 -1
  252. package/dist/schema/operations.d.ts +3168 -26468
  253. package/dist/schema/operations.js +1 -1
  254. package/dist/schema/permission/index.d.ts +121 -0
  255. package/dist/schema/permission/index.js +1 -0
  256. package/dist/schema/persona/index.d.ts +469 -1820
  257. package/dist/schema/persona/index.js +1 -1
  258. package/dist/schema/project/index.d.ts +1023 -8450
  259. package/dist/schema/project/index.js +1 -1
  260. package/dist/schema/query/index.d.ts +12121 -75556
  261. package/dist/schema/query/index.js +1 -1
  262. package/dist/schema/schema-query/index.d.ts +35 -98
  263. package/dist/schema/schema-query/index.js +1 -1
  264. package/dist/schema/schema-version.js +1 -1
  265. package/dist/schema/task-status.d.ts +26 -132
  266. package/dist/schema/trust/index.d.ts +194 -1290
  267. package/dist/schema/utils/guard-parser.js +1 -1
  268. package/dist/schema/utils/node-parser.js +1 -1
  269. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  270. package/dist/schema/utils/skills-recommendation.js +1 -1
  271. package/dist/schema/workflow/index.d.ts +161 -0
  272. package/dist/schema/workflow/index.js +1 -0
  273. package/dist/schema/workspace/index.d.ts +69 -0
  274. package/dist/schema/workspace/index.js +1 -0
  275. package/dist/{schema-query โ†’ schema-query-impl}/index.js +1 -1
  276. package/dist/schemas/account_operation.output.json +3147 -1655
  277. package/dist/schemas/account_operation.schema.json +225 -218
  278. package/dist/schemas/bridge_operation.output.json +1168 -653
  279. package/dist/schemas/bridge_operation.schema.json +736 -504
  280. package/dist/schemas/config_operation.output.json +185 -179
  281. package/dist/schemas/config_operation.schema.json +21 -26
  282. package/dist/schemas/employee_operation.output.json +207 -0
  283. package/dist/schemas/employee_operation.schema.json +176 -0
  284. package/dist/schemas/evaluation_operation.output.json +2268 -601
  285. package/dist/schemas/evaluation_operation.schema.json +2919 -787
  286. package/dist/schemas/guard2file.output.json +58 -64
  287. package/dist/schemas/guard2file.schema.json +79 -81
  288. package/dist/schemas/index.json +41 -11
  289. package/dist/schemas/industry_pack_operation.output.json +594 -0
  290. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  291. package/dist/schemas/intent_radar.output.json +275 -203
  292. package/dist/schemas/intent_radar.schema.json +124 -126
  293. package/dist/schemas/local_info_operation.output.json +1174 -660
  294. package/dist/schemas/local_info_operation.schema.json +119 -125
  295. package/dist/schemas/local_mark_operation.output.json +1239 -692
  296. package/dist/schemas/local_mark_operation.schema.json +91 -96
  297. package/dist/schemas/machineNode2file.output.json +63 -69
  298. package/dist/schemas/machineNode2file.schema.json +79 -81
  299. package/dist/schemas/messenger_operation.output.json +2722 -1531
  300. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  301. package/dist/schemas/onchain_events.output.json +2590 -978
  302. package/dist/schemas/onchain_events.schema.json +117 -99
  303. package/dist/schemas/onchain_operations.output.json +3957 -2312
  304. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  305. package/dist/schemas/onchain_operations_allocation.schema.json +171 -107
  306. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  307. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  308. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  309. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  310. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  311. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  312. package/dist/schemas/onchain_operations_machine.schema.json +536 -163
  313. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  314. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  315. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  316. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  317. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  318. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  319. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  320. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  321. package/dist/schemas/onchain_operations_service.schema.json +678 -220
  322. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  323. package/dist/schemas/onchain_table_data.output.json +6833 -2432
  324. package/dist/schemas/onchain_table_data.schema.json +684 -417
  325. package/dist/schemas/permission_operation.output.json +173 -0
  326. package/dist/schemas/permission_operation.schema.json +39 -0
  327. package/dist/schemas/persona_operation.output.json +1568 -268
  328. package/dist/schemas/persona_operation.schema.json +346 -205
  329. package/dist/schemas/project_operation.output.json +6922 -5132
  330. package/dist/schemas/project_operation.schema.json +1050 -1020
  331. package/dist/schemas/query_task_status.output.json +195 -99
  332. package/dist/schemas/query_task_status.schema.json +12 -18
  333. package/dist/schemas/query_toolkit.output.json +18862 -14561
  334. package/dist/schemas/query_toolkit.schema.json +614 -522
  335. package/dist/schemas/schema_query.output.json +127 -129
  336. package/dist/schemas/schema_query.schema.json +64 -69
  337. package/dist/schemas/trust_score.output.json +678 -587
  338. package/dist/schemas/trust_score.schema.json +289 -277
  339. package/dist/schemas/wip_file.output.json +116 -124
  340. package/dist/schemas/wip_file.schema.json +142 -143
  341. package/dist/schemas/workflow_operation.output.json +164 -0
  342. package/dist/schemas/workflow_operation.schema.json +116 -0
  343. package/dist/schemas/workspace_operation.output.json +277 -0
  344. package/dist/schemas/workspace_operation.schema.json +45 -0
  345. package/dist/schemas/wowok_buildin_info.output.json +1682 -844
  346. package/dist/schemas/wowok_buildin_info.schema.json +576 -526
  347. package/dist/tools/handlers/bridge.d.ts +8 -1
  348. package/dist/tools/handlers/bridge.js +1 -1
  349. package/dist/tools/handlers/config.js +1 -1
  350. package/dist/tools/handlers/employee.d.ts +2 -0
  351. package/dist/tools/handlers/employee.js +1 -0
  352. package/dist/tools/handlers/evaluation.js +1 -1
  353. package/dist/tools/handlers/file-export.js +1 -1
  354. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  355. package/dist/tools/handlers/industry-pack.js +1 -0
  356. package/dist/tools/handlers/onchain.js +1 -1
  357. package/dist/tools/handlers/permission.d.ts +2 -0
  358. package/dist/tools/handlers/permission.js +1 -0
  359. package/dist/tools/handlers/persona.js +1 -1
  360. package/dist/tools/handlers/project.js +1 -1
  361. package/dist/tools/handlers/query.js +1 -1
  362. package/dist/tools/handlers/schema-query.js +1 -1
  363. package/dist/tools/handlers/trust.js +1 -1
  364. package/dist/tools/handlers/wip.js +1 -1
  365. package/dist/tools/handlers/workflow.d.ts +2 -0
  366. package/dist/tools/handlers/workflow.js +1 -0
  367. package/dist/tools/handlers/workspace.d.ts +4 -0
  368. package/dist/tools/handlers/workspace.js +1 -0
  369. package/dist/tools/index.d.ts +2 -1
  370. package/dist/tools/index.js +1 -1
  371. package/dist/tools/rules-hook.d.ts +1 -1
  372. package/dist/tools/rules-hook.js +1 -1
  373. package/dist/tools/shared.d.ts +1 -1
  374. package/dist/tools/shared.js +1 -1
  375. package/dist/tools/types.d.ts +2 -1
  376. package/package.json +4 -5
  377. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  378. package/dist/knowledge/arbitration-trust.js +0 -1
  379. package/dist/schema/call/bridge-handler.d.ts +0 -8
  380. package/dist/schema/call/bridge-handler.js +0 -1
  381. package/dist/schema/sync-layer4.d.ts +0 -21
  382. package/dist/schema/sync-layer4.js +0 -1
  383. /package/dist/{schema-query โ†’ schema-query-impl}/index.d.ts +0 -0
@@ -1 +1 @@
1
- import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';export const SERVICE_REGISTRY=[{'name':'confirm_gate','description':'Security\x20confirmation\x20gate\x20โ€”\x20prompts\x20user\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CONFIRM_GATE','remindOnToggle':!![]},{'name':'project_service','description':'Project\x20namespace\x20+\x20object\x20dependency\x20graph\x20โ€”\x20auto-injects\x20project:/type:\x20tags,\x20maintains\x20DAG','defaultEnabled':!![],'envVar':'WOWOK_PROJECT_SERVICE','remindOnToggle':!![]},{'name':'harness','description':'L4\x20Harness\x20verify/recover\x20loop\x20โ€”\x20automatically\x20validates\x20expected\x20results\x20before\x20and\x20after\x20operations.\x20GLM5:\x20default\x20ON\x20with\x20tiered\x20enforcement\x20(off/lightweight/full).','defaultEnabled':!![],'envVar':'WOWOK_HARNESS_ENABLED','remindOnToggle':!![]},{'name':'graph_persist','description':'Object\x20graph\x20persistence\x20โ€”\x20saves\x20in-memory\x20DAG\x20to\x20local\x20file,\x20retained\x20across\x20sessions','defaultEnabled':![],'envVar':'WOWOK_GRAPH_PERSIST','remindOnToggle':!![]},{'name':'semantic_rich','description':'Semantic\x20layer\x20enrichment\x20โ€”\x20attaches\x20extra\x20reminder\x20info\x20such\x20as\x20service_status\x20in\x20responses','defaultEnabled':!![],'envVar':'WOWOK_SEMANTIC_RICH','remindOnToggle':![]},{'name':'experience_layer','description':'Real-time\x20experience\x20layer\x20โ€”\x20intent\x20distillation\x20+\x20user\x20profiling\x20+\x20experience\x20reuse,\x20gets\x20smarter\x20with\x20usage','defaultEnabled':!![],'envVar':'WOWOK_EXPERIENCE_LAYER','remindOnToggle':!![]},{'name':'customer_intelligence','description':'Buyer\x20intelligence\x20(Phase\x203\x20C-3)\x20โ€”\x20attaches\x20risk\x20reminders,\x20preference\x20matching,\x20and\x20blocking\x20alerts\x20in\x20semantic.customer_advice\x20for\x20order/query\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CUSTOMER_INTELLIGENCE','remindOnToggle':!![]},{'name':'order_monitor','description':'In-progress\x20order\x20monitoring\x20(Phase\x203\x20C-3.2)\x20โ€”\x20detects\x20Progress\x20stalls\x20/\x20compensation\x20balance\x20changes\x20/\x20Messenger\x20timeouts;\x20disabled\x20by\x20default,\x20must\x20be\x20actively\x20enabled','defaultEnabled':![],'envVar':'WOWOK_ORDER_MONITOR','remindOnToggle':!![]},{'name':'industry_evolution','description':'Industry\x20specialization\x20evolution\x20(Phase\x204)\x20โ€”\x20AI-Human-WOW\x20flywheel\x20loop:\x20captures\x20industry\x20signals\x20+\x20updates\x20knowledge\x20+\x20injects\x20evolution\x20context','defaultEnabled':!![],'envVar':'WOWOK_INDUSTRY_EVOLUTION','remindOnToggle':!![]}];const SERVICE_MAP=new Map(SERVICE_REGISTRY['map'](a=>[a['name'],a])),runtimeOverrides=new Map();let harnessTierOverride;function configFilePath(){return join(getWowMcpDir(),'runtime-config.json');}function isPersistEnabled(){const a=process['env']['WOWOK_RUNTIME_CONFIG_PERSIST'];return a==='1'||a==='true';}function loadPersisted(){if(!isPersistEnabled())return null;try{const a=configFilePath();if(!existsSync(a))return null;const b=readFileSync(a,'utf-8'),c=JSON['parse'](b);if(c&&typeof c==='object'&&c['services'])return c;}catch{}return null;}function savePersisted(){if(!isPersistEnabled())return;try{const a=configFilePath(),b=dirname(a);if(!existsSync(b))mkdirSync(b,{'recursive':!![]});const c={'version':0x2,'services':Object['fromEntries'](runtimeOverrides),'harness_tier':harnessTierOverride,'updatedAt':Date['now']()};writeFileSync(a,JSON['stringify'](c,null,0x2),'utf-8');}catch{}}{const persisted=loadPersisted();if(persisted){for(const [name,enabled]of Object['entries'](persisted['services'])){SERVICE_MAP['has'](name)&&runtimeOverrides['set'](name,enabled);}persisted['harness_tier']&&(harnessTierOverride=persisted['harness_tier']);}}export function getHarnessTier(){if(!isEnabled('harness'))return'off';if(harnessTierOverride)return harnessTierOverride;const a=process['env']['WOWOK_HARNESS_TIER'];if(a==='off'||a==='lightweight'||a==='full')return a;return'lightweight';}export function setHarnessTier(a){harnessTierOverride=a,savePersisted();}export function resetHarnessTier(){harnessTierOverride=undefined,savePersisted();}export function isEnabled(a){if(runtimeOverrides['has'](a))return runtimeOverrides['get'](a);const b=SERVICE_MAP['get'](a);if(b){const c=process['env'][b['envVar']];if(c!==undefined){if(c==='0'||c==='false')return![];if(c==='1'||c==='true')return!![];}return b['defaultEnabled'];}return![];}export function setEnabled(a,b){runtimeOverrides['set'](a,b),savePersisted();}export function toggle(a){const b=!isEnabled(a);return setEnabled(a,b),b;}export function reset(a){runtimeOverrides['delete'](a),savePersisted();}export function listServices(){return SERVICE_REGISTRY['map'](a=>{const b=runtimeOverrides['has'](a['name']),c=isEnabled(a['name']);return{'name':a['name'],'enabled':c,'defaultEnabled':a['defaultEnabled'],'description':a['description'],'overridden':b,'envVar':a['envVar'],'reminder':a['remindOnToggle']?buildReminder(a['name'],c):undefined};});}export function getServiceInfo(a){const b=SERVICE_MAP['get'](a);if(!b)return undefined;return{'name':b['name'],'enabled':isEnabled(b['name']),'defaultEnabled':b['defaultEnabled'],'description':b['description'],'overridden':runtimeOverrides['has'](b['name']),'envVar':b['envVar'],'reminder':b['remindOnToggle']?buildReminder(b['name'],isEnabled(b['name'])):undefined};}function buildReminder(a,b){switch(a){case'confirm_gate':return b?'ConfirmGate\x20is\x20ON:\x20prompts\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20confirm_gate.':'ConfirmGate\x20is\x20OFF:\x20operations\x20will\x20execute\x20directly\x20without\x20confirmation.\x20Note\x20the\x20risk\x20of\x20irreversible\x20operations.\x20To\x20re-enable,\x20call\x20config_operation\x20toggle\x20confirm_gate.';case'project_service':return b?'ProjectService\x20is\x20ON:\x20auto-injects\x20project:/type:\x20tags\x20on\x20object\x20creation\x20and\x20maintains\x20the\x20dependency\x20graph.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20project_service.':'ProjectService\x20is\x20OFF:\x20objects\x20will\x20not\x20be\x20automatically\x20tagged\x20with\x20project\x20membership.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20project_service.';case'harness':return b?'Harness\x20is\x20ON\x20(tier:\x20'+getHarnessTier()+'):\x20automatically\x20validates\x20expected\x20results\x20around\x20operations.\x20lightweight=Plan+Verify;\x20full=Plan+Expect+Verify+Recover+Checkpoint.\x20To\x20change\x20tier,\x20set\x20WOWOK_HARNESS_TIER\x20or\x20call\x20harness\x20API.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20harness.':'Harness\x20is\x20OFF.\x20GLM5\x20recommends\x20keeping\x20it\x20ON\x20(lightweight\x20tier)\x20for\x20safety.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20harness.';case'graph_persist':return b?'Graph\x20persistence\x20is\x20ON:\x20the\x20object\x20dependency\x20graph\x20will\x20be\x20saved\x20to\x20~/.wow/mcp/project-graph.json.':'Graph\x20persistence\x20is\x20OFF:\x20the\x20dependency\x20graph\x20exists\x20only\x20in\x20memory\x20and\x20will\x20be\x20lost\x20on\x20process\x20restart.\x20To\x20persist,\x20call\x20config_operation\x20toggle\x20graph_persist.';case'semantic_rich':return undefined;case'experience_layer':return b?'Experience\x20layer\x20is\x20ON:\x20provides\x20suggestions\x20in\x20semantic.experience\x20based\x20on\x20historical\x20operation\x20experience.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20experience_layer.':'Experience\x20layer\x20is\x20OFF:\x20no\x20experience\x20suggestions\x20will\x20be\x20attached.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20experience_layer.';case'customer_intelligence':return b?'Customer\x20intelligence\x20is\x20ON:\x20order/query\x20operations\x20will\x20attach\x20risk/preference/blocking\x20alerts\x20in\x20semantic.customer_advice.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.':'Customer\x20intelligence\x20is\x20OFF:\x20semantic.customer_advice\x20will\x20not\x20be\x20populated.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.';case'order_monitor':return b?'Order\x20monitor\x20is\x20ON:\x20detects\x20Progress\x20stalls,\x20compensation\x20balance\x20changes,\x20and\x20Messenger\x20timeouts.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20order_monitor.':'Order\x20monitor\x20is\x20OFF:\x20will\x20not\x20actively\x20detect\x20order\x20anomalies.\x20To\x20enable\x20(recommended\x20when\x20there\x20are\x20active\x20orders),\x20call\x20config_operation\x20toggle\x20order_monitor.';}}export const RUNTIME_CONFIG_VERSION=0x1;
1
+ import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';export const SERVICE_REGISTRY=[{'name':'confirm_gate','description':'Security\x20confirmation\x20gate\x20โ€”\x20prompts\x20user\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CONFIRM_GATE','remindOnToggle':!![]},{'name':'project_service','description':'Project\x20namespace\x20+\x20object\x20dependency\x20graph\x20โ€”\x20auto-injects\x20project:/type:\x20tags,\x20maintains\x20DAG','defaultEnabled':!![],'envVar':'WOWOK_PROJECT_SERVICE','remindOnToggle':!![]},{'name':'harness','description':'L4\x20Harness\x20verify/recover\x20loop\x20โ€”\x20automatically\x20validates\x20expected\x20results\x20before\x20and\x20after\x20operations.\x20GLM5:\x20default\x20ON\x20with\x20tiered\x20enforcement\x20(off/lightweight/full).','defaultEnabled':!![],'envVar':'WOWOK_HARNESS_ENABLED','remindOnToggle':!![]},{'name':'graph_persist','description':'Object\x20graph\x20persistence\x20โ€”\x20saves\x20in-memory\x20DAG\x20to\x20local\x20file,\x20retained\x20across\x20sessions','defaultEnabled':![],'envVar':'WOWOK_GRAPH_PERSIST','remindOnToggle':!![]},{'name':'semantic_rich','description':'Semantic\x20layer\x20enrichment\x20โ€”\x20attaches\x20extra\x20reminder\x20info\x20such\x20as\x20service_status\x20in\x20responses','defaultEnabled':!![],'envVar':'WOWOK_SEMANTIC_RICH','remindOnToggle':![]},{'name':'experience_layer','description':'Real-time\x20experience\x20layer\x20โ€”\x20intent\x20distillation\x20+\x20user\x20profiling\x20+\x20experience\x20reuse,\x20gets\x20smarter\x20with\x20usage','defaultEnabled':!![],'envVar':'WOWOK_EXPERIENCE_LAYER','remindOnToggle':!![]},{'name':'customer_intelligence','description':'Buyer\x20intelligence\x20(Phase\x203\x20C-3)\x20โ€”\x20attaches\x20risk\x20reminders,\x20preference\x20matching,\x20and\x20blocking\x20alerts\x20in\x20semantic.customer_advice\x20for\x20order/query\x20operations','defaultEnabled':!![],'envVar':'WOWOK_CUSTOMER_INTELLIGENCE','remindOnToggle':!![]},{'name':'order_monitor','description':'In-progress\x20order\x20monitoring\x20(Phase\x203\x20C-3.2)\x20โ€”\x20detects\x20Progress\x20stalls\x20/\x20compensation\x20balance\x20changes\x20/\x20Messenger\x20timeouts;\x20disabled\x20by\x20default,\x20must\x20be\x20actively\x20enabled','defaultEnabled':![],'envVar':'WOWOK_ORDER_MONITOR','remindOnToggle':!![]},{'name':'industry_evolution','description':'Industry\x20specialization\x20evolution\x20(Phase\x204)\x20โ€”\x20AI-Human-WOW\x20flywheel\x20loop:\x20captures\x20industry\x20signals\x20+\x20updates\x20knowledge\x20+\x20injects\x20evolution\x20context','defaultEnabled':!![],'envVar':'WOWOK_INDUSTRY_EVOLUTION','remindOnToggle':!![]}];const SERVICE_MAP=new Map(SERVICE_REGISTRY['map'](a=>[a['name'],a])),runtimeOverrides=new Map();let harnessTierOverride;function configFilePath(){if(process['env']['WOWOK_CONFIG_DIR'])return join(process['env']['WOWOK_CONFIG_DIR'],'runtime-config.json');return join(getWowMcpDir(),'runtime-config.json');}function isPersistEnabled(){const a=process['env']['WOWOK_RUNTIME_CONFIG_PERSIST'];return a==='1'||a==='true';}function loadPersisted(){if(!isPersistEnabled())return null;try{const a=configFilePath();if(!existsSync(a))return null;const b=readFileSync(a,'utf-8'),c=JSON['parse'](b);if(c&&typeof c==='object'&&c['services'])return c;}catch{}return null;}function savePersisted(){if(!isPersistEnabled())return;try{const a=configFilePath(),b=dirname(a);if(!existsSync(b))mkdirSync(b,{'recursive':!![]});const c={'version':0x2,'services':Object['fromEntries'](runtimeOverrides),'harness_tier':harnessTierOverride,'updatedAt':Date['now']()};writeFileSync(a,JSON['stringify'](c,null,0x2),'utf-8');}catch{}}{const persisted=loadPersisted();if(persisted){for(const [name,enabled]of Object['entries'](persisted['services'])){SERVICE_MAP['has'](name)&&runtimeOverrides['set'](name,enabled);}persisted['harness_tier']&&(harnessTierOverride=persisted['harness_tier']);}}export function getHarnessTier(){if(!isEnabled('harness'))return'off';if(harnessTierOverride)return harnessTierOverride;const a=process['env']['WOWOK_HARNESS_TIER'];if(a==='off'||a==='lightweight'||a==='full')return a;return'lightweight';}export function setHarnessTier(a){harnessTierOverride=a,savePersisted();}export function resetHarnessTier(){harnessTierOverride=undefined,savePersisted();}export function isEnabled(a){if(runtimeOverrides['has'](a))return runtimeOverrides['get'](a);const b=SERVICE_MAP['get'](a);if(b){const c=process['env'][b['envVar']];if(c!==undefined){if(c==='0'||c==='false')return![];if(c==='1'||c==='true')return!![];}return b['defaultEnabled'];}return![];}export function setEnabled(a,b){runtimeOverrides['set'](a,b),savePersisted();}export function toggle(a){const b=!isEnabled(a);return setEnabled(a,b),b;}export function reset(a){runtimeOverrides['delete'](a),savePersisted();}export function listServices(){return SERVICE_REGISTRY['map'](a=>{const b=runtimeOverrides['has'](a['name']),c=isEnabled(a['name']);return{'name':a['name'],'enabled':c,'defaultEnabled':a['defaultEnabled'],'description':a['description'],'overridden':b,'envVar':a['envVar'],'reminder':a['remindOnToggle']?buildReminder(a['name'],c):undefined};});}export function getServiceInfo(a){const b=SERVICE_MAP['get'](a);if(!b)return undefined;return{'name':b['name'],'enabled':isEnabled(b['name']),'defaultEnabled':b['defaultEnabled'],'description':b['description'],'overridden':runtimeOverrides['has'](b['name']),'envVar':b['envVar'],'reminder':b['remindOnToggle']?buildReminder(b['name'],isEnabled(b['name'])):undefined};}function buildReminder(a,b){switch(a){case'confirm_gate':return b?'ConfirmGate\x20is\x20ON:\x20prompts\x20confirmation\x20before\x20amount,\x20default\x20account,\x20publish,\x20or\x20irreversible\x20operations.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20confirm_gate.':'ConfirmGate\x20is\x20OFF:\x20operations\x20will\x20execute\x20directly\x20without\x20confirmation.\x20Note\x20the\x20risk\x20of\x20irreversible\x20operations.\x20To\x20re-enable,\x20call\x20config_operation\x20toggle\x20confirm_gate.';case'project_service':return b?'ProjectService\x20is\x20ON:\x20auto-injects\x20project:/type:\x20tags\x20on\x20object\x20creation\x20and\x20maintains\x20the\x20dependency\x20graph.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20project_service.':'ProjectService\x20is\x20OFF:\x20objects\x20will\x20not\x20be\x20automatically\x20tagged\x20with\x20project\x20membership.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20project_service.';case'harness':return b?'Harness\x20is\x20ON\x20(tier:\x20'+getHarnessTier()+'):\x20automatically\x20validates\x20expected\x20results\x20around\x20operations.\x20lightweight=Plan+Verify;\x20full=Plan+Expect+Verify+Recover+Checkpoint.\x20To\x20change\x20tier,\x20set\x20WOWOK_HARNESS_TIER\x20or\x20call\x20harness\x20API.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20harness.':'Harness\x20is\x20OFF.\x20GLM5\x20recommends\x20keeping\x20it\x20ON\x20(lightweight\x20tier)\x20for\x20safety.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20harness.';case'graph_persist':return b?'Graph\x20persistence\x20is\x20ON:\x20the\x20object\x20dependency\x20graph\x20will\x20be\x20saved\x20to\x20~/.wow/mcp/project-graph.json.':'Graph\x20persistence\x20is\x20OFF:\x20the\x20dependency\x20graph\x20exists\x20only\x20in\x20memory\x20and\x20will\x20be\x20lost\x20on\x20process\x20restart.\x20To\x20persist,\x20call\x20config_operation\x20toggle\x20graph_persist.';case'semantic_rich':return undefined;case'experience_layer':return b?'Experience\x20layer\x20is\x20ON:\x20provides\x20suggestions\x20in\x20semantic.experience\x20based\x20on\x20historical\x20operation\x20experience.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20experience_layer.':'Experience\x20layer\x20is\x20OFF:\x20no\x20experience\x20suggestions\x20will\x20be\x20attached.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20experience_layer.';case'customer_intelligence':return b?'Customer\x20intelligence\x20is\x20ON:\x20order/query\x20operations\x20will\x20attach\x20risk/preference/blocking\x20alerts\x20in\x20semantic.customer_advice.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.':'Customer\x20intelligence\x20is\x20OFF:\x20semantic.customer_advice\x20will\x20not\x20be\x20populated.\x20To\x20enable,\x20call\x20config_operation\x20toggle\x20customer_intelligence.';case'order_monitor':return b?'Order\x20monitor\x20is\x20ON:\x20detects\x20Progress\x20stalls,\x20compensation\x20balance\x20changes,\x20and\x20Messenger\x20timeouts.\x20To\x20disable,\x20call\x20config_operation\x20toggle\x20order_monitor.':'Order\x20monitor\x20is\x20OFF:\x20will\x20not\x20actively\x20detect\x20order\x20anomalies.\x20To\x20enable\x20(recommended\x20when\x20there\x20are\x20active\x20orders),\x20call\x20config_operation\x20toggle\x20order_monitor.';}}export const RUNTIME_CONFIG_VERSION=0x1;
@@ -0,0 +1,32 @@
1
+ import type { ENTRYPOINT } from "@wowok/wowok";
2
+ import { type Review } from "../knowledge/reputation-rules.js";
3
+ export type AccountEventPriority = "required" | "recommended" | "info" | "reminder";
4
+ export interface AccountEvent {
5
+ id: string;
6
+ category: string;
7
+ priority: AccountEventPriority;
8
+ title: string;
9
+ message: string;
10
+ action?: string;
11
+ object_ref?: string;
12
+ timestamp: number;
13
+ }
14
+ export interface AccountEventWatcherContext {
15
+ account?: string;
16
+ network?: ENTRYPOINT;
17
+ reviews?: Review[];
18
+ order_history?: Array<{
19
+ id: string;
20
+ status: string;
21
+ }>;
22
+ }
23
+ export interface AccountEventWatcher {
24
+ id: string;
25
+ description: string;
26
+ applies?: (ctx: AccountEventWatcherContext) => boolean | Promise<boolean>;
27
+ watch: (ctx: AccountEventWatcherContext) => Promise<AccountEvent[]>;
28
+ }
29
+ export declare function registerAccountEventWatcher(watcher: AccountEventWatcher): boolean;
30
+ export declare function unregisterAccountEventWatcher(id: string): boolean;
31
+ export declare function listAccountEventWatchers(): AccountEventWatcher[];
32
+ export declare function runAccountEventWatchers(ctx: AccountEventWatcherContext, categories?: string[]): Promise<AccountEvent[]>;
@@ -0,0 +1 @@
1
+ import{watch_conversations,query_received,query_events,query_objects}from'@wowok/wowok';import{computeReviewStats,detectReviewManipulation,filterVerifiedReviews}from'../knowledge/reputation-rules.js';const watchers=new Map();export function registerAccountEventWatcher(a){if(!a['id']||watchers['has'](a['id']))return![];return watchers['set'](a['id'],a),!![];}export function unregisterAccountEventWatcher(a){return watchers['delete'](a);}export function listAccountEventWatchers(){return Array['from'](watchers['values']());}const PRIORITY_RANK={'required':0x4,'recommended':0x3,'info':0x2,'reminder':0x1};export async function runAccountEventWatchers(a,b){const c=[],d=b&&b['length']>0x0?new Set(b):undefined;for(const g of watchers['values']()){if(d&&!d['has'](g['id']))continue;if(g['applies']&&!await g['applies'](a))continue;try{c['push'](...await g['watch'](a));}catch{}}const f=new Map();for(const h of c)f['set'](h['id'],h);return Array['from'](f['values']())['sort']((i,j)=>PRIORITY_RANK[j['priority']]-PRIORITY_RANK[i['priority']]||j['timestamp']-i['timestamp']);}registerAccountEventWatcher({'id':'messenger_unread','description':'Unread\x20encrypted\x20messages\x20needing\x20attention','watch':async({account:a})=>{const b=await watch_conversations({'account':a,'unreadOnly':!![],'previewMessageCount':0x1,'skipAutoMarkViewed':!![]});return b['map'](d=>({'id':'messenger_unread:'+d['peerAddress'],'category':'messenger_unread','priority':'reminder','title':'Unread\x20messages\x20from\x20'+d['peerAddress'],'message':d['unreadCount']+'\x20unread\x20message(s)'+(d['lastMessagePreview']?'\x20โ€”\x20\x22'+d['lastMessagePreview']+'\x22':''),'action':'View\x20and\x20reply\x20via\x20messenger_operation','object_ref':d['peerAddress'],'timestamp':Date['now']()}));}}),registerAccountEventWatcher({'id':'order_collection','description':'Pending\x20on-chain\x20collections\x20(CoinWrapper\x20objects\x20awaiting\x20claim)','watch':async({account:a,network:b})=>{if(!a)return[];const c=await query_received({'name_or_address':{'name_or_address':a},'type':undefined,'network':b});if(!Array['isArray'](c))return[];const d=c['filter'](e=>typeof e['type']==='string'&&e['type']['includes']('payment::CoinWrapper'));return d['map'](e=>({'id':'order_collection:'+e['id'],'category':'order_collection','priority':'recommended','title':'Pending\x20collection\x20available','message':'A\x20received\x20payment\x20object\x20is\x20awaiting\x20claim:\x20'+e['id'],'action':'Claim\x20via\x20onchain_operations\x20(order_claim\x20/\x20owner_receive)','object_ref':e['id'],'timestamp':Date['now']()}));}}),registerAccountEventWatcher({'id':'demand_presented','description':'A\x20service\x20presented\x20against\x20one\x20of\x20my\x20demands','watch':async({account:a,network:b})=>{if(!a)return[];const c=await query_events({'type':'DemandPresentEvent','order':'descending','limit':0x14,'network':b,'no_cache':!![]}),d=[];for(const e of c?.['data']??[]){const f=e['demand'];if(!f)continue;try{const g=await query_objects({'objects':[f],'network':b,'no_cache':!![]}),h=g['objects']?.[0x0],i=typeof h?.['owner']==='string'?h['owner']:h?.['owner']?.['AddressOwner'];i&&i['toLowerCase']()===a['toLowerCase']()&&d['push']({'id':'demand_presented:'+f+':'+(e['service']??'?'),'category':'demand_presented','priority':'info','title':'New\x20service\x20presented\x20on\x20your\x20demand','message':'A\x20service\x20('+(e['service']??'unknown')+')\x20presented\x20against\x20demand\x20'+f+(e['recommend']?'\x20โ€”\x20\x22'+e['recommend']+'\x22':''),'action':'Review\x20the\x20presenter\x20via\x20onchain_table_data\x20(demand\x20presenter\x20item)','object_ref':f,'timestamp':Number(e['time']??Date['now']())});}catch{}}return d;}}),registerAccountEventWatcher({'id':'reputation_integrity','description':'Review-reputation\x20analysis\x20for\x20supplied\x20review\x20rows:\x20verification,\x20stats,\x20and\x20manipulation\x20detection\x20(knowledge/reputation-rules)','applies':({reviews:a})=>Array['isArray'](a)&&a['length']>0x0,'watch':async({reviews:a,order_history:b})=>{const c=a??[],d=b&&b['length']>0x0?filterVerifiedReviews(c,b):c,e=computeReviewStats(d),f=detectReviewManipulation(d),g=[];return f['suspicious']&&g['push']({'id':'reputation_integrity:manipulation','category':'reputation_integrity','priority':'required','title':'Suspicious\x20review\x20activity\x20detected','message':'Manipulation\x20signals:\x20'+f['reasons']['join'](';\x20')+'.\x20Stats:\x20'+e['likes']+'\x20likes\x20/\x20'+e['dislikes']+'\x20dislikes\x20across\x20'+e['total']+'\x20reviews\x20('+e['verifiedCount']+'\x20verified).','action':'Cross-check\x20reviewer\x20addresses\x20against\x20completed\x20orders\x20before\x20trusting\x20the\x20review\x20aggregate','timestamp':Date['now']()}),e['total']>=0x5&&e['verifiedCount']/e['total']<0.3&&g['push']({'id':'reputation_integrity:unverified','category':'reputation_integrity','priority':'recommended','title':'Reviews\x20are\x20dominated\x20by\x20unverified\x20submissions','message':'Only\x20'+e['verifiedCount']+'/'+e['total']+'\x20reviews\x20carry\x20a\x20completed-order\x20credential\x20โ€”\x20the\x20aggregate\x20may\x20reflect\x20spam\x20rather\x20than\x20real\x20buyers.','action':'Bind\x20a\x20review\x20Guard\x20(verified-buyer\x20check)\x20to\x20the\x20ReviewRepository\x20โ€”\x20see\x20knowledge/reputation-rules\x20buildReviewRepositorySetup','timestamp':Date['now']()}),e['recentTrend']==='declining'&&g['push']({'id':'reputation_integrity:declining','category':'reputation_integrity','priority':'info','title':'Review\x20trend\x20is\x20declining','message':'Recent\x20like-rate\x20is\x20materially\x20below\x20the\x20earlier\x20period\x20('+Math['round'](e['likeRate']*0x64)+'%\x20overall,\x20top\x20tags:\x20'+(e['topTags']['map'](h=>h['tag'])['join'](',\x20')||'none')+').','action':'Inspect\x20recent\x20dislike\x20tags\x20for\x20recurring\x20complaint\x20themes','timestamp':Date['now']()}),g;}});
@@ -6,6 +6,7 @@ export interface PreorderAdviceInput {
6
6
  industry?: Industry;
7
7
  matching_overrides?: Partial<ServiceForMatching>;
8
8
  reminder_overrides?: Partial<ReminderContext>;
9
+ overrides?: Record<string, string>;
9
10
  max_strategies?: number;
10
11
  max_reminders?: number;
11
12
  }
@@ -1 +1 @@
1
- import{assessRisk,detectScenarios,recommendStrategy,matchServiceToPreferences,assessIndustryRisks,inferIndustry,generateReminders,getBlockingReminders,sortAndCapReminders}from'./index.js';import{registryDisplayHint}from'../knowledge/fund-layer.js';export function assemblePreorderAdvice(a){const {puzzle:b}=a,c=a['risk']??assessRisk(b),d=a['industry']??inferIndustry(b),e=detectScenarios(b),f=e['slice'](0x0,a['max_strategies']??0x3)['map'](m=>recommendStrategy(m,{'puzzle':b,'prefs':a['preferences']}));let g;if(a['preferences']){const m=toMatchingService(b,c,a['matching_overrides']);g=matchServiceToPreferences(m,a['preferences']);}let h;d&&(h=assessIndustryRisks(b,d));const i=buildReminderContext(b,c,a['reminder_overrides']),j=sortAndCapReminders(generateReminders(i))['slice'](0x0,a['max_reminders']??0x8),k=getBlockingReminders(j),l=computeConfidence(b,c,g);return{'service_id':b['service_id'],'risk':c,'industry':d,'strategies':f,'preference_match':g,'industry_risks':h,'reminders':j,'blocking_reminders':k,'confidence':l,'summary':buildSummary(b,c,d,f,g,k,l)};}function toMatchingService(a,b,c){const d=a['service_basics'],e=a['fund_safety'],f=a['trust_signals'],g=a['merchant_behavior'];return{'service_id':a['service_id'],'price':d['price_raw'],'token_type':d['token_type']??'','avg_market_price':a['market_context']?.['avg_price'],'merchant_order_history_count':g?.['total_orders']??0x0,'merchant_age':g?g['total_orders']>=0x32?'established':'emerging':'unknown','has_arbitration':(f?.['arbitration_count']??0x0)>0x0,'has_compensation_fund':e?e['compensation_ratio']>0x0:![],'has_reward_activity':![],'has_discount':![],'risk_score':b['total'],'trust_score':f?.['trust_score']??0x32,'requires_messenger':![],'after_sales_support_level':f?.['has_messenger']?'full':'minimal',...c};}function buildReminderContext(a,b,c){const d=a['trust_signals'],e=a['fund_safety'],f=a['workflow_analysis'];return{'stage':'preorder','service_id':a['service_id'],'review_count':d?.['review_total'],'like_rate':d?.['like_rate'],'avg_market_price':a['market_context']?.['avg_price'],'service_price':a['service_basics']['price_raw'],'token':registryDisplayHint(a['service_basics']['token_type']),'has_arbitration':(d?.['arbitration_count']??0x0)>0x0,'has_compensation':e?e['compensation_ratio']>0x0:undefined,'compensation_ratio':e?.['compensation_ratio'],'risk_score':b['total'],'risk_level':b['level'],'has_refund_path':f?.['has_refund_path'],'has_messenger':d?.['has_messenger'],'customer_required':a['service_basics']['customer_required'],...c};}function computeConfidence(a,b,c){const d=Math['max'](0x0,Math['min'](0x64,0x64-b['total'])),e=a['user_metrics']?.['adjustment']??0x0,f=c?Math['round']((c['score']-0x32)/0xa):0x0,g=Math['max'](0x0,Math['min'](0x64,d+e+f)),h=['base\x20'+d+'\x20(=\x20100\x20-\x20risk\x20'+b['total']+')'];if(e!==0x0)h['push']('your\x20custom\x20metrics\x20'+(e>0x0?'+':'')+e);if(f!==0x0)h['push']('preference\x20fit\x20'+(f>0x0?'+':'')+f);return{'score':g,'base':d,'user_adjustment':e,'preference_nudge':f,'explanation':'Confidence\x20'+g+'/100\x20=\x20'+h['join']('\x20')+'.\x20'+'This\x20is\x20evidence\x20aggregation,\x20not\x20advice\x20โ€”\x20the\x20decision\x20is\x20yours.'};}function buildSummary(a,b,c,d,e,f,g){const h=['Order\x20confidence\x20'+g['score']+'/100\x20(risk\x20'+b['total']+'/100,\x20level\x20'+b['level']+')'+(c?'\x20for\x20'+c+'\x20service':'')+('.\x20Information\x20completeness\x20'+Math['round'](a['completeness']*0x64)+'%.')];f['length']>0x0&&h['push']('โš ๏ธ\x20'+f['length']+'\x20blocking\x20concern(s):\x20'+f['map'](i=>i['message'])['join'](';\x20'));b['red_flags']['length']>0x0&&h['push']('Red\x20flags:\x20'+b['red_flags']['slice'](0x0,0x3)['join'](';\x20')+'.');if(d['length']>0x0){const i=d[0x0];h['push']('Key\x20protection\x20('+i['scenario']+'):\x20'+i['strategy']['user_strategy']);}return e&&h['push'](e['mismatches']['length']>0x0?'Preference\x20mismatches:\x20'+e['mismatches']['slice'](0x0,0x2)['join'](';\x20')+'.':'Service\x20matches\x20your\x20preferences\x20(score\x20'+e['score']+'/100).'),a['gaps']['length']>0x0&&h['push']('Missing\x20information:\x20'+a['gaps']['join'](',\x20')+'\x20โ€”\x20consider\x20asking\x20the\x20merchant\x20via\x20Messenger\x20before\x20ordering.'),h['join']('\x20');}
1
+ import{assessRisk,detectScenarios,recommendStrategy,matchServiceToPreferences,assessIndustryRisks,inferIndustry,generateReminders,getBlockingReminders,sortAndCapReminders}from'./index.js';import{registryDisplayHint}from'../knowledge/fund-layer.js';export function assemblePreorderAdvice(a){const {puzzle:b}=a,c=a['risk']??assessRisk(b),d=a['industry']??inferIndustry(b),e=detectScenarios(b),f=e['slice'](0x0,a['max_strategies']??0x3)['map'](m=>recommendStrategy(m,{'puzzle':b,'prefs':a['preferences']}));let g;if(a['preferences']){const m=toMatchingService(b,c,a['matching_overrides']);g=matchServiceToPreferences(m,a['preferences']);}let h;d&&(h=assessIndustryRisks(b,d));const i=buildReminderContext(b,c,a['reminder_overrides']),j=applyMissingArbitrationOverride(sortAndCapReminders(generateReminders(i))['slice'](0x0,a['max_reminders']??0x8),a['overrides']),k=getBlockingReminders(j),l=computeConfidence(b,c,g);return{'service_id':b['service_id'],'risk':c,'industry':d,'strategies':f,'preference_match':g,'industry_risks':h,'reminders':j,'blocking_reminders':k,'confidence':l,'summary':buildSummary(b,c,d,f,g,k,l)};}function toMatchingService(a,b,c){const d=a['service_basics'],e=a['fund_safety'],f=a['trust_signals'],g=a['merchant_behavior'];return{'service_id':a['service_id'],'price':d['price_raw'],'token_type':d['token_type']??'','avg_market_price':a['market_context']?.['avg_price'],'merchant_order_history_count':g?.['total_orders']??0x0,'merchant_age':g?g['total_orders']>=0x32?'established':'emerging':'unknown','has_arbitration':(f?.['arbitration_count']??0x0)>0x0,'has_compensation_fund':e?e['compensation_ratio']>0x0:![],'has_reward_activity':![],'has_discount':![],'risk_score':b['total'],'trust_score':f?.['trust_score']??0x32,'requires_messenger':![],'after_sales_support_level':f?.['has_messenger']?'full':'minimal',...c};}function applyMissingArbitrationOverride(a,b){if(b?.['risk.missing_arbitration']!=='block')return a;return a['map'](c=>c['id']==='browse_no_arbitration'?{...c,'priority':'required'}:c);}function buildReminderContext(a,b,c){const d=a['trust_signals'],e=a['fund_safety'],f=a['workflow_analysis'];return{'stage':'preorder','service_id':a['service_id'],'review_count':d?.['review_total'],'like_rate':d?.['like_rate'],'avg_market_price':a['market_context']?.['avg_price'],'service_price':a['service_basics']['price_raw'],'token':registryDisplayHint(a['service_basics']['token_type']),'has_arbitration':(d?.['arbitration_count']??0x0)>0x0,'has_compensation':e?e['compensation_ratio']>0x0:undefined,'compensation_ratio':e?.['compensation_ratio'],'risk_score':b['total'],'risk_level':b['level'],'has_refund_path':f?.['has_refund_path'],'has_arb_refund_path':f?.['has_arb_refund_path'],'has_refund_allocator':f?.['has_refund_allocator'],'has_messenger':d?.['has_messenger'],'customer_required':a['service_basics']['customer_required'],...c};}function computeConfidence(a,b,c){const d=Math['max'](0x0,Math['min'](0x64,0x64-b['total'])),e=a['user_metrics']?.['adjustment']??0x0,f=c?Math['round']((c['score']-0x32)/0xa):0x0,g=Math['max'](0x0,Math['min'](0x64,d+e+f)),h=['base\x20'+d+'\x20(=\x20100\x20-\x20risk\x20'+b['total']+')'];if(e!==0x0)h['push']('your\x20custom\x20metrics\x20'+(e>0x0?'+':'')+e);if(f!==0x0)h['push']('preference\x20fit\x20'+(f>0x0?'+':'')+f);return{'score':g,'base':d,'user_adjustment':e,'preference_nudge':f,'explanation':'Confidence\x20'+g+'/100\x20=\x20'+h['join']('\x20')+'.\x20'+'This\x20is\x20evidence\x20aggregation,\x20not\x20advice\x20โ€”\x20the\x20decision\x20is\x20yours.'};}function buildSummary(a,b,c,d,e,f,g){const h=['Order\x20confidence\x20'+g['score']+'/100\x20(risk\x20'+b['total']+'/100,\x20level\x20'+b['level']+')'+(c?'\x20for\x20'+c+'\x20service':'')+('.\x20Information\x20completeness\x20'+Math['round'](a['completeness']*0x64)+'%.')];f['length']>0x0&&h['push']('โš ๏ธ\x20'+f['length']+'\x20blocking\x20concern(s):\x20'+f['map'](i=>i['message'])['join'](';\x20'));b['red_flags']['length']>0x0&&h['push']('Red\x20flags:\x20'+b['red_flags']['slice'](0x0,0x3)['join'](';\x20')+'.');if(d['length']>0x0){const i=d[0x0];h['push']('Key\x20protection\x20('+i['scenario']+'):\x20'+i['strategy']['user_strategy']);}return e&&h['push'](e['mismatches']['length']>0x0?'Preference\x20mismatches:\x20'+e['mismatches']['slice'](0x0,0x2)['join'](';\x20')+'.':'Service\x20matches\x20your\x20preferences\x20(score\x20'+e['score']+'/100).'),a['gaps']['length']>0x0&&h['push']('Missing\x20information:\x20'+a['gaps']['join'](',\x20')+'\x20โ€”\x20consider\x20asking\x20the\x20merchant\x20via\x20Messenger\x20before\x20ordering.'),h['join']('\x20');}
@@ -1 +1 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export function assembleServiceBasics(a,b,c=![]){const d=(b['sales']??[])['filter'](f=>!f['suspension']),e=d['some'](f=>f['wip_hash']&&f['wip_hash']['length']>0x0);return{'service_id':a,'name':b['name']??a,'bPublished':b['bPublished']??![],'bPaused':b['bPaused']??![],'price':b['price']??'0','price_raw':b['priceRaw']??0x0n,'token_type':b['token_type']??'0x2::wow::WOW','sales_count':d['length'],'machine_id':b['machine'],'buy_guard_id':b['buy_guard'],'customer_required_count':b['customer_required']?.['length']??0x0,'customer_required':(b['customer_required']??[])['filter'](f=>typeof f==='string'),'arbitrations_count':b['arbitrations']?.['length']??0x0,'compensation_fund_balance':b['compensation_fund']?.['balance']??0x0n,'compensation_lock_duration':b['compensation_lock_duration']??0x0,'um_id':b['um'],'has_wip':e,'wip_verified':c};}export function assembleWorkflowAnalysis(a,b,c,d){const e=[],f=[],g=[];let h=0x0,i=0x0,j=0x0,k=![],l=![],m=![];const n=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i,o=/^(wonder|no_wonder|praise|complain|thumbs_up|thumbs_down|positive_review|negative_review)$/i,p=a['reduce']((w,x)=>w+(x['forwards']?.['length']??0x0),0x0);for(const w of a){n['test'](w['name']['trim']())&&(m=!![]);}for(const x of a){const y=x['forwards']??[];y['length']===0x0&&f['push'](x['name']);for(const z of y){const A=z['namedOperator'],B=z['guard'];if(A==='')B?j++:h++;else A===null||A===undefined?i++:i++;const C=(z['to']??'')['trim']()['toLowerCase']();o['test'](C)&&(l=!![]),C['includes']('milestone')&&(k=!![]);}}for(const D of a){const E=D['forwards']??[];if(E['length']>0x0&&!f['includes'](D['name'])){const F=E['every'](G=>G['namedOperator']!==''&&G['namedOperator']!==null);F&&h===0x0&&g['push'](D['name']);}}const q=(d?.['arbitrations']?.['length']??0x0)>0x0,r=d?.['compensation_fund']?.['balance']??0x0n,s=q&&r>0x0n,t=d?.['order_allocators']?.[0x0]?.['allocators']??[],u=t['some'](G=>G['surplus_to']==='order'||G['surplus_to']==='Order'),v=s||u;if(!v)e['push']('no_refund_path');if(!q)e['push']('no_arbitration_binding');if(m)e['push']('dispute_anti_pattern');if(h===0x0)e['push']('no_user_operable_path');if(g['length']>0x0)e['push']('potential_dead_ends');return{'machine_published':b,'machine_paused':c,'total_nodes':a['length'],'total_forwards':p,'user_operable_forwards':h,'provider_only_forwards':i,'guard_gated_forwards':j,'has_refund_path':v,'has_arbitration_path':q,'has_arbitration_binding':q,'has_wonder_node':l,'has_dispute_anti_pattern':m,'has_milestone_nodes':k,'dead_end_nodes':g,'terminal_nodes':f,'risk_signals':e};}export function assembleFundSafety(a,b){const c=a['order_allocators']?.[0x0]?.['allocators']??[],d=a['compensation_fund']?.['balance']??0x0n,e=a['compensation_lock_duration']??0x0,f=c['find'](j=>{const k=j['amount'];return k?.['type']==='FixedValue'&&k['value']===b;}),g=c['some'](j=>j['surplus_to']==='order'||j['surplus_to']==='Order');let h='none';b>0x0n&&(d>0x0n&&b>d*0x3n&&(h='low'));const i=e===0x0||e>0x7;return{'has_order_allocator':c['length']>0x0,'has_refund_allocator':!!f||g,'allocator_count':c['length'],'refund_allocator_exists':g,'surplus_to_provider':c['some'](j=>j['surplus_to']!=='order'&&j['surplus_to']!=='Order'),'user_path_has_allocator':c['length']>0x0,'compensation_covers_order':d>=b,'compensation_ratio':b>0x0n?Math['min'](0x1,Number(d*0x64n/b)/0x64):0x0,'lock_duration_safe':i,'price_anomaly':h};}export function assembleTrustSignals(a,b,c,d,e,f,g){const h=b['filter'](n=>n['rating']==='like')['length'],i=b['filter'](n=>n['rating']==='dislike')['length'],j=b['filter'](n=>n['verified']||n['has_evidence'])['length'],k=b['length'],l=k>0x0?h/k:0x0,m=d!==undefined&&e!==undefined?d!==e:!![];return{'arbitration_independent':m,'arbitration_count':a['arbitrations']?.['length']??0x0,'arbitration_paused':![],'review_likes':h,'review_dislikes':i,'review_verified_count':j,'review_total':k,'like_rate':l,'trust_score':c['score'],'trust_level':c['level'],'has_contact':!!a['um'],'has_messenger':!!a['um'],'arbitration_permission_shared':f,'arbitration_permission_overlap':g};}const REPUTATION_MIN_VOTES=0x3;function toReputation(a){const b=a['likes']+a['dislikes'];return{'likes':a['likes'],'dislikes':a['dislikes'],'like_ratio':b>0x0?a['likes']/b:0x1};}function reputationRedFlags(a){if(!a)return[];const b=a['likes']+a['dislikes'];if(b>=REPUTATION_MIN_VOTES&&a['like_ratio']<0.5)return['reputation_negative'];return[];}export function assembleMerchantBehavior(a,b,c){const d=c?toReputation(c):undefined,e=reputationRedFlags(d);if(b&&b['length']>0x0){const l=b['length'],m=b['filter'](v=>v['status']==='completed')['length'],n=b['filter'](v=>v['has_dispute'])['length'],o=b['filter'](v=>v['is_repeat'])['length'],p=l>0x0?m/l:0x0,q=l>0x0?n/l:0x0,r=l>0x0?o/l:0x0,s=Math['floor'](l/0x2);let t='stable';if(l>=0x4&&s>0x0){const v=b['slice'](0x0,s)['filter'](z=>z['has_dispute'])['length'],w=b['slice'](s)['filter'](z=>z['has_dispute'])['length'],x=v/s,y=w/(l-s);if(y<x*0.85)t='improving';else{if(y>x*1.15)t='declining';}}const u=[...e];if(q>0.1)u['push']('dispute_rate_high');if(t==='declining')u['push']('declining_trend');return{'total_orders':l,'completed_rate':p,'dispute_rate':q,'refund_rate':0x0,'arb_loss_rate':0x0,'repeat_buyer_rate':r,'recent_trend':t,'red_flags':u,'reputation':d};}const f=a['filter'](z=>z['type']['includes']('Order')||z['type']['includes']('order')),g=a['filter'](z=>z['type']['includes']('Dispute')||z['type']['includes']('Arb')),h=f['length'],i=g['length'],j=h>0x0?i/h:0x0,k=[...e];if(j>0.1)k['push']('dispute_rate_high');return{'total_orders':h,'completed_rate':h>0x0?Math['max'](0x0,0x1-j):0x0,'dispute_rate':j,'refund_rate':0x0,'arb_loss_rate':0x0,'repeat_buyer_rate':0x0,'recent_trend':'stable','red_flags':k,'reputation':d};}export function assembleMarketContext(a,b){if(a['length']===0x0)return{'similar_services_count':0x0,'avg_price':0x0n,'min_price':0x0n,'max_price':0x0n,'price_percentile':0x0,'supply_demand_ratio':0x0};const c=a['map'](j=>j['price'])['sort']((j,k)=>j<k?-0x1:j>k?0x1:0x0),d=c['reduce']((j,k)=>j+k,0x0n),e=d/BigInt(c['length']),f=c[0x0],g=c[c['length']-0x1];let h=0x0;for(const j of c){if(j<b)h++;}const i=c['length']>0x0?h/c['length']:0x0;return{'similar_services_count':a['length'],'avg_price':e,'min_price':f,'max_price':g,'price_percentile':i,'supply_demand_ratio':a['length']};}export function assembleInfoPuzzle(a,b,c='evaluate'){const d=[],e=assembleServiceBasics(a,b['service'],b['wip_verified']??![]);let f,g,h;if(c==='evaluate'||c==='preorder'||c==='monitor'){b['machine_nodes']?f=assembleWorkflowAnalysis(b['machine_nodes'],b['machine_published']??![],b['machine_paused']??![],b['service']):d['push']('machine_workflow');const m=b['order_amount']??e['price_raw'];g=assembleFundSafety(b['service'],m),b['reviews']&&b['trust_score']?h=assembleTrustSignals(b['service'],b['reviews'],b['trust_score'],b['arbitration_owner'],b['service_owner']):d['push']('reviews_or_trust_score');}let i;if(c==='preorder'||c==='monitor'){if(b['events']||b['order_history'])i=assembleMerchantBehavior(b['events']??[],b['order_history'],b['merchant_reputation']);else b['merchant_reputation']?i=assembleMerchantBehavior([],undefined,b['merchant_reputation']):d['push']('merchant_behavior');}let j;(c==='evaluate'||c==='preorder')&&(b['similar_services']?j=assembleMarketContext(b['similar_services'],e['price_raw']):d['push']('market_context'));let k;b['user_metrics_config']&&b['user_metrics_config']['metrics']['length']>0x0&&(k=assembleUserMetrics(b['user_metrics_config'],b['user_metrics_context']??{}));let l=b['service_nesting'];return!l&&b['service_nesting_raw']&&(l=evaluateServiceNesting(b['service_nesting_raw'])),{'service_id':a,'service_basics':e,'workflow_analysis':f,'fund_safety':g,'trust_signals':h,'merchant_behavior':i,'market_context':j,'user_metrics':k,'service_nesting':l,'completeness':computeCompleteness(c,[e,f,g,h,i,j,k,l]),'gaps':d,'assembled_at':Date['now']()};}export function assembleUserMetrics(a,b){const c=a['adjustment_cap']??0xa,d=[],e=a['metrics']['reduce']((i,j)=>i+Math['max'](0x0,j['weight']),0x0);for(const i of a['metrics']){const j=e>0x0?Math['max'](0x0,i['weight'])/e:0x0,k=resolvePath(b,i['params']['path']??i['name']),{passed:l,score:m,observed_value:n}=evaluateMetric(i,k);d['push']({'name':i['name'],'label':i['label'],'passed':l,'score':m,'observed_value':formatObservedValue(k),'weight':j,'advice':l?i['advice_on_pass']:i['advice_on_fail']});}const f=d['reduce']((o,p)=>o+p['score']*p['weight'],0x0),g=Math['round'](f*0x64),h=Math['round']((g-0x32)/0x32*c);return{'metrics':d,'score':g,'adjustment':h,'source_file':a['source_file'],'evaluated_at':Date['now']()};}function resolvePath(a,b){if(!b)return undefined;const c=b['split']('.');let d=a;for(const e of c){if(d===null||d===undefined)return undefined;if(typeof d!=='object')return undefined;d=d[e];}return d;}function evaluateMetric(a,b){const c=a['params'];switch(a['evaluator']){case'threshold':{const d=typeof b==='number'?b:typeof b==='string'?Number(b):typeof b==='bigint'?Number(b):NaN,e=typeof c['threshold']==='number'?c['threshold']:typeof c['threshold']==='string'?Number(c['threshold']):NaN;if(isNaN(d)||isNaN(e))return{'passed':![],'score':0x0,'observed_value':b};const f=c['invert']?d<=e:d>=e,g=Math['abs'](e)*0.5||0x1,h=c['invert']?(e-d)/g+0x1:(d-e)/g+0x1,i=Math['max'](0x0,Math['min'](0x1,h));return{'passed':f,'score':i,'observed_value':b};}case'ratio':{const j=typeof b==='number'?b:typeof b==='string'?Number(b):NaN,k=c['min']??0x0,l=c['max']??0x1;if(isNaN(j))return{'passed':![],'score':0x0,'observed_value':b};const m=j>=k&&j<=l,n=l-k,o=(k+l)/0x2,q=n>0x0?Math['max'](0x0,0x1-Math['abs'](j-o)/(n/0x2)):0x1;return{'passed':m,'score':q,'observed_value':b};}case'boolean':{const r=!!b;return{'passed':r,'score':r?0x1:0x0,'observed_value':b};}case'presence':{const s=b!==undefined&&b!==null&&b!=='';return{'passed':s,'score':s?0x1:0x0,'observed_value':b};}case'regex_match':{if(typeof b!=='string'||!c['pattern'])return{'passed':![],'score':0x0,'observed_value':b};try{const t=new RegExp(c['pattern']),u=t['test'](b);return{'passed':u,'score':u?0x1:0x0,'observed_value':b};}catch{return{'passed':![],'score':0x0,'observed_value':b};}}case'custom_query':{return{'passed':![],'score':0.5,'observed_value':b};}default:return{'passed':![],'score':0x0,'observed_value':b};}}function formatObservedValue(a){if(typeof a==='string'||typeof a==='number'||typeof a==='boolean')return a;if(typeof a==='bigint')return a['toString']();if(a===undefined||a===null)return undefined;try{return JSON['stringify'](a);}catch{return String(a);}}function computeCompleteness(a,b){const c=a==='browse'?0x1:a==='evaluate'?0x4:a==='preorder'?0x6:0x5,d=b['slice'](0x0,c),e=d['filter'](f=>f!==undefined&&f!==null)['length'];return Math['min'](0x1,e/c);}export function evaluateServiceNesting(b){const c=b['depth']??0x0,d=b['maxDepth']??0x3,e=c>=d,f={'arbitrations':[],'rewards':[],'repositories':[]};let g=0x0;if(b['machine']){const v=b['machine'],w=[];let x=0x0;if(v['published'])x+=0xa;else w['push']('Machine\x20not\x20published');v['paused']&&(x+=0x28,w['push']('Machine\x20paused'));v['has_no_entry']&&(x+=0x32,w['push']('No\x20entry\x20point\x20(R-M1-01)'));v['has_no_terminal']&&(x+=0x32,w['push']('No\x20terminal\x20node\x20(R-M1-02)'));v['has_dispute_anti_pattern']&&(x+=0x3c,w['push']('Dispute\x20anti-pattern\x20(R-M1-11):\x20machine\x20illegally\x20models\x20dispute\x20flow'));const y=v['structural_issue_count']??0x0;y>0x0&&(x+=y*0xf,w['push'](y+'\x20structural\x20issue(s)\x20detected\x20(cycles/dead-ends/orphans)')),x=Math['min'](0x64,x),f['machine']={'object_id':v['object_id'],'published':v['published'],'risk_level':scoreToNestingLevel(x),'issues':w},g++;}for(const z of b['arbitrations']??[]){const A=[];let B=0x0;if(z['voting_guard_count']===0x0)B+=0x32,A['push']('No\x20voting_guard\x20configured\x20โ€”\x20no\x20arbitrators\x20can\x20vote');else z['voting_guard_count']<=0x2?(B+=0x1e,A['push']('Few\x20arbitrators\x20(<=2)\x20โ€”\x20limited\x20dispute\x20resolution\x20capacity')):B+=0xa;z['paused']&&(B+=0x28,A['push']('Arbitration\x20paused\x20โ€”\x20disputes\x20cannot\x20be\x20filed')),z['fee_balance']===0x0n&&(B+=0x1e,A['push']('No\x20compensation\x20fund\x20balance\x20โ€”\x20rulings\x20cannot\x20pay\x20out')),B=Math['min'](0x64,B),f['arbitrations']['push']({'object_id':z['object_id'],'voting_guard_count':z['voting_guard_count'],'fee_balance':z['fee_balance']['toString'](),'paused':z['paused'],'risk_level':scoreToNestingLevel(B),'issues':A}),g++;}for(const C of b['rewards']??[]){const D=[];let E=0x0;C['balance']===0x0n&&(E+=0x3c,D['push']('Reward\x20fund\x20empty\x20โ€”\x20claims\x20will\x20fail')),C['guard_count']===0x0&&(E+=0x32,D['push']('No\x20claim_guard\x20โ€”\x20anyone\x20could\x20claim\x20(or\x20no\x20one\x20can,\x20depending\x20on\x20default)')),C['expiration_time']&&C['expiration_time']>0x0&&C['expiration_time']<Date['now']()&&(E+=0x28,D['push']('Reward\x20expired\x20โ€”\x20claims\x20no\x20longer\x20possible')),E=Math['min'](0x64,E),f['rewards']['push']({'object_id':C['object_id'],'balance':C['balance']['toString'](),'guard_count':C['guard_count'],'risk_level':scoreToNestingLevel(E),'issues':D}),g++;}for(const F of b['repositories']??[]){const G=[];let H=0x0;!F['has_write_guard']&&(H+=0x28,G['push']('No\x20write_guard\x20โ€”\x20Repository\x20is\x20open\x20to\x20arbitrary\x20writes')),F['is_empty']&&(H+=0x14,G['push']('Repository\x20empty\x20โ€”\x20no\x20historical\x20data\x20for\x20evaluation')),H=Math['min'](0x64,H),f['repositories']['push']({'object_id':F['object_id'],'risk_level':scoreToNestingLevel(H),'issues':G}),g++;}if(g===0x0)return undefined;const h=f['machine']?nestingLevelToScore(f['machine']['risk_level']):0x0,i=f['machine']?0x23:0x0,j=f['arbitrations']['length']>0x0?Math['max'](...f['arbitrations']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,k=f['arbitrations']['length']>0x0?0x1e:0x0,l=f['rewards']['length']>0x0?Math['max'](...f['rewards']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,n=f['rewards']['length']>0x0?0x14:0x0,o=f['repositories']['length']>0x0?Math['max'](...f['repositories']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,p=f['repositories']['length']>0x0?0xf:0x0,q=i+k+n+p,s=q>0x0?Math['round']((h*i+j*k+l*n+o*p)/q):0x0,t=[];if(f['machine'])t['push'](f['machine']['risk_level']);for(const I of f['arbitrations'])t['push'](I['risk_level']);for(const J of f['rewards'])t['push'](J['risk_level']);for(const K of f['repositories'])t['push'](K['risk_level']);const u=t['reduce'](highestLevel,'low');return{'depth_reached':c,'truncated':e,'bindings':f,'overall_risk_level':u,'overall_risk_score':s,'total_bindings_evaluated':g,'evaluated_at':Date['now']()};}function scoreToNestingLevel(a){if(a>=0x4b)return'critical';if(a>=0x32)return'high';if(a>=0x19)return'medium';return'low';}function nestingLevelToScore(a){switch(a){case'critical':return 0x5a;case'high':return 0x41;case'medium':return 0x28;case'low':return 0xa;}}function highestLevel(c,d){const e={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3};return e[c]>=e[d]?c:d;}export{CUSTOMER_INTELLIGENCE_VERSION};
1
+ import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export function assembleServiceBasics(a,b,c=![]){const d=(b['sales']??[])['filter'](f=>!f['suspension']),e=d['some'](f=>f['wip_hash']&&f['wip_hash']['length']>0x0);return{'service_id':a,'name':b['name']??a,'bPublished':b['bPublished']??![],'bPaused':b['bPaused']??![],'price':b['price']??'0','price_raw':b['priceRaw']??0x0n,'token_type':b['token_type']??'0x2::wow::WOW','sales_count':d['length'],'machine_id':b['machine'],'buy_guard_id':b['buy_guard'],'customer_required_count':b['customer_required']?.['length']??0x0,'customer_required':(b['customer_required']??[])['filter'](f=>typeof f==='string'),'arbitrations_count':b['arbitrations']?.['length']??0x0,'compensation_fund_balance':b['compensation_fund']?.['balance']??0x0n,'compensation_lock_duration':b['compensation_lock_duration']??0x0,'um_id':b['um'],'has_wip':e,'wip_verified':c};}export function assembleWorkflowAnalysis(a,b,c,d){const e=[],f=[],g=[];let h=0x0,i=0x0,j=0x0,k=![],l=![],m=![];const n=/(^|_)(disputed?|refund(?:ed)?|arbitration|arb)(_|$)/i,o=/^(wonder|no_wonder|praise|complain|thumbs_up|thumbs_down|positive_review|negative_review)$/i,p=a['reduce']((w,x)=>w+(x['forwards']?.['length']??0x0),0x0);for(const w of a){n['test'](w['name']['trim']())&&(m=!![]);}for(const x of a){const y=x['forwards']??[];y['length']===0x0&&f['push'](x['name']);for(const z of y){const A=z['namedOperator'],B=z['guard'];if(A==='')B?j++:h++;else A===null||A===undefined?i++:i++;const C=(z['to']??'')['trim']()['toLowerCase']();o['test'](C)&&(l=!![]),C['includes']('milestone')&&(k=!![]);}}for(const D of a){const E=D['forwards']??[];if(E['length']>0x0&&!f['includes'](D['name'])){const F=E['every'](G=>G['namedOperator']!==''&&G['namedOperator']!==null);F&&h===0x0&&g['push'](D['name']);}}const q=(d?.['arbitrations']?.['length']??0x0)>0x0,r=d?.['compensation_fund']?.['balance']??0x0n,s=q&&r>0x0n,t=d?.['order_allocators']?.[0x0]?.['allocators']??[],u=t['some'](G=>G['surplus_to']==='order'||G['surplus_to']==='Order'),v=s||u;if(!v)e['push']('no_refund_path');if(!q)e['push']('no_arbitration_binding');if(m)e['push']('dispute_anti_pattern');if(h===0x0)e['push']('no_user_operable_path');if(g['length']>0x0)e['push']('potential_dead_ends');return{'machine_published':b,'machine_paused':c,'total_nodes':a['length'],'total_forwards':p,'user_operable_forwards':h,'provider_only_forwards':i,'guard_gated_forwards':j,'has_refund_path':v,'has_arb_refund_path':s,'has_refund_allocator':u,'has_arbitration_path':q,'has_arbitration_binding':q,'has_wonder_node':l,'has_dispute_anti_pattern':m,'has_milestone_nodes':k,'dead_end_nodes':g,'terminal_nodes':f,'risk_signals':e};}export function assembleFundSafety(a,b){const c=a['order_allocators']?.[0x0]?.['allocators']??[],d=a['compensation_fund']?.['balance']??0x0n,e=a['compensation_lock_duration']??0x0,f=c['find'](j=>{const k=j['amount'];return k?.['type']==='FixedValue'&&k['value']===b;}),g=c['some'](j=>j['surplus_to']==='order'||j['surplus_to']==='Order');let h='none';b>0x0n&&(d>0x0n&&b>d*0x3n&&(h='low'));const i=e===0x0||e>0x7;return{'has_order_allocator':c['length']>0x0,'has_refund_allocator':!!f||g,'allocator_count':c['length'],'refund_allocator_exists':g,'surplus_to_provider':c['some'](j=>j['surplus_to']!=='order'&&j['surplus_to']!=='Order'),'user_path_has_allocator':c['length']>0x0,'compensation_covers_order':d>=b,'compensation_ratio':b>0x0n?Math['min'](0x1,Number(d*0x64n/b)/0x64):0x0,'lock_duration_safe':i,'price_anomaly':h};}export function assembleTrustSignals(a,b,c,d,e,f,g){const h=b['filter'](n=>n['rating']==='like')['length'],i=b['filter'](n=>n['rating']==='dislike')['length'],j=b['filter'](n=>n['verified']||n['has_evidence'])['length'],k=b['length'],l=k>0x0?h/k:0x0,m=d!==undefined&&e!==undefined?d!==e:!![];return{'arbitration_independent':m,'arbitration_count':a['arbitrations']?.['length']??0x0,'arbitration_paused':![],'review_likes':h,'review_dislikes':i,'review_verified_count':j,'review_total':k,'like_rate':l,'trust_score':c['score'],'trust_level':c['level'],'has_contact':!!a['um'],'has_messenger':!!a['um'],'arbitration_permission_shared':f,'arbitration_permission_overlap':g};}const REPUTATION_MIN_VOTES=0x3;function toReputation(a){const b=a['likes']+a['dislikes'];return{'likes':a['likes'],'dislikes':a['dislikes'],'like_ratio':b>0x0?a['likes']/b:0x1};}function reputationRedFlags(a){if(!a)return[];const b=a['likes']+a['dislikes'];if(b>=REPUTATION_MIN_VOTES&&a['like_ratio']<0.5)return['reputation_negative'];return[];}export function assembleMerchantBehavior(a,b,c){const d=c?toReputation(c):undefined,e=reputationRedFlags(d);if(b&&b['length']>0x0){const l=b['length'],m=b['filter'](v=>v['status']==='completed')['length'],n=b['filter'](v=>v['has_dispute'])['length'],o=b['filter'](v=>v['is_repeat'])['length'],p=l>0x0?m/l:0x0,q=l>0x0?n/l:0x0,r=l>0x0?o/l:0x0,s=Math['floor'](l/0x2);let t='stable';if(l>=0x4&&s>0x0){const v=b['slice'](0x0,s)['filter'](z=>z['has_dispute'])['length'],w=b['slice'](s)['filter'](z=>z['has_dispute'])['length'],x=v/s,y=w/(l-s);if(y<x*0.85)t='improving';else{if(y>x*1.15)t='declining';}}const u=[...e];if(q>0.1)u['push']('dispute_rate_high');if(t==='declining')u['push']('declining_trend');return{'total_orders':l,'completed_rate':p,'dispute_rate':q,'refund_rate':0x0,'arb_loss_rate':0x0,'repeat_buyer_rate':r,'recent_trend':t,'red_flags':u,'reputation':d};}const f=a['filter'](z=>z['type']['includes']('Order')||z['type']['includes']('order')),g=a['filter'](z=>z['type']['includes']('Dispute')||z['type']['includes']('Arb')),h=f['length'],i=g['length'],j=h>0x0?i/h:0x0,k=[...e];if(j>0.1)k['push']('dispute_rate_high');return{'total_orders':h,'completed_rate':h>0x0?Math['max'](0x0,0x1-j):0x0,'dispute_rate':j,'refund_rate':0x0,'arb_loss_rate':0x0,'repeat_buyer_rate':0x0,'recent_trend':'stable','red_flags':k,'reputation':d};}export function assembleMarketContext(a,b){if(a['length']===0x0)return{'similar_services_count':0x0,'avg_price':0x0n,'min_price':0x0n,'max_price':0x0n,'price_percentile':0x0,'supply_demand_ratio':0x0};const c=a['map'](j=>j['price'])['sort']((j,k)=>j<k?-0x1:j>k?0x1:0x0),d=c['reduce']((j,k)=>j+k,0x0n),e=d/BigInt(c['length']),f=c[0x0],g=c[c['length']-0x1];let h=0x0;for(const j of c){if(j<b)h++;}const i=c['length']>0x0?h/c['length']:0x0;return{'similar_services_count':a['length'],'avg_price':e,'min_price':f,'max_price':g,'price_percentile':i,'supply_demand_ratio':a['length']};}export function assembleInfoPuzzle(a,b,c='evaluate'){const d=[],e=assembleServiceBasics(a,b['service'],b['wip_verified']??![]);let f,g,h;if(c==='evaluate'||c==='preorder'||c==='monitor'){b['machine_nodes']?f=assembleWorkflowAnalysis(b['machine_nodes'],b['machine_published']??![],b['machine_paused']??![],b['service']):d['push']('machine_workflow');const m=b['order_amount']??e['price_raw'];g=assembleFundSafety(b['service'],m),b['reviews']&&b['trust_score']?h=assembleTrustSignals(b['service'],b['reviews'],b['trust_score'],b['arbitration_owner'],b['service_owner']):d['push']('reviews_or_trust_score');}let i;if(c==='preorder'||c==='monitor'){if(b['events']||b['order_history'])i=assembleMerchantBehavior(b['events']??[],b['order_history'],b['merchant_reputation']);else b['merchant_reputation']?i=assembleMerchantBehavior([],undefined,b['merchant_reputation']):d['push']('merchant_behavior');}let j;(c==='evaluate'||c==='preorder')&&(b['similar_services']?j=assembleMarketContext(b['similar_services'],e['price_raw']):d['push']('market_context'));let k;b['user_metrics_config']&&b['user_metrics_config']['metrics']['length']>0x0&&(k=assembleUserMetrics(b['user_metrics_config'],b['user_metrics_context']??{}));let l=b['service_nesting'];return!l&&b['service_nesting_raw']&&(l=evaluateServiceNesting(b['service_nesting_raw'])),{'service_id':a,'service_basics':e,'workflow_analysis':f,'fund_safety':g,'trust_signals':h,'merchant_behavior':i,'market_context':j,'user_metrics':k,'service_nesting':l,'completeness':computeCompleteness(c,[e,f,g,h,i,j,k,l]),'gaps':d,'assembled_at':Date['now']()};}export function assembleUserMetrics(a,b){const c=a['adjustment_cap']??0xa,d=[],e=a['metrics']['reduce']((i,j)=>i+Math['max'](0x0,j['weight']),0x0);for(const i of a['metrics']){const j=e>0x0?Math['max'](0x0,i['weight'])/e:0x0,k=resolvePath(b,i['params']['path']??i['name']),{passed:l,score:m,observed_value:n}=evaluateMetric(i,k);d['push']({'name':i['name'],'label':i['label'],'passed':l,'score':m,'observed_value':formatObservedValue(k),'weight':j,'advice':l?i['advice_on_pass']:i['advice_on_fail']});}const f=d['reduce']((o,p)=>o+p['score']*p['weight'],0x0),g=Math['round'](f*0x64),h=Math['round']((g-0x32)/0x32*c);return{'metrics':d,'score':g,'adjustment':h,'source_file':a['source_file'],'evaluated_at':Date['now']()};}function resolvePath(a,b){if(!b)return undefined;const c=b['split']('.');let d=a;for(const e of c){if(d===null||d===undefined)return undefined;if(typeof d!=='object')return undefined;d=d[e];}return d;}function evaluateMetric(a,b){const c=a['params'];switch(a['evaluator']){case'threshold':{const d=typeof b==='number'?b:typeof b==='string'?Number(b):typeof b==='bigint'?Number(b):NaN,e=typeof c['threshold']==='number'?c['threshold']:typeof c['threshold']==='string'?Number(c['threshold']):NaN;if(isNaN(d)||isNaN(e))return{'passed':![],'score':0x0,'observed_value':b};const f=c['invert']?d<=e:d>=e,g=Math['abs'](e)*0.5||0x1,h=c['invert']?(e-d)/g+0x1:(d-e)/g+0x1,i=Math['max'](0x0,Math['min'](0x1,h));return{'passed':f,'score':i,'observed_value':b};}case'ratio':{const j=typeof b==='number'?b:typeof b==='string'?Number(b):NaN,k=c['min']??0x0,l=c['max']??0x1;if(isNaN(j))return{'passed':![],'score':0x0,'observed_value':b};const m=j>=k&&j<=l,n=l-k,o=(k+l)/0x2,q=n>0x0?Math['max'](0x0,0x1-Math['abs'](j-o)/(n/0x2)):0x1;return{'passed':m,'score':q,'observed_value':b};}case'boolean':{const r=!!b;return{'passed':r,'score':r?0x1:0x0,'observed_value':b};}case'presence':{const s=b!==undefined&&b!==null&&b!=='';return{'passed':s,'score':s?0x1:0x0,'observed_value':b};}case'regex_match':{if(typeof b!=='string'||!c['pattern'])return{'passed':![],'score':0x0,'observed_value':b};try{const t=new RegExp(c['pattern']),u=t['test'](b);return{'passed':u,'score':u?0x1:0x0,'observed_value':b};}catch{return{'passed':![],'score':0x0,'observed_value':b};}}case'custom_query':{return{'passed':![],'score':0.5,'observed_value':b};}default:return{'passed':![],'score':0x0,'observed_value':b};}}function formatObservedValue(a){if(typeof a==='string'||typeof a==='number'||typeof a==='boolean')return a;if(typeof a==='bigint')return a['toString']();if(a===undefined||a===null)return undefined;try{return JSON['stringify'](a);}catch{return String(a);}}function computeCompleteness(a,b){const c=a==='browse'?0x1:a==='evaluate'?0x4:a==='preorder'?0x6:0x5,d=b['slice'](0x0,c),e=d['filter'](f=>f!==undefined&&f!==null)['length'];return Math['min'](0x1,e/c);}export function evaluateServiceNesting(b){const c=b['depth']??0x0,d=b['maxDepth']??0x3,e=c>=d,f={'arbitrations':[],'rewards':[],'repositories':[]};let g=0x0;if(b['machine']){const v=b['machine'],w=[];let x=0x0;if(v['published'])x+=0xa;else w['push']('Machine\x20not\x20published');v['paused']&&(x+=0x28,w['push']('Machine\x20paused'));v['has_no_entry']&&(x+=0x32,w['push']('No\x20entry\x20point\x20(R-M1-01)'));v['has_no_terminal']&&(x+=0x32,w['push']('No\x20terminal\x20node\x20(R-M1-02)'));v['has_dispute_anti_pattern']&&(x+=0x3c,w['push']('Dispute\x20anti-pattern\x20(R-M1-11):\x20machine\x20illegally\x20models\x20dispute\x20flow'));const y=v['structural_issue_count']??0x0;y>0x0&&(x+=y*0xf,w['push'](y+'\x20structural\x20issue(s)\x20detected\x20(cycles/dead-ends/orphans)')),x=Math['min'](0x64,x),f['machine']={'object_id':v['object_id'],'published':v['published'],'risk_level':scoreToNestingLevel(x),'issues':w},g++;}for(const z of b['arbitrations']??[]){const A=[];let B=0x0;if(z['voting_guard_count']===0x0)B+=0x32,A['push']('No\x20voting_guard\x20configured\x20โ€”\x20no\x20arbitrators\x20can\x20vote');else z['voting_guard_count']<=0x2?(B+=0x1e,A['push']('Few\x20arbitrators\x20(<=2)\x20โ€”\x20limited\x20dispute\x20resolution\x20capacity')):B+=0xa;z['paused']&&(B+=0x28,A['push']('Arbitration\x20paused\x20โ€”\x20disputes\x20cannot\x20be\x20filed')),z['fee_balance']===0x0n&&(B+=0x1e,A['push']('No\x20compensation\x20fund\x20balance\x20โ€”\x20rulings\x20cannot\x20pay\x20out')),B=Math['min'](0x64,B),f['arbitrations']['push']({'object_id':z['object_id'],'voting_guard_count':z['voting_guard_count'],'fee_balance':z['fee_balance']['toString'](),'paused':z['paused'],'risk_level':scoreToNestingLevel(B),'issues':A}),g++;}for(const C of b['rewards']??[]){const D=[];let E=0x0;C['balance']===0x0n&&(E+=0x3c,D['push']('Reward\x20fund\x20empty\x20โ€”\x20claims\x20will\x20fail')),C['guard_count']===0x0&&(E+=0x32,D['push']('No\x20claim_guard\x20โ€”\x20anyone\x20could\x20claim\x20(or\x20no\x20one\x20can,\x20depending\x20on\x20default)')),C['expiration_time']&&C['expiration_time']>0x0&&C['expiration_time']<Date['now']()&&(E+=0x28,D['push']('Reward\x20expired\x20โ€”\x20claims\x20no\x20longer\x20possible')),E=Math['min'](0x64,E),f['rewards']['push']({'object_id':C['object_id'],'balance':C['balance']['toString'](),'guard_count':C['guard_count'],'risk_level':scoreToNestingLevel(E),'issues':D}),g++;}for(const F of b['repositories']??[]){const G=[];let H=0x0;!F['has_write_guard']&&(H+=0x28,G['push']('No\x20write_guard\x20โ€”\x20Repository\x20is\x20open\x20to\x20arbitrary\x20writes')),F['is_empty']&&(H+=0x14,G['push']('Repository\x20empty\x20โ€”\x20no\x20historical\x20data\x20for\x20evaluation')),H=Math['min'](0x64,H),f['repositories']['push']({'object_id':F['object_id'],'risk_level':scoreToNestingLevel(H),'issues':G}),g++;}if(g===0x0)return undefined;const h=f['machine']?nestingLevelToScore(f['machine']['risk_level']):0x0,i=f['machine']?0x23:0x0,j=f['arbitrations']['length']>0x0?Math['max'](...f['arbitrations']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,k=f['arbitrations']['length']>0x0?0x1e:0x0,l=f['rewards']['length']>0x0?Math['max'](...f['rewards']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,n=f['rewards']['length']>0x0?0x14:0x0,o=f['repositories']['length']>0x0?Math['max'](...f['repositories']['map'](I=>nestingLevelToScore(I['risk_level']))):0x0,p=f['repositories']['length']>0x0?0xf:0x0,q=i+k+n+p,s=q>0x0?Math['round']((h*i+j*k+l*n+o*p)/q):0x0,t=[];if(f['machine'])t['push'](f['machine']['risk_level']);for(const I of f['arbitrations'])t['push'](I['risk_level']);for(const J of f['rewards'])t['push'](J['risk_level']);for(const K of f['repositories'])t['push'](K['risk_level']);const u=t['reduce'](highestLevel,'low');return{'depth_reached':c,'truncated':e,'bindings':f,'overall_risk_level':u,'overall_risk_score':s,'total_bindings_evaluated':g,'evaluated_at':Date['now']()};}function scoreToNestingLevel(a){if(a>=0x4b)return'critical';if(a>=0x32)return'high';if(a>=0x19)return'medium';return'low';}function nestingLevelToScore(a){switch(a){case'critical':return 0x5a;case'high':return 0x41;case'medium':return 0x28;case'low':return 0xa;}}function highestLevel(c,d){const e={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3};return e[c]>=e[d]?c:d;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -19,7 +19,7 @@ export declare function flowMigrationStrategy(puzzle: InfoPuzzle): {
19
19
  risk: "low" | "medium" | "high";
20
20
  advice: string;
21
21
  };
22
- export declare function repeatGameStrategy(puzzle: InfoPuzzle, history: {
22
+ export declare function repeatGameStrategy(_puzzle: InfoPuzzle, history: {
23
23
  completed: number;
24
24
  disputes: number;
25
25
  refunds: number;
@@ -18,6 +18,8 @@ export interface ReminderContext {
18
18
  risk_score?: number;
19
19
  risk_level?: RiskLevel;
20
20
  has_refund_path?: boolean;
21
+ has_arb_refund_path?: boolean;
22
+ has_refund_allocator?: boolean;
21
23
  has_user_operable?: boolean;
22
24
  has_messenger?: boolean;
23
25
  customer_required?: string[];
@@ -1 +1 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';import{formatAmountText}from'../knowledge/fund-layer.js';const REMINDER_RULES=[{'id':'browse_reviews_summary','stage':'browse','priority':'info','message':a=>'This\x20Service\x20has\x20'+a['review_count']+'\x20reviews,\x20like\x20rate\x20'+Math['round']((a['like_rate']??0x0)*0x64)+'%','applies':a=>(a['review_count']??0x0)>0x0,'dedup_key':'reviews_summary'},{'id':'browse_price_anomaly_low','stage':'browse','priority':'recommended','message':a=>{if(!a['avg_market_price']||!a['service_price']||a['avg_market_price']===0x0n)return'โš ๏ธ\x20Price\x20is\x20abnormally\x20low,\x20beware\x20of\x20quality\x20risk';const b=Number(a['service_price']*0x64n/a['avg_market_price'])/0x64,c=Math['round']((0x1-b)*0x64);return'โš ๏ธ\x20Price\x20is\x20'+c+'%\x20below\x20the\x20average\x20for\x20similar\x20services,\x20beware\x20of\x20quality\x20risk';},'applies':a=>{if(!a['avg_market_price']||!a['service_price'])return![];if(a['avg_market_price']===0x0n)return![];const b=Number(a['service_price']*0x64n/a['avg_market_price'])/0x64;return b<0.6;},'dedup_key':'price_anomaly'},{'id':'browse_no_arbitration','stage':'browse','priority':'recommended','message':'โš ๏ธ\x20This\x20Service\x20has\x20no\x20arbitration\x20configured;\x20disputes\x20have\x20no\x20resolution\x20channel','applies':a=>a['has_arbitration']===![],'dedup_key':'no_arbitration'},{'id':'browse_no_compensation','stage':'browse','priority':'recommended','message':'โš ๏ธ\x20This\x20Service\x20has\x20no\x20compensation\x20fund;\x20no\x20automatic\x20payout\x20source\x20if\x20the\x20order\x20fails','applies':a=>a['has_compensation']===![],'dedup_key':'no_compensation'},{'id':'evaluate_checklist','stage':'evaluate','priority':'info','message':'๐Ÿ“‹\x20Running\x204-dimension\x20risk\x20check\x20(workflow/fund/trust/behavior)...','applies':()=>!![],'dedup_key':'checklist_start'},{'id':'evaluate_high_risk','stage':'evaluate','priority':'required','message':a=>'๐Ÿ”ด\x20Composite\x20risk\x20score\x20'+a['risk_score']+'/100,\x20strongly\x20recommend\x20not\x20purchasing','applies':a=>(a['risk_level']??'low')==='high','dedup_key':'high_risk_score'},{'id':'evaluate_medium_high_risk','stage':'evaluate','priority':'recommended','message':a=>'๐ŸŸ \x20Composite\x20risk\x20score\x20'+a['risk_score']+'/100,\x20purchase\x20with\x20caution\x20and\x20focus\x20on\x202-3\x20key\x20risks','applies':a=>(a['risk_level']??'low')==='medium_high','dedup_key':'medium_high_risk'},{'id':'evaluate_ambiguous_guard','stage':'evaluate','priority':'required','message':a=>'๐Ÿ”ด\x20Detected\x20'+(a['ambiguous_guards']?.['length']??0x0)+'\x20ambiguous\x20Guard(s);\x20manual\x20review\x20is\x20required\x20before\x20proceeding:\x20'+(a['ambiguous_guards']?.['join'](',\x20')??''),'applies':a=>(a['ambiguous_guards']?.['length']??0x0)>0x0,'dedup_key':'ambiguous_guard'},{'id':'evaluate_no_refund_path','stage':'evaluate','priority':'recommended','message':'โš ๏ธ\x20No\x20refund\x20path:\x20if\x20delivery\x20fails,\x20funds\x20may\x20be\x20unrecoverable.\x20Recommend\x20negotiating\x20refund\x20terms\x20via\x20Messenger','applies':a=>a['has_refund_path']===![],'dedup_key':'no_refund_path'},{'id':'evaluate_no_user_operable','stage':'evaluate','priority':'required','message':'๐Ÿ”ด\x20No\x20user-operable\x20steps\x20in\x20the\x20workflow:\x20order\x20progress\x20depends\x20entirely\x20on\x20the\x20merchant','applies':a=>a['has_user_operable']===![],'dedup_key':'no_user_operable'},{'id':'evaluate_below_min_trust','stage':'evaluate','priority':'required','message':a=>'๐Ÿ”ด\x20Risk\x20score\x20'+a['risk_score']+'\x20is\x20below\x20your\x20minimum\x20requirement\x20of\x20'+a['user_min_trust_score'],'applies':a=>a['user_min_trust_score']!==undefined&&a['risk_score']!==undefined&&a['risk_score']<a['user_min_trust_score'],'dedup_key':'below_min_trust'},{'id':'preorder_payment_confirm','stage':'preorder','priority':'required','message':a=>'๐Ÿ””\x20About\x20to\x20pay\x20'+formatAmountText(a['service_price']??0x0n,a['token']?.['decimals'],a['token']?.['symbol'])+'\x20to\x20the\x20escrow\x20account,\x20please\x20confirm','applies':a=>a['service_price']!==undefined,'dedup_key':'payment_confirm'},{'id':'preorder_compensation_insufficient','stage':'preorder','priority':'recommended','message':a=>'โš ๏ธ\x20Compensation\x20balance\x20only\x20covers\x20'+Math['round']((a['compensation_ratio']??0x0)*0x64)+'%\x20of\x20the\x20order\x20amount','applies':a=>(a['compensation_ratio']??0x1)<0x1,'dedup_key':'compensation_insufficient'},{'id':'preorder_user_require_arb_missing','stage':'preorder','priority':'required','message':'๐Ÿ”ด\x20Your\x20preferences\x20require\x20arbitration,\x20but\x20this\x20Service\x20does\x20not\x20have\x20it\x20configured','applies':a=>a['user_require_arbitration']===!![]&&a['has_arbitration']===![],'dedup_key':'user_require_arb_missing'},{'id':'preorder_user_require_comp_missing','stage':'preorder','priority':'required','message':'๐Ÿ”ด\x20Your\x20preferences\x20require\x20a\x20compensation\x20fund,\x20but\x20this\x20Service\x20has\x20none','applies':a=>a['user_require_compensation']===!![]&&a['has_compensation']===![],'dedup_key':'user_require_comp_missing'},{'id':'preorder_no_messenger','stage':'preorder','priority':'recommended','message':'โš ๏ธ\x20Merchant\x20has\x20no\x20Messenger\x20channel;\x20no\x20way\x20to\x20negotiate\x20or\x20get\x20post-sale\x20support\x20after\x20ordering','applies':a=>a['has_messenger']===![],'dedup_key':'no_messenger'},{'id':'preorder_customer_required_no_contact','stage':'preorder','priority':'required','message':a=>'๐Ÿ”ด\x20This\x20Service\x20requires\x20private\x20information\x20('+(a['customer_required']??[])['join'](',\x20')+'),\x20'+'but\x20it\x20has\x20NO\x20Contact/Messenger\x20channel\x20configured.\x20Your\x20private\x20information\x20cannot\x20be\x20delivered\x20securely\x20'+'โ€”\x20do\x20NOT\x20order\x20until\x20the\x20merchant\x20binds\x20a\x20Contact\x20(um)\x20so\x20the\x20info\x20can\x20be\x20sent\x20end-to-end\x20encrypted.','applies':a=>(a['customer_required']?.['length']??0x0)>0x0&&a['has_messenger']===![],'dedup_key':'customer_required_no_contact'},{'id':'preorder_customer_required_send_info','stage':'preorder','priority':'recommended','message':a=>'๐Ÿ”\x20After\x20ordering\x20you\x20MUST\x20send\x20your\x20private\x20information\x20('+(a['customer_required']??[])['join'](',\x20')+')\x20'+'to\x20the\x20merchant\x27s\x20Contact\x20via\x20end-to-end\x20encrypted\x20Messenger,\x20and\x20obtain\x20a\x20confirmation\x20reply.\x20'+'Your\x20private\x20information\x20is\x20encrypted\x20end-to-end\x20and\x20never\x20stored\x20in\x20plaintext\x20by\x20the\x20service.','applies':a=>(a['customer_required']?.['length']??0x0)>0x0&&a['has_messenger']===!![],'dedup_key':'customer_required_send_info'},{'id':'in_progress_progress_stalled','stage':'in_progress','priority':'recommended','message':a=>'โš ๏ธ\x20Order\x20has\x20been\x20stuck\x20at\x20node\x20'+a['current_node']+'\x20for\x20over\x20'+a['hours_since_last_progress']+'\x20hours,\x20suggest\x20contacting\x20the\x20merchant','applies':a=>{const b=a['hours_since_last_progress']??0x0,c=a['expected_progress_hours']??0x18;return b>c*0x2;},'dedup_key':'progress_stalled'},{'id':'in_progress_compensation_drop','stage':'in_progress','priority':'recommended','message':'โš ๏ธ\x20Merchant\x20compensation\x20fund\x20balance\x20dropped\x2030%,\x20please\x20note','applies':()=>![],'dedup_key':'compensation_drop'},{'id':'in_progress_user_action_required','stage':'in_progress','priority':'reminder','message':a=>'๐Ÿ””\x20Order\x20advanced\x20to\x20node\x20'+a['current_node']+',\x20your\x20action\x20is\x20required','applies':a=>a['current_node']!==undefined&&a['current_node']!=='','dedup_key':'user_action_required'},{'id':'in_progress_messenger_unanswered','stage':'in_progress','priority':'recommended','message':a=>'โš ๏ธ\x20Merchant\x20has\x20not\x20replied\x20on\x20Messenger\x20for\x20'+a['hours_since_messenger_reply']+'\x20hours;\x20consider\x20initiating\x20arbitration','applies':a=>(a['hours_since_messenger_reply']??0x0)>0x18,'dedup_key':'messenger_unanswered'},{'id':'complete_review_reminder','stage':'complete','priority':'info','message':'๐Ÿ’ก\x20Order\x20completed,\x20would\x20you\x20like\x20to\x20submit\x20a\x20review?','applies':()=>!![],'dedup_key':'review_reminder'},{'id':'complete_review_window','stage':'complete','priority':'reminder','message':a=>'โฐ\x20The\x20review\x20window\x20will\x20close\x20in\x20'+a['review_window_days']+'\x20days','applies':a=>(a['review_window_days']??0x0)>0x0,'dedup_key':'review_window'},{'id':'after_sale_arb_window','stage':'after_sale','priority':'reminder','message':a=>'โฐ\x20The\x20arbitration\x20application\x20window\x20will\x20close\x20in\x20'+a['arb_window_days']+'\x20day(s)','applies':a=>(a['arb_window_days']??0x0)>0x0,'dedup_key':'arb_window'},{'id':'after_sale_refund_received','stage':'after_sale','priority':'info','message':'โœ…\x20Refund\x20received','applies':()=>![],'dedup_key':'refund_received'}];export function generateReminders(a){const b=REMINDER_RULES['filter'](e=>e['stage']===a['stage']),c=new Map();for(const e of b){if(!e['applies'](a))continue;const f=c['get'](e['dedup_key']);(!f||priorityRank(e['priority'])>priorityRank(f['priority']))&&c['set'](e['dedup_key'],e);}const d=Array['from'](c['values']())['map'](g=>({'id':g['id'],'stage':g['stage'],'priority':g['priority'],'message':typeof g['message']==='function'?g['message'](a):g['message'],'action':g['action']}));return sortAndCapReminders(d);}export function sortAndCapReminders(a){const b=[...a]['sort']((f,g)=>priorityRank(g['priority'])-priorityRank(f['priority'])),c=b['filter'](f=>f['priority']==='required'||f['priority']==='recommended'),d=b['filter'](f=>f['priority']==='info'||f['priority']==='reminder'),e=c['slice'](0x0,0x3);return[...e,...d];}function priorityRank(a){switch(a){case'required':return 0x4;case'recommended':return 0x3;case'info':return 0x2;case'reminder':return 0x1;}}export function generateMultiStageReminders(a,b=[]){const c=[a['stage'],...b],d=[],e=new Set();for(const f of c){const g={...a,'stage':f},h=generateReminders(g);for(const i of h){const j=f+':'+i['id'];!e['has'](j)&&(e['add'](j),d['push'](i));}}return d;}export function isBlocking(a){return a['priority']==='required';}export function getBlockingReminders(a){return a['filter'](isBlocking);}export function summarizeReminders(a){if(a['length']===0x0)return'No\x20reminders';const b=a['filter'](g=>g['priority']==='required'),c=a['filter'](g=>g['priority']==='recommended'),d=a['filter'](g=>g['priority']==='info'),e=a['filter'](g=>g['priority']==='reminder'),f=[];if(b['length'])f['push']('๐Ÿ”ด\x20Must-read:\x20'+b['length']);if(c['length'])f['push']('โš ๏ธ\x20Recommended:\x20'+c['length']);if(d['length'])f['push']('๐Ÿ’ก\x20Info:\x20'+d['length']);if(e['length'])f['push']('๐Ÿ””\x20Reminder:\x20'+e['length']);return f['join'](',\x20');}export function topReminders(a,b=0x5){return sortAndCapReminders(a)['slice'](0x0,b);}export{CUSTOMER_INTELLIGENCE_VERSION};
1
+ import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';import{formatAmountText}from'../knowledge/fund-layer.js';const REMINDER_RULES=[{'id':'browse_reviews_summary','stage':'browse','priority':'info','message':a=>'This\x20Service\x20has\x20'+a['review_count']+'\x20reviews,\x20like\x20rate\x20'+Math['round']((a['like_rate']??0x0)*0x64)+'%','applies':a=>(a['review_count']??0x0)>0x0,'dedup_key':'reviews_summary'},{'id':'browse_price_anomaly_low','stage':'browse','priority':'recommended','message':a=>{if(!a['avg_market_price']||!a['service_price']||a['avg_market_price']===0x0n)return'โš ๏ธ\x20Price\x20is\x20abnormally\x20low,\x20beware\x20of\x20quality\x20risk';const b=Number(a['service_price']*0x64n/a['avg_market_price'])/0x64,c=Math['round']((0x1-b)*0x64);return'โš ๏ธ\x20Price\x20is\x20'+c+'%\x20below\x20the\x20average\x20for\x20similar\x20services,\x20beware\x20of\x20quality\x20risk';},'applies':a=>{if(!a['avg_market_price']||!a['service_price'])return![];if(a['avg_market_price']===0x0n)return![];const b=Number(a['service_price']*0x64n/a['avg_market_price'])/0x64;return b<0.6;},'dedup_key':'price_anomaly'},{'id':'browse_no_arbitration','stage':'browse','priority':'recommended','message':'โš ๏ธ\x20This\x20Service\x20has\x20no\x20arbitration\x20configured;\x20disputes\x20have\x20no\x20resolution\x20channel','applies':a=>a['has_arbitration']===![],'dedup_key':'no_arbitration'},{'id':'browse_no_compensation','stage':'browse','priority':'recommended','message':'โš ๏ธ\x20This\x20Service\x20has\x20no\x20compensation\x20fund;\x20no\x20automatic\x20payout\x20source\x20if\x20the\x20order\x20fails','applies':a=>a['has_compensation']===![],'dedup_key':'no_compensation'},{'id':'evaluate_checklist','stage':'evaluate','priority':'info','message':'๐Ÿ“‹\x20Running\x204-dimension\x20risk\x20check\x20(workflow/fund/trust/behavior)...','applies':()=>!![],'dedup_key':'checklist_start'},{'id':'evaluate_high_risk','stage':'evaluate','priority':'required','message':a=>'๐Ÿ”ด\x20Composite\x20risk\x20score\x20'+a['risk_score']+'/100,\x20strongly\x20recommend\x20not\x20purchasing','applies':a=>(a['risk_level']??'low')==='high','dedup_key':'high_risk_score'},{'id':'evaluate_medium_high_risk','stage':'evaluate','priority':'recommended','message':a=>'๐ŸŸ \x20Composite\x20risk\x20score\x20'+a['risk_score']+'/100,\x20purchase\x20with\x20caution\x20and\x20focus\x20on\x202-3\x20key\x20risks','applies':a=>(a['risk_level']??'low')==='medium_high','dedup_key':'medium_high_risk'},{'id':'evaluate_ambiguous_guard','stage':'evaluate','priority':'required','message':a=>'๐Ÿ”ด\x20Detected\x20'+(a['ambiguous_guards']?.['length']??0x0)+'\x20ambiguous\x20Guard(s);\x20manual\x20review\x20is\x20required\x20before\x20proceeding:\x20'+(a['ambiguous_guards']?.['join'](',\x20')??''),'applies':a=>(a['ambiguous_guards']?.['length']??0x0)>0x0,'dedup_key':'ambiguous_guard'},{'id':'evaluate_no_refund_path','stage':'evaluate','priority':'recommended','message':'โš ๏ธ\x20No\x20refund\x20path:\x20if\x20delivery\x20fails,\x20funds\x20may\x20be\x20unrecoverable.\x20Recommend\x20negotiating\x20refund\x20terms\x20via\x20Messenger','applies':a=>a['has_refund_path']===![],'dedup_key':'no_refund_path'},{'id':'evaluate_refund_conditions','stage':'evaluate','priority':'info','message':a=>{const b=[];a['has_arb_refund_path']&&b['push']('Arbitration-backed\x20(dispute\x20โ†’\x20ruling\x20โ†’\x20compensation\x20payout)');a['has_refund_allocator']&&b['push']('refund-to-order\x20Allocator\x20(cancel/refund\x20returns\x20funds)');if(b['length']===0x0)return'';return'Refund\x20conditions:\x20'+b['join'](';\x20')+'.';},'applies':a=>a['has_refund_path']===!![]&&(a['has_arb_refund_path']===!![]||a['has_refund_allocator']===!![]),'dedup_key':'refund_conditions'},{'id':'evaluate_no_user_operable','stage':'evaluate','priority':'required','message':'๐Ÿ”ด\x20No\x20user-operable\x20steps\x20in\x20the\x20workflow:\x20order\x20progress\x20depends\x20entirely\x20on\x20the\x20merchant','applies':a=>a['has_user_operable']===![],'dedup_key':'no_user_operable'},{'id':'evaluate_below_min_trust','stage':'evaluate','priority':'required','message':a=>'๐Ÿ”ด\x20Risk\x20score\x20'+a['risk_score']+'\x20is\x20below\x20your\x20minimum\x20requirement\x20of\x20'+a['user_min_trust_score'],'applies':a=>a['user_min_trust_score']!==undefined&&a['risk_score']!==undefined&&a['risk_score']<a['user_min_trust_score'],'dedup_key':'below_min_trust'},{'id':'preorder_payment_confirm','stage':'preorder','priority':'required','message':a=>'๐Ÿ””\x20About\x20to\x20pay\x20'+formatAmountText(a['service_price']??0x0n,a['token']?.['decimals'],a['token']?.['symbol'])+'\x20to\x20the\x20escrow\x20account,\x20please\x20confirm','applies':a=>a['service_price']!==undefined,'dedup_key':'payment_confirm'},{'id':'preorder_compensation_insufficient','stage':'preorder','priority':'recommended','message':a=>'โš ๏ธ\x20Compensation\x20balance\x20only\x20covers\x20'+Math['round']((a['compensation_ratio']??0x0)*0x64)+'%\x20of\x20the\x20order\x20amount','applies':a=>(a['compensation_ratio']??0x1)<0x1,'dedup_key':'compensation_insufficient'},{'id':'preorder_user_require_arb_missing','stage':'preorder','priority':'required','message':'๐Ÿ”ด\x20Your\x20preferences\x20require\x20arbitration,\x20but\x20this\x20Service\x20does\x20not\x20have\x20it\x20configured','applies':a=>a['user_require_arbitration']===!![]&&a['has_arbitration']===![],'dedup_key':'user_require_arb_missing'},{'id':'preorder_user_require_comp_missing','stage':'preorder','priority':'required','message':'๐Ÿ”ด\x20Your\x20preferences\x20require\x20a\x20compensation\x20fund,\x20but\x20this\x20Service\x20has\x20none','applies':a=>a['user_require_compensation']===!![]&&a['has_compensation']===![],'dedup_key':'user_require_comp_missing'},{'id':'preorder_no_messenger','stage':'preorder','priority':'recommended','message':'โš ๏ธ\x20Merchant\x20has\x20no\x20Messenger\x20channel;\x20no\x20way\x20to\x20negotiate\x20or\x20get\x20post-sale\x20support\x20after\x20ordering','applies':a=>a['has_messenger']===![],'dedup_key':'no_messenger'},{'id':'preorder_customer_required_no_contact','stage':'preorder','priority':'required','message':a=>'๐Ÿ”ด\x20This\x20Service\x20requires\x20private\x20information\x20('+(a['customer_required']??[])['join'](',\x20')+'),\x20'+'but\x20it\x20has\x20NO\x20Contact/Messenger\x20channel\x20configured.\x20Your\x20private\x20information\x20cannot\x20be\x20delivered\x20securely\x20'+'โ€”\x20do\x20NOT\x20order\x20until\x20the\x20merchant\x20binds\x20a\x20Contact\x20(um)\x20so\x20the\x20info\x20can\x20be\x20sent\x20end-to-end\x20encrypted.','applies':a=>(a['customer_required']?.['length']??0x0)>0x0&&a['has_messenger']===![],'dedup_key':'customer_required_no_contact'},{'id':'preorder_customer_required_send_info','stage':'preorder','priority':'recommended','message':a=>'๐Ÿ”\x20After\x20ordering\x20you\x20MUST\x20send\x20your\x20private\x20information\x20('+(a['customer_required']??[])['join'](',\x20')+')\x20'+'to\x20the\x20merchant\x27s\x20Contact\x20via\x20end-to-end\x20encrypted\x20Messenger,\x20and\x20obtain\x20a\x20confirmation\x20reply.\x20'+'Your\x20private\x20information\x20is\x20encrypted\x20end-to-end\x20and\x20never\x20stored\x20in\x20plaintext\x20by\x20the\x20service.','applies':a=>(a['customer_required']?.['length']??0x0)>0x0&&a['has_messenger']===!![],'dedup_key':'customer_required_send_info'},{'id':'in_progress_progress_stalled','stage':'in_progress','priority':'recommended','message':a=>'โš ๏ธ\x20Order\x20has\x20been\x20stuck\x20at\x20node\x20'+a['current_node']+'\x20for\x20over\x20'+a['hours_since_last_progress']+'\x20hours,\x20suggest\x20contacting\x20the\x20merchant','applies':a=>{const b=a['hours_since_last_progress']??0x0,c=a['expected_progress_hours']??0x18;return b>c*0x2;},'dedup_key':'progress_stalled'},{'id':'in_progress_compensation_drop','stage':'in_progress','priority':'recommended','message':'โš ๏ธ\x20Merchant\x20compensation\x20fund\x20balance\x20dropped\x2030%,\x20please\x20note','applies':()=>![],'dedup_key':'compensation_drop'},{'id':'in_progress_user_action_required','stage':'in_progress','priority':'reminder','message':a=>'๐Ÿ””\x20Order\x20advanced\x20to\x20node\x20'+a['current_node']+',\x20your\x20action\x20is\x20required','applies':a=>a['current_node']!==undefined&&a['current_node']!=='','dedup_key':'user_action_required'},{'id':'in_progress_messenger_unanswered','stage':'in_progress','priority':'recommended','message':a=>'โš ๏ธ\x20Merchant\x20has\x20not\x20replied\x20on\x20Messenger\x20for\x20'+a['hours_since_messenger_reply']+'\x20hours;\x20consider\x20initiating\x20arbitration','applies':a=>(a['hours_since_messenger_reply']??0x0)>0x18,'dedup_key':'messenger_unanswered'},{'id':'complete_review_reminder','stage':'complete','priority':'info','message':'๐Ÿ’ก\x20Order\x20completed,\x20would\x20you\x20like\x20to\x20submit\x20a\x20review?','applies':()=>!![],'dedup_key':'review_reminder'},{'id':'complete_review_window','stage':'complete','priority':'reminder','message':a=>'โฐ\x20The\x20review\x20window\x20will\x20close\x20in\x20'+a['review_window_days']+'\x20days','applies':a=>(a['review_window_days']??0x0)>0x0,'dedup_key':'review_window'},{'id':'after_sale_arb_window','stage':'after_sale','priority':'reminder','message':a=>'โฐ\x20The\x20arbitration\x20application\x20window\x20will\x20close\x20in\x20'+a['arb_window_days']+'\x20day(s)','applies':a=>(a['arb_window_days']??0x0)>0x0,'dedup_key':'arb_window'},{'id':'after_sale_refund_received','stage':'after_sale','priority':'info','message':'โœ…\x20Refund\x20received','applies':()=>![],'dedup_key':'refund_received'}];export function generateReminders(a){const b=REMINDER_RULES['filter'](e=>e['stage']===a['stage']),c=new Map();for(const e of b){if(!e['applies'](a))continue;const f=c['get'](e['dedup_key']);(!f||priorityRank(e['priority'])>priorityRank(f['priority']))&&c['set'](e['dedup_key'],e);}const d=Array['from'](c['values']())['map'](g=>({'id':g['id'],'stage':g['stage'],'priority':g['priority'],'message':typeof g['message']==='function'?g['message'](a):g['message'],'action':g['action']}));return sortAndCapReminders(d);}export function sortAndCapReminders(a){const b=[...a]['sort']((f,g)=>priorityRank(g['priority'])-priorityRank(f['priority'])),c=b['filter'](f=>f['priority']==='required'||f['priority']==='recommended'),d=b['filter'](f=>f['priority']==='info'||f['priority']==='reminder'),e=c['slice'](0x0,0x3);return[...e,...d];}function priorityRank(a){switch(a){case'required':return 0x4;case'recommended':return 0x3;case'info':return 0x2;case'reminder':return 0x1;}}export function generateMultiStageReminders(a,b=[]){const c=[a['stage'],...b],d=[],e=new Set();for(const f of c){const g={...a,'stage':f},h=generateReminders(g);for(const i of h){const j=f+':'+i['id'];!e['has'](j)&&(e['add'](j),d['push'](i));}}return d;}export function isBlocking(a){return a['priority']==='required';}export function getBlockingReminders(a){return a['filter'](isBlocking);}export function summarizeReminders(a){if(a['length']===0x0)return'No\x20reminders';const b=a['filter'](g=>g['priority']==='required'),c=a['filter'](g=>g['priority']==='recommended'),d=a['filter'](g=>g['priority']==='info'),e=a['filter'](g=>g['priority']==='reminder'),f=[];if(b['length'])f['push']('๐Ÿ”ด\x20Must-read:\x20'+b['length']);if(c['length'])f['push']('โš ๏ธ\x20Recommended:\x20'+c['length']);if(d['length'])f['push']('๐Ÿ’ก\x20Info:\x20'+d['length']);if(e['length'])f['push']('๐Ÿ””\x20Reminder:\x20'+e['length']);return f['join'](',\x20');}export function topReminders(a,b=0x5){return sortAndCapReminders(a)['slice'](0x0,b);}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -7,6 +7,7 @@ export declare function assessWorkflowRisk(puzzle: InfoPuzzle): RiskDimensionSco
7
7
  export declare function assessFundRisk(puzzle: InfoPuzzle): RiskDimensionScore;
8
8
  export declare function assessTrustRisk(puzzle: InfoPuzzle): RiskDimensionScore;
9
9
  export declare function assessBehaviorRisk(puzzle: InfoPuzzle): RiskDimensionScore;
10
+ export declare function knowledgeServiceRisks(puzzle: InfoPuzzle): import("../knowledge/service-risk.js").ServiceRisk[];
10
11
  export declare function assessRisk(puzzle: InfoPuzzle): RiskScore;
11
12
  export declare function passesRiskThreshold(score: RiskScore, minLevel?: RiskLevel): boolean;
12
13
  export { CUSTOMER_INTELLIGENCE_VERSION };
@@ -1 +1 @@
1
- import{RISK_LEVELS,RISK_DIMENSION_MAX,CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export function riskLevelFromScore(a){const b=RISK_LEVELS['find'](c=>a>=c['min']);return b?.['level']??'high';}export function riskLevelLabel(a){const b=RISK_LEVELS['find'](c=>c['level']===a);return b?b['color']+'\x20'+b['label']:'๐Ÿ”ด\x20High\x20risk';}export function riskLevelEmoji(a){const b=RISK_LEVELS['find'](c=>c['level']===a);return b?.['color']??'๐Ÿ”ด';}export function assessWorkflowRisk(a){const b=a['workflow_analysis'],c=[],d=b?.['has_arbitration_binding']??b?.['has_arbitration_path']??![];c['push']({'id':'wf_arbitration_binding','dimension':'workflow','description':'Service\x20has\x20Arbitration\x20object\x20bound\x20(dispute\x20independence)','weight':0xa,'passed':d,'advice':d?undefined:'โš ๏ธ\x20No\x20Arbitration\x20binding:\x20disputes\x20cannot\x20be\x20escalated\x20to\x20third-party\x20arbitration.\x20Recommend\x20requiring\x20the\x20merchant\x20to\x20bind\x20an\x20Arbitration\x20service\x20(with\x20voting_guard\x20config)\x20before\x20ordering.\x20Dispute\x20is\x20filed\x20via\x20arbitration::dispute(order,\x20arbitration),\x20independent\x20of\x20the\x20machine\x20workflow.'});const e=b?.['has_refund_path']??![];c['push']({'id':'wf_refund_path','dimension':'workflow','description':'Refund\x20path\x20exists\x20(Arbitration+compensation_fund\x20OR\x20refund\x20Allocator)','weight':0xa,'passed':e,'advice':e?undefined:'โš ๏ธ\x20No\x20refund\x20path:\x20if\x20delivery\x20fails,\x20funds\x20may\x20not\x20be\x20recoverable.\x20Either\x20(a)\x20bind\x20Arbitration\x20AND\x20deposit\x20compensation_fund,\x20or\x20(b)\x20configure\x20a\x20refund-to-order\x20Allocator.\x20Refund\x20via\x20arbitration\x20flows:\x20dispute\x20โ†’\x20arbitration()\x20ruling\x20with\x20indemnity\x20โ†’\x20arb_withdraw\x20by\x20order\x20holder.'});const f=b?.['user_operable_forwards']??0x0;c['push']({'id':'wf_user_operable','dimension':'workflow','description':'At\x20least\x201\x20user-operable\x20Forward','weight':0x8,'passed':f>0x0,'advice':f>0x0?undefined:'๐Ÿ”ด\x20No\x20user-operable\x20steps\x20in\x20the\x20workflow:\x20order\x20progress\x20depends\x20entirely\x20on\x20the\x20merchant,\x20leaving\x20you\x20in\x20a\x20passive\x20position.'});const g=b?.['dead_end_nodes']??[],h=g['length']===0x0;c['push']({'id':'wf_no_dead_ends','dimension':'workflow','description':'No\x20potential\x20dead-end\x20nodes','weight':0x4,'passed':h,'advice':h?undefined:'โš ๏ธ\x20Detected\x20'+g['length']+'\x20potential\x20dead-end\x20node(s):\x20'+g['join'](',\x20')+'.\x20All\x20exits\x20of\x20these\x20nodes\x20depend\x20on\x20merchant\x20action.'});const i=b?b['machine_published']&&!b['machine_paused']&&!b['has_dispute_anti_pattern']:![];c['push']({'id':'wf_machine_usable','dimension':'workflow','description':'Machine\x20published,\x20not\x20paused,\x20no\x20dispute\x20anti-pattern','weight':0x3,'passed':i,'advice':i?undefined:b?.['has_dispute_anti_pattern']?'๐Ÿ”ด\x20Machine\x20contains\x20dispute\x20anti-pattern\x20nodes\x20(disputed/refunded/arb/arbitration).\x20Dispute\x20is\x20INDEPENDENT\x20of\x20machine\x20โ€”\x20these\x20nodes\x20create\x20dead-end\x20paths\x20because\x20arbitrators\x20are\x20in\x20Arbitration.voting_guard,\x20not\x20Permission.\x20Recommend\x20removing\x20these\x20nodes\x20and\x20binding\x20an\x20Arbitration\x20object\x20to\x20the\x20Service\x20instead.':'โš ๏ธ\x20Machine\x20is\x20not\x20published\x20or\x20is\x20paused:\x20the\x20workflow\x20may\x20not\x20be\x20in\x20effect\x20or\x20has\x20been\x20actively\x20paused\x20by\x20the\x20merchant.'});const j=c['reduce']((k,l)=>k+(l['passed']?l['weight']:0x0),0x0);return{'name':'workflow','score':j,'max_score':RISK_DIMENSION_MAX['workflow'],'checks':c};}export function assessFundRisk(a){const b=a['fund_safety'],c=[];let d=0x0,e;if(b){if(b['compensation_covers_order'])d=0xa;else b['compensation_ratio']>0x0?(d=Math['round'](b['compensation_ratio']*0xa),e='โš ๏ธ\x20Compensation\x20fund\x20covers\x20only\x20'+Math['round'](b['compensation_ratio']*0x64)+'%\x20of\x20the\x20order\x20amount;\x20insufficient\x20for\x20a\x20full\x20payout.'):(d=0x0,e='๐Ÿ”ด\x20No\x20compensation\x20fund:\x20the\x20merchant\x20has\x20not\x20set\x20up\x20a\x20compensation_fund;\x20no\x20automatic\x20payout\x20source\x20if\x20the\x20order\x20fails.');}else d=0x5;c['push']({'id':'fund_compensation','dimension':'fund','description':'Compensation\x20fund\x20adequacy\x20(covers\x20the\x20order\x20amount)','weight':0xa,'passed':d>=0x7,'advice':e});const f=b?.['refund_allocator_exists']??![];c['push']({'id':'fund_refund_allocator','dimension':'fund','description':'100%โ†’Order\x20refund\x20Allocator\x20exists','weight':0x8,'passed':f,'advice':f?undefined:'โš ๏ธ\x20No\x20100%โ†’Order\x20Allocator\x20detected:\x20refunds\x20require\x20manual\x20merchant\x20action\x20or\x20arbitration\x20ruling.'});const g=b?b['price_anomaly']==='none':!![];c['push']({'id':'fund_price_normal','dimension':'fund','description':'No\x20price\x20anomaly\x20(compared\x20with\x20compensation\x20fund\x20and\x20market\x20price)','weight':0x4,'passed':g,'advice':g?undefined:'โš ๏ธ\x20Price\x20anomaly\x20('+b?.['price_anomaly']+'):\x20possible\x20fraudulent\x20pricing\x20or\x20abnormally-low-price\x20lure.'});const h=b?.['lock_duration_safe']??!![];c['push']({'id':'fund_lock_safe','dimension':'fund','description':'Compensation\x20fund\x20lock\x20period\x20is\x20reasonable\x20(โ‰ฅ7\x20days\x20or\x20no\x20lock)','weight':0x3,'passed':h,'advice':h?undefined:'โš ๏ธ\x20Compensation\x20fund\x20lock\x20period\x20is\x20too\x20short:\x20the\x20merchant\x20may\x20withdraw\x20funds\x20at\x20any\x20time.'});const i=c['reduce']((k,l)=>k+(l['passed']?l['weight']:0x0),0x0),j=b&&!b['compensation_covers_order']&&b['compensation_ratio']>0x0?Math['min'](RISK_DIMENSION_MAX['fund'],i+d-(d>=0x7?0xa:0x0)):i;return{'name':'fund','score':j,'max_score':RISK_DIMENSION_MAX['fund'],'checks':c};}export function assessTrustRisk(a){const b=a['trust_signals'],c=[],d=b?.['arbitration_independent']??!![],e=b?.['arbitration_permission_shared']===!![],f=b?.['arbitration_permission_overlap']===!![];let g=d,h,i=0x6;if(e)g=![],h='๐Ÿ”ด\x20CRITICAL:\x20Arbitration\x20and\x20Service\x20share\x20the\x20SAME\x20Permission\x20object.\x20'+'The\x20merchant\x20fully\x20controls\x20arbitration\x20operations\x20(vote,\x20confirm,\x20execute\x20rulings).\x20'+'Dispute\x20fairness\x20cannot\x20be\x20guaranteed.\x20Require\x20the\x20merchant\x20to\x20use\x20a\x20separate,\x20'+'independent\x20Permission\x20object\x20for\x20Arbitration\x20before\x20ordering.';else{if(f)g=![],h='๐Ÿ”ด\x20WARNING:\x20Arbitration\x20and\x20Service\x20have\x20overlapping\x20Permission\x20control\x20'+'(shared\x20owner\x20or\x20admin).\x20Even\x20with\x20separate\x20Permission\x20objects,\x20the\x20merchant\x20can\x20'+'influence\x20dispute\x20outcomes.\x20For\x20mainnet,\x20require\x20completely\x20independent\x20third-party\x20'+'Permission\x20(different\x20owner\x20and\x20admin\x20list)\x20for\x20Arbitration.';else!d&&(h='๐Ÿ”ด\x20Arbitrator\x20and\x20merchant\x20are\x20the\x20same\x20address:\x20arbitration\x20fairness\x20cannot\x20be\x20guaranteed.');}c['push']({'id':'trust_arb_independent','dimension':'trust','description':'Arbitrator\x20has\x20no\x20conflict\x20of\x20interest\x20with\x20the\x20merchant\x20(Permission\x20isolation)','weight':i,'passed':g,'advice':h});let j=![],k;if(b&&b['review_total']>0x0){const q=b['like_rate'];if(q>=0.85)j=!![];else q>=0.6?(j=!![],k='โš ๏ธ\x20Like\x20rate\x20is\x20'+Math['round'](q*0x64)+'%;\x20there\x20is\x20some\x20controversy.'):(j=![],k='๐Ÿ”ด\x20Like\x20rate\x20is\x20only\x20'+Math['round'](q*0x64)+'%\x20('+b['review_likes']+'/'+b['review_total']+');\x20many\x20negative\x20reviews.');}else b?j=!![]:j=!![];c['push']({'id':'trust_review_reputation','dimension':'trust','description':'Good\x20review\x20reputation\x20(like\x20rate\x20โ‰ฅ60%)','weight':0x5,'passed':j,'advice':k});const l=b?.['trust_score']??0x32,m=l>=0x32;c['push']({'id':'trust_score','dimension':'trust','description':'Composite\x20trust\x20score\x20โ‰ฅ50\x20(current\x20'+l+')','weight':0x4,'passed':m,'advice':m?undefined:'๐Ÿ”ด\x20Composite\x20trust\x20score\x20is\x20only\x20'+l+'/100;\x20recommend\x20finding\x20a\x20more\x20trustworthy\x20merchant.'});const n=b?.['has_contact']??![],o=b?.['has_messenger']??![];c['push']({'id':'trust_contact','dimension':'trust','description':'Merchant\x20has\x20a\x20contactable\x20Messenger\x20channel','weight':0x5,'passed':n&&o,'advice':n&&o?undefined:'๐Ÿ”ด\x20Merchant\x20has\x20no\x20contactable\x20channel\x20(um\x20is\x20empty):\x20no\x20way\x20to\x20conduct\x20pre-order\x20negotiation\x20or\x20post-sale\x20communication.'});const p=c['reduce']((r,s)=>r+(s['passed']?s['weight']:0x0),0x0);return{'name':'trust','score':p,'max_score':RISK_DIMENSION_MAX['trust'],'checks':c};}export function assessBehaviorRisk(a){const b=a['merchant_behavior'],c=[];let d=![],e;if(b){if(b['recent_trend']==='improving')d=!![];else b['recent_trend']==='stable'?d=!![]:(d=![],e='๐Ÿ”ด\x20Merchant\x27s\x20recent\x20dispute\x20rate\x20is\x20rising:\x20fulfillment\x20quality\x20may\x20be\x20deteriorating.');}else d=!![];c['push']({'id':'behavior_trend','dimension':'behavior','description':'Recent\x20fulfillment\x20trend\x20is\x20stable\x20or\x20improving','weight':0x6,'passed':d,'advice':e});const f=b!=null&&b['total_orders']>0x0,g=f?b['completed_rate']>=0.85:!![];c['push']({'id':'behavior_completion_rate','dimension':'behavior','description':'Order\x20completion\x20rate\x20โ‰ฅ85%','weight':0x4,'passed':g,'advice':g?undefined:'๐Ÿ”ด\x20Completion\x20rate\x20is\x20only\x20'+Math['round']((b?.['completed_rate']??0x0)*0x64)+'%:\x20a\x20higher-than-average\x20share\x20of\x20orders\x20end\x20in\x20failure.'});const h=f?b['dispute_rate']<=0.1:!![];c['push']({'id':'behavior_low_dispute','dimension':'behavior','description':'Dispute\x20rate\x20โ‰ค10%','weight':0x4,'passed':h,'advice':h?undefined:'โš ๏ธ\x20Dispute\x20rate\x20is\x20'+Math['round']((b?.['dispute_rate']??0x0)*0x64)+'%:\x20above\x20the\x20industry\x20average.'});const i=f?b['arb_loss_rate']<=0.3:!![];c['push']({'id':'behavior_arb_loss','dimension':'behavior','description':'Arbitration\x20loss\x20rate\x20โ‰ค30%','weight':0x3,'passed':i,'advice':i?undefined:'๐Ÿ”ด\x20Arbitration\x20loss\x20rate\x20is\x20'+Math['round']((b?.['arb_loss_rate']??0x0)*0x64)+'%:\x20the\x20merchant\x20has\x20lost\x20multiple\x20arbitration\x20cases,\x20indicating\x20a\x20tendency\x20to\x20violate\x20rules.'});const j=b?b['red_flags']['length']===0x0:!![];c['push']({'id':'behavior_no_red_flags','dimension':'behavior','description':'No\x20behavior\x20red_flags','weight':0x3,'passed':j,'advice':j?undefined:'โš ๏ธ\x20Detected\x20behavioral\x20warning\x20signals:\x20'+b?.['red_flags']['join'](',\x20')});const k=c['reduce']((l,m)=>l+(m['passed']?m['weight']:0x0),0x0);return{'name':'behavior','score':k,'max_score':RISK_DIMENSION_MAX['behavior'],'checks':c};}export function assessRisk(a){const b=[assessWorkflowRisk(a),assessFundRisk(a),assessTrustRisk(a),assessBehaviorRisk(a)],c=b['reduce']((m,n)=>m+n['score'],0x0),d=a['user_metrics']?.['adjustment']??0x0,e=a['service_nesting']?.['overall_risk_score'],g=a['service_nesting']?.['overall_risk_level'],h=a['workflow_analysis']?.['has_wonder_node']?0x2:0x0,i=Math['max'](0x0,Math['min'](0x64,c+d+h)),j=riskLevelFromScore(i),k=[];for(const m of b){for(const n of m['checks']){!n['passed']&&n['advice']&&n['advice']['startsWith']('๐Ÿ”ด')&&k['push']('['+m['name']+']\x20'+n['description']+':\x20'+n['advice']);}}if(a['workflow_analysis']?.['risk_signals']['length'])for(const o of a['workflow_analysis']['risk_signals']){k['push']('[workflow_signal]\x20'+o);}if(a['merchant_behavior']?.['red_flags']['length'])for(const p of a['merchant_behavior']['red_flags']){k['push']('[behavior_flag]\x20'+p);}(g==='high'||g==='critical')&&k['push']('[service_nesting]\x20overall\x20nesting\x20risk:\x20'+g+'\x20(score\x20'+e+')');const l=generateAdvice(a,i,j,b);return{'total':i,'base_total':c,'level':j,'dimensions':b,'user_metrics_adjustment':d,'service_nesting_risk':e,'service_nesting_level':g,'red_flags':k,'advice':l};}function generateAdvice(a,b,c,d){const e=[],f=riskLevelEmoji(c),g=RISK_LEVELS['find'](i=>i['level']===c);e['push'](f+'\x20Composite\x20risk\x20score:\x20'+b+'/100\x20('+(g?.['label']??'unknown')+')');if(c==='high')e['push']('๐Ÿšซ\x20Recommend\x20abandoning\x20this\x20order:\x20the\x20risk\x20level\x20is\x20too\x20high;\x20fund\x20safety\x20cannot\x20be\x20guaranteed.');else{if(c==='medium_high')e['push']('โš ๏ธ\x20Recommend\x20ordering\x20with\x20caution:\x20be\x20sure\x20to\x20negotiate\x20supplementary\x20terms\x20via\x20Messenger\x20and\x20request\x20a\x20WTS\x20evidence\x20file.');else c==='medium_low'?e['push']('โœ…\x20You\x20may\x20order:\x20recommend\x20continuously\x20monitoring\x20order\x20progress\x20and\x20keeping\x20communication\x20records.'):e['push']('โœ…\x20Safe\x20order:\x20you\x20can\x20order\x20with\x20confidence;\x20still\x20recommend\x20enabling\x20order\x20monitoring\x20reminders.');}const h=[...d]['sort']((i,j)=>i['score']/ i['max_score']-j['score']/j['max_score']);for(const i of h){const j=i['max_score']>0x0?i['score']/ i['max_score']:0x0;if(j<0.5){const k=i['checks']['filter'](l=>!l['passed']);if(k['length']>0x0){e['push']('๐Ÿ“Š\x20'+i['name']+'\x20dimension\x20'+i['score']+'/'+i['max_score']+':\x20'+k['length']+'\x20check(s)\x20failed.');const l=k['find'](n=>n['advice']?.['startsWith']('๐Ÿ”ด'));if(l?.['advice'])e['push'](l['advice']);}}}a['completeness']<0.8&&e['push']('โ„น๏ธ\x20Information\x20completeness\x20is\x20only\x20'+Math['round'](a['completeness']*0x64)+'%;\x20missing:\x20'+(a['gaps']['join'](',\x20')||'none')+'.\x20Recommend\x20supplementing\x20data\x20before\x20making\x20a\x20decision.');a['workflow_analysis']?.['has_wonder_node']&&e['push']('๐ŸŒŸ\x20Machine\x20implements\x20wonder/no-wonder\x20praise\x20design:\x20customers\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20(negative\x20review)\x20after\x20completion.\x20Reward\x20objects\x20can\x20claim\x20against\x20Progress.current\x20==\x20\x27wonder\x27\x20to\x20incentivize\x20positive\x20outcomes.');a['workflow_analysis']?.['has_dispute_anti_pattern']&&e['push']('๐Ÿ”ด\x20Machine\x20contains\x20dispute\x20anti-pattern\x20nodes\x20(disputed/refunded/arb/arbitration).\x20Dispute\x20is\x20INDEPENDENT\x20of\x20machine\x20โ€”\x20it\x20flows\x20through\x20Order\x20โ†’\x20Arbitration.dispute()\x20โ†’\x20Arb\x20โ†’\x20arbitration()\x20โ†’\x20arb_withdraw.\x20Arbitrators\x20are\x20configured\x20in\x20Arbitration.voting_guard,\x20NOT\x20in\x20Permission.\x20Recommend\x20the\x20merchant\x20remove\x20these\x20nodes\x20and\x20bind\x20an\x20Arbitration\x20object\x20instead.');if(a['user_metrics']){const n=a['user_metrics'],o=n['metrics']['filter'](p=>p['passed'])['length'];e['push']('๐Ÿ“Š\x20User-customized\x20metrics:\x20'+o+'/'+n['metrics']['length']+'\x20passed\x20(score\x20'+n['score']+'/100,\x20adjustment\x20'+(n['adjustment']>=0x0?'+':'')+n['adjustment']+').'+(n['source_file']?'\x20Source:\x20'+n['source_file']:''));for(const p of n['metrics']){!p['passed']&&p['advice']&&e['push']('\x20\x20\x20โ€ข\x20'+p['label']+':\x20'+p['advice']);}}if(a['service_nesting']){const q=a['service_nesting'];e['push']('๐Ÿ”—\x20Service\x20nesting\x20evaluation:\x20'+q['total_bindings_evaluated']+'\x20bound\x20objects,\x20overall\x20risk\x20'+q['overall_risk_level']+'\x20(score\x20'+q['overall_risk_score']+'/100).'+(q['truncated']?'\x20Recursion\x20truncated\x20at\x20depth\x20limit.':''));}return e;}export function passesRiskThreshold(a,b='medium_high'){const c=['high','medium_high','medium_low','low'],d=c['indexOf'](b),e=c['indexOf'](a['level']);return e>=d;}export{CUSTOMER_INTELLIGENCE_VERSION};
1
+ import{RISK_LEVELS,RISK_DIMENSION_MAX,CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';import{assessServiceRisks}from'../knowledge/service-risk.js';export function riskLevelFromScore(a){const b=RISK_LEVELS['find'](c=>a>=c['min']);return b?.['level']??'high';}export function riskLevelLabel(a){const b=RISK_LEVELS['find'](c=>c['level']===a);return b?b['color']+'\x20'+b['label']:'๐Ÿ”ด\x20High\x20risk';}export function riskLevelEmoji(a){const b=RISK_LEVELS['find'](c=>c['level']===a);return b?.['color']??'๐Ÿ”ด';}export function assessWorkflowRisk(a){const b=a['workflow_analysis'],c=[],d=b?.['has_arbitration_binding']??b?.['has_arbitration_path']??![];c['push']({'id':'wf_arbitration_binding','dimension':'workflow','description':'Service\x20has\x20Arbitration\x20object\x20bound\x20(dispute\x20independence)','weight':0xa,'passed':d,'advice':d?undefined:'โš ๏ธ\x20No\x20Arbitration\x20binding:\x20disputes\x20cannot\x20be\x20escalated\x20to\x20third-party\x20arbitration.\x20Recommend\x20requiring\x20the\x20merchant\x20to\x20bind\x20an\x20Arbitration\x20service\x20(with\x20voting_guard\x20config)\x20before\x20ordering.\x20Dispute\x20is\x20filed\x20via\x20arbitration::dispute(order,\x20arbitration),\x20independent\x20of\x20the\x20machine\x20workflow.'});const e=b?.['has_refund_path']??![];c['push']({'id':'wf_refund_path','dimension':'workflow','description':'Refund\x20path\x20exists\x20(Arbitration+compensation_fund\x20OR\x20refund\x20Allocator)','weight':0xa,'passed':e,'advice':e?undefined:'โš ๏ธ\x20No\x20refund\x20path:\x20if\x20delivery\x20fails,\x20funds\x20may\x20not\x20be\x20recoverable.\x20Either\x20(a)\x20bind\x20Arbitration\x20AND\x20deposit\x20compensation_fund,\x20or\x20(b)\x20configure\x20a\x20refund-to-order\x20Allocator.\x20Refund\x20via\x20arbitration\x20flows:\x20dispute\x20โ†’\x20arbitration()\x20ruling\x20with\x20indemnity\x20โ†’\x20arb_withdraw\x20by\x20order\x20holder.'});const f=b?.['user_operable_forwards']??0x0;c['push']({'id':'wf_user_operable','dimension':'workflow','description':'At\x20least\x201\x20user-operable\x20Forward','weight':0x8,'passed':f>0x0,'advice':f>0x0?undefined:'๐Ÿ”ด\x20No\x20user-operable\x20steps\x20in\x20the\x20workflow:\x20order\x20progress\x20depends\x20entirely\x20on\x20the\x20merchant,\x20leaving\x20you\x20in\x20a\x20passive\x20position.'});const g=b?.['dead_end_nodes']??[],h=g['length']===0x0;c['push']({'id':'wf_no_dead_ends','dimension':'workflow','description':'No\x20potential\x20dead-end\x20nodes','weight':0x4,'passed':h,'advice':h?undefined:'โš ๏ธ\x20Detected\x20'+g['length']+'\x20potential\x20dead-end\x20node(s):\x20'+g['join'](',\x20')+'.\x20All\x20exits\x20of\x20these\x20nodes\x20depend\x20on\x20merchant\x20action.'});const i=b?b['machine_published']&&!b['machine_paused']&&!b['has_dispute_anti_pattern']:![];c['push']({'id':'wf_machine_usable','dimension':'workflow','description':'Machine\x20published,\x20not\x20paused,\x20no\x20dispute\x20anti-pattern','weight':0x3,'passed':i,'advice':i?undefined:b?.['has_dispute_anti_pattern']?'๐Ÿ”ด\x20Machine\x20contains\x20dispute\x20anti-pattern\x20nodes\x20(disputed/refunded/arb/arbitration).\x20Dispute\x20is\x20INDEPENDENT\x20of\x20machine\x20โ€”\x20these\x20nodes\x20create\x20dead-end\x20paths\x20because\x20arbitrators\x20are\x20in\x20Arbitration.voting_guard,\x20not\x20Permission.\x20Recommend\x20removing\x20these\x20nodes\x20and\x20binding\x20an\x20Arbitration\x20object\x20to\x20the\x20Service\x20instead.':'โš ๏ธ\x20Machine\x20is\x20not\x20published\x20or\x20is\x20paused:\x20the\x20workflow\x20may\x20not\x20be\x20in\x20effect\x20or\x20has\x20been\x20actively\x20paused\x20by\x20the\x20merchant.'});const j=c['reduce']((k,l)=>k+(l['passed']?l['weight']:0x0),0x0);return{'name':'workflow','score':j,'max_score':RISK_DIMENSION_MAX['workflow'],'checks':c};}export function assessFundRisk(a){const b=a['fund_safety'],c=[];let d=0x0,e;if(b){if(b['compensation_covers_order'])d=0xa;else b['compensation_ratio']>0x0?(d=Math['round'](b['compensation_ratio']*0xa),e='โš ๏ธ\x20Compensation\x20fund\x20covers\x20only\x20'+Math['round'](b['compensation_ratio']*0x64)+'%\x20of\x20the\x20order\x20amount;\x20insufficient\x20for\x20a\x20full\x20payout.'):(d=0x0,e='๐Ÿ”ด\x20No\x20compensation\x20fund:\x20the\x20merchant\x20has\x20not\x20set\x20up\x20a\x20compensation_fund;\x20no\x20automatic\x20payout\x20source\x20if\x20the\x20order\x20fails.');}else d=0x5;c['push']({'id':'fund_compensation','dimension':'fund','description':'Compensation\x20fund\x20adequacy\x20(covers\x20the\x20order\x20amount)','weight':0xa,'passed':d>=0x7,'advice':e});const f=b?.['refund_allocator_exists']??![];c['push']({'id':'fund_refund_allocator','dimension':'fund','description':'100%โ†’Order\x20refund\x20Allocator\x20exists','weight':0x8,'passed':f,'advice':f?undefined:'โš ๏ธ\x20No\x20100%โ†’Order\x20Allocator\x20detected:\x20refunds\x20require\x20manual\x20merchant\x20action\x20or\x20arbitration\x20ruling.'});const g=b?b['price_anomaly']==='none':!![];c['push']({'id':'fund_price_normal','dimension':'fund','description':'No\x20price\x20anomaly\x20(compared\x20with\x20compensation\x20fund\x20and\x20market\x20price)','weight':0x4,'passed':g,'advice':g?undefined:'โš ๏ธ\x20Price\x20anomaly\x20('+b?.['price_anomaly']+'):\x20possible\x20fraudulent\x20pricing\x20or\x20abnormally-low-price\x20lure.'});const h=b?.['lock_duration_safe']??!![];c['push']({'id':'fund_lock_safe','dimension':'fund','description':'Compensation\x20fund\x20lock\x20period\x20is\x20reasonable\x20(โ‰ฅ7\x20days\x20or\x20no\x20lock)','weight':0x3,'passed':h,'advice':h?undefined:'โš ๏ธ\x20Compensation\x20fund\x20lock\x20period\x20is\x20too\x20short:\x20the\x20merchant\x20may\x20withdraw\x20funds\x20at\x20any\x20time.'});const i=c['reduce']((k,l)=>k+(l['passed']?l['weight']:0x0),0x0),j=b&&!b['compensation_covers_order']&&b['compensation_ratio']>0x0?Math['min'](RISK_DIMENSION_MAX['fund'],i+d-(d>=0x7?0xa:0x0)):i;return{'name':'fund','score':j,'max_score':RISK_DIMENSION_MAX['fund'],'checks':c};}export function assessTrustRisk(a){const b=a['trust_signals'],c=[],d=b?.['arbitration_independent']??!![],e=b?.['arbitration_permission_shared']===!![],f=b?.['arbitration_permission_overlap']===!![];let g=d,h,i=0x6;if(e)g=![],h='๐Ÿ”ด\x20CRITICAL:\x20Arbitration\x20and\x20Service\x20share\x20the\x20SAME\x20Permission\x20object.\x20'+'The\x20merchant\x20fully\x20controls\x20arbitration\x20operations\x20(vote,\x20confirm,\x20execute\x20rulings).\x20'+'Dispute\x20fairness\x20cannot\x20be\x20guaranteed.\x20Require\x20the\x20merchant\x20to\x20use\x20a\x20separate,\x20'+'independent\x20Permission\x20object\x20for\x20Arbitration\x20before\x20ordering.';else{if(f)g=![],h='๐Ÿ”ด\x20WARNING:\x20Arbitration\x20and\x20Service\x20have\x20overlapping\x20Permission\x20control\x20'+'(shared\x20owner\x20or\x20admin).\x20Even\x20with\x20separate\x20Permission\x20objects,\x20the\x20merchant\x20can\x20'+'influence\x20dispute\x20outcomes.\x20The\x20contract\x20only\x20checks\x20Permission\x20object\x20addresses,\x20'+'not\x20control\x20overlap\x20โ€”\x20this\x20risk\x20exists\x20on\x20ANY\x20network.\x20Require\x20completely\x20'+'independent\x20third-party\x20Permission\x20(different\x20owner\x20and\x20admin\x20list)\x20for\x20Arbitration.';else!d&&(h='๐Ÿ”ด\x20Arbitrator\x20and\x20merchant\x20are\x20the\x20same\x20address:\x20arbitration\x20fairness\x20cannot\x20be\x20guaranteed.');}c['push']({'id':'trust_arb_independent','dimension':'trust','description':'Arbitrator\x20has\x20no\x20conflict\x20of\x20interest\x20with\x20the\x20merchant\x20(Permission\x20isolation)','weight':i,'passed':g,'advice':h});let j=![],k;if(b&&b['review_total']>0x0){const q=b['like_rate'];if(q>=0.85)j=!![];else q>=0.6?(j=!![],k='โš ๏ธ\x20Like\x20rate\x20is\x20'+Math['round'](q*0x64)+'%;\x20there\x20is\x20some\x20controversy.'):(j=![],k='๐Ÿ”ด\x20Like\x20rate\x20is\x20only\x20'+Math['round'](q*0x64)+'%\x20('+b['review_likes']+'/'+b['review_total']+');\x20many\x20negative\x20reviews.');}else b?j=!![]:j=!![];c['push']({'id':'trust_review_reputation','dimension':'trust','description':'Good\x20review\x20reputation\x20(like\x20rate\x20โ‰ฅ60%)','weight':0x5,'passed':j,'advice':k});const l=b?.['trust_score']??0x32,m=l>=0x32;c['push']({'id':'trust_score','dimension':'trust','description':'Composite\x20trust\x20score\x20โ‰ฅ50\x20(current\x20'+l+')','weight':0x4,'passed':m,'advice':m?undefined:'๐Ÿ”ด\x20Composite\x20trust\x20score\x20is\x20only\x20'+l+'/100;\x20recommend\x20finding\x20a\x20more\x20trustworthy\x20merchant.'});const n=b?.['has_contact']??![],o=b?.['has_messenger']??![];c['push']({'id':'trust_contact','dimension':'trust','description':'Merchant\x20has\x20a\x20contactable\x20Messenger\x20channel','weight':0x5,'passed':n&&o,'advice':n&&o?undefined:'๐Ÿ”ด\x20Merchant\x20has\x20no\x20contactable\x20channel\x20(um\x20is\x20empty):\x20no\x20way\x20to\x20conduct\x20pre-order\x20negotiation\x20or\x20post-sale\x20communication.'});const p=c['reduce']((r,s)=>r+(s['passed']?s['weight']:0x0),0x0);return{'name':'trust','score':p,'max_score':RISK_DIMENSION_MAX['trust'],'checks':c};}export function assessBehaviorRisk(a){const b=a['merchant_behavior'],c=[];let d=![],e;if(b){if(b['recent_trend']==='improving')d=!![];else b['recent_trend']==='stable'?d=!![]:(d=![],e='๐Ÿ”ด\x20Merchant\x27s\x20recent\x20dispute\x20rate\x20is\x20rising:\x20fulfillment\x20quality\x20may\x20be\x20deteriorating.');}else d=!![];c['push']({'id':'behavior_trend','dimension':'behavior','description':'Recent\x20fulfillment\x20trend\x20is\x20stable\x20or\x20improving','weight':0x6,'passed':d,'advice':e});const f=b!=null&&b['total_orders']>0x0,g=f?b['completed_rate']>=0.85:!![];c['push']({'id':'behavior_completion_rate','dimension':'behavior','description':'Order\x20completion\x20rate\x20โ‰ฅ85%','weight':0x4,'passed':g,'advice':g?undefined:'๐Ÿ”ด\x20Completion\x20rate\x20is\x20only\x20'+Math['round']((b?.['completed_rate']??0x0)*0x64)+'%:\x20a\x20higher-than-average\x20share\x20of\x20orders\x20end\x20in\x20failure.'});const h=f?b['dispute_rate']<=0.1:!![];c['push']({'id':'behavior_low_dispute','dimension':'behavior','description':'Dispute\x20rate\x20โ‰ค10%','weight':0x4,'passed':h,'advice':h?undefined:'โš ๏ธ\x20Dispute\x20rate\x20is\x20'+Math['round']((b?.['dispute_rate']??0x0)*0x64)+'%:\x20above\x20the\x20industry\x20average.'});const i=f?b['arb_loss_rate']<=0.3:!![];c['push']({'id':'behavior_arb_loss','dimension':'behavior','description':'Arbitration\x20loss\x20rate\x20โ‰ค30%','weight':0x3,'passed':i,'advice':i?undefined:'๐Ÿ”ด\x20Arbitration\x20loss\x20rate\x20is\x20'+Math['round']((b?.['arb_loss_rate']??0x0)*0x64)+'%:\x20the\x20merchant\x20has\x20lost\x20multiple\x20arbitration\x20cases,\x20indicating\x20a\x20tendency\x20to\x20violate\x20rules.'});const j=b?b['red_flags']['length']===0x0:!![];c['push']({'id':'behavior_no_red_flags','dimension':'behavior','description':'No\x20behavior\x20red_flags','weight':0x3,'passed':j,'advice':j?undefined:'โš ๏ธ\x20Detected\x20behavioral\x20warning\x20signals:\x20'+b?.['red_flags']['join'](',\x20')});const k=c['reduce']((l,m)=>l+(m['passed']?m['weight']:0x0),0x0);return{'name':'behavior','score':k,'max_score':RISK_DIMENSION_MAX['behavior'],'checks':c};}export function knowledgeServiceRisks(a){const b=a['service_basics'],c={'object':b['service_id'],'current_bPublished':b['bPublished'],'current_bPaused':b['bPaused'],'current_compensation_fund_balance':b['compensation_fund_balance']['toString'](),'current_arbitrations_count':b['arbitrations_count'],'current_sales_count':b['sales_count'],'current_machine_bound':!!b['machine_id']};return assessServiceRisks(c)['risks']['filter'](d=>(d['level']==='HIGH'||d['level']==='CRITICAL')&&d['affected_stakeholders']['includes']('customer'));}export function assessRisk(a){const b=[assessWorkflowRisk(a),assessFundRisk(a),assessTrustRisk(a),assessBehaviorRisk(a)],c=knowledgeServiceRisks(a),d=b['reduce']((n,o)=>n+o['score'],0x0),e=a['user_metrics']?.['adjustment']??0x0,g=a['service_nesting']?.['overall_risk_score'],h=a['service_nesting']?.['overall_risk_level'],i=a['workflow_analysis']?.['has_wonder_node']?0x2:0x0,j=Math['max'](0x0,Math['min'](0x64,d+e+i)),k=riskLevelFromScore(j),l=[];for(const n of b){for(const o of n['checks']){!o['passed']&&o['advice']&&o['advice']['startsWith']('๐Ÿ”ด')&&l['push']('['+n['name']+']\x20'+o['description']+':\x20'+o['advice']);}}if(a['workflow_analysis']?.['risk_signals']['length'])for(const p of a['workflow_analysis']['risk_signals']){l['push']('[workflow_signal]\x20'+p);}if(a['merchant_behavior']?.['red_flags']['length'])for(const q of a['merchant_behavior']['red_flags']){l['push']('[behavior_flag]\x20'+q);}(h==='high'||h==='critical')&&l['push']('[service_nesting]\x20overall\x20nesting\x20risk:\x20'+h+'\x20(score\x20'+g+')');for(const r of c){l['push']('[service_risk]\x20'+r['id']+':\x20'+r['title']+'\x20โ€”\x20'+r['description']);}const m=generateAdvice(a,j,k,b);for(const s of c){m['push']('๐Ÿ”ด\x20[service_risk]\x20'+s['title']+':\x20'+s['mitigation']);}return{'total':j,'base_total':d,'level':k,'dimensions':b,'user_metrics_adjustment':e,'service_nesting_risk':g,'service_nesting_level':h,'red_flags':l,'advice':m};}function generateAdvice(a,b,c,d){const e=[],f=riskLevelEmoji(c),g=RISK_LEVELS['find'](i=>i['level']===c);e['push'](f+'\x20Composite\x20risk\x20score:\x20'+b+'/100\x20('+(g?.['label']??'unknown')+')');if(c==='high')e['push']('๐Ÿšซ\x20Recommend\x20abandoning\x20this\x20order:\x20the\x20risk\x20level\x20is\x20too\x20high;\x20fund\x20safety\x20cannot\x20be\x20guaranteed.');else{if(c==='medium_high')e['push']('โš ๏ธ\x20Recommend\x20ordering\x20with\x20caution:\x20be\x20sure\x20to\x20negotiate\x20supplementary\x20terms\x20via\x20Messenger\x20and\x20request\x20a\x20WTS\x20evidence\x20file.');else c==='medium_low'?e['push']('โœ…\x20You\x20may\x20order:\x20recommend\x20continuously\x20monitoring\x20order\x20progress\x20and\x20keeping\x20communication\x20records.'):e['push']('โœ…\x20Safe\x20order:\x20you\x20can\x20order\x20with\x20confidence;\x20still\x20recommend\x20enabling\x20order\x20monitoring\x20reminders.');}const h=[...d]['sort']((i,j)=>i['score']/ i['max_score']-j['score']/j['max_score']);for(const i of h){const j=i['max_score']>0x0?i['score']/ i['max_score']:0x0;if(j<0.5){const k=i['checks']['filter'](l=>!l['passed']);if(k['length']>0x0){e['push']('๐Ÿ“Š\x20'+i['name']+'\x20dimension\x20'+i['score']+'/'+i['max_score']+':\x20'+k['length']+'\x20check(s)\x20failed.');const l=k['find'](n=>n['advice']?.['startsWith']('๐Ÿ”ด'));if(l?.['advice'])e['push'](l['advice']);}}}a['completeness']<0.8&&e['push']('โ„น๏ธ\x20Information\x20completeness\x20is\x20only\x20'+Math['round'](a['completeness']*0x64)+'%;\x20missing:\x20'+(a['gaps']['join'](',\x20')||'none')+'.\x20Recommend\x20supplementing\x20data\x20before\x20making\x20a\x20decision.');a['workflow_analysis']?.['has_wonder_node']&&e['push']('๐ŸŒŸ\x20Machine\x20implements\x20wonder/no-wonder\x20praise\x20design:\x20customers\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20(negative\x20review)\x20after\x20completion.\x20Reward\x20objects\x20can\x20claim\x20against\x20Progress.current\x20==\x20\x27wonder\x27\x20to\x20incentivize\x20positive\x20outcomes.');a['workflow_analysis']?.['has_dispute_anti_pattern']&&e['push']('๐Ÿ”ด\x20Machine\x20contains\x20dispute\x20anti-pattern\x20nodes\x20(disputed/refunded/arb/arbitration).\x20Dispute\x20is\x20INDEPENDENT\x20of\x20machine\x20โ€”\x20it\x20flows\x20through\x20Order\x20โ†’\x20Arbitration.dispute()\x20โ†’\x20Arb\x20โ†’\x20arbitration()\x20โ†’\x20arb_withdraw.\x20Arbitrators\x20are\x20configured\x20in\x20Arbitration.voting_guard,\x20NOT\x20in\x20Permission.\x20Recommend\x20the\x20merchant\x20remove\x20these\x20nodes\x20and\x20bind\x20an\x20Arbitration\x20object\x20instead.');if(a['user_metrics']){const n=a['user_metrics'],o=n['metrics']['filter'](p=>p['passed'])['length'];e['push']('๐Ÿ“Š\x20User-customized\x20metrics:\x20'+o+'/'+n['metrics']['length']+'\x20passed\x20(score\x20'+n['score']+'/100,\x20adjustment\x20'+(n['adjustment']>=0x0?'+':'')+n['adjustment']+').'+(n['source_file']?'\x20Source:\x20'+n['source_file']:''));for(const p of n['metrics']){!p['passed']&&p['advice']&&e['push']('\x20\x20\x20โ€ข\x20'+p['label']+':\x20'+p['advice']);}}if(a['service_nesting']){const q=a['service_nesting'];e['push']('๐Ÿ”—\x20Service\x20nesting\x20evaluation:\x20'+q['total_bindings_evaluated']+'\x20bound\x20objects,\x20overall\x20risk\x20'+q['overall_risk_level']+'\x20(score\x20'+q['overall_risk_score']+'/100).'+(q['truncated']?'\x20Recursion\x20truncated\x20at\x20depth\x20limit.':''));}return e;}export function passesRiskThreshold(a,b='medium_high'){const c=['high','medium_high','medium_low','low'],d=c['indexOf'](b),e=c['indexOf'](a['level']);return e>=d;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -28,6 +28,8 @@ export interface WorkflowAnalysis {
28
28
  provider_only_forwards: number;
29
29
  guard_gated_forwards: number;
30
30
  has_refund_path: boolean;
31
+ has_arb_refund_path?: boolean;
32
+ has_refund_allocator?: boolean;
31
33
  has_arbitration_path: boolean;
32
34
  has_arbitration_binding: boolean;
33
35
  has_wonder_node: boolean;
@@ -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
+ favor?: 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),'favor':d?.['favor']===!![],'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'};}
@@ -1,3 +1,4 @@
1
1
  export declare function registerBuiltinEvaluations(): void;
2
2
  export { registerDemandMatchEvaluation, matchDemandToServices, matchServiceToDemands, DEMAND_MATCH_EVALUATION, type DemandMatch, type ServiceMatch, } from "./demand-match.js";
3
3
  export { registerServiceRiskEvaluation, assessServiceRisk, SERVICE_RISK_EVALUATION, } from "./service-risk.js";
4
+ export { registerArbitrationScoreEvaluation, assessArbitration, ARBITRATION_TRUST_EVALUATION, ARBITRATION_FAIRNESS_EVALUATION, } from "./arbitration-score.js";
@@ -1 +1 @@
1
- import{getEvaluationEngine}from'../engine.js';import{registerDemandMatchEvaluation}from'./demand-match.js';import{registerServiceRiskEvaluation}from'./service-risk.js';export function registerBuiltinEvaluations(){const a=getEvaluationEngine();registerDemandMatchEvaluation(a),registerServiceRiskEvaluation(a);}export{registerDemandMatchEvaluation,matchDemandToServices,matchServiceToDemands,DEMAND_MATCH_EVALUATION}from'./demand-match.js';export{registerServiceRiskEvaluation,assessServiceRisk,SERVICE_RISK_EVALUATION}from'./service-risk.js';
1
+ import{getEvaluationEngine}from'../engine.js';import{registerDemandMatchEvaluation}from'./demand-match.js';import{registerServiceRiskEvaluation}from'./service-risk.js';import{registerArbitrationScoreEvaluation}from'./arbitration-score.js';export function registerBuiltinEvaluations(){const a=getEvaluationEngine();registerDemandMatchEvaluation(a),registerServiceRiskEvaluation(a),registerArbitrationScoreEvaluation(a);}export{registerDemandMatchEvaluation,matchDemandToServices,matchServiceToDemands,DEMAND_MATCH_EVALUATION}from'./demand-match.js';export{registerServiceRiskEvaluation,assessServiceRisk,SERVICE_RISK_EVALUATION}from'./service-risk.js';export{registerArbitrationScoreEvaluation,assessArbitration,ARBITRATION_TRUST_EVALUATION,ARBITRATION_FAIRNESS_EVALUATION}from'./arbitration-score.js';
@@ -0,0 +1,30 @@
1
+ import type { UserInjection } from "./types.js";
2
+ export type CalendarMode = "none" | "slot" | "date" | "period";
3
+ export type GeoMode = "strict" | "near" | "logistics";
4
+ export interface HardConstraint {
5
+ field: string;
6
+ kind: "truthy" | "falsy";
7
+ description: string;
8
+ }
9
+ export interface CategoryMatchRules {
10
+ category: string;
11
+ hard_constraints: HardConstraint[];
12
+ soft_weights: Record<string, number>;
13
+ highlight_fields: string[];
14
+ calendar_mode: CalendarMode;
15
+ geo_mode: GeoMode;
16
+ pricing_rules: string[];
17
+ }
18
+ export declare const CATEGORY_MATCH_RULES: Record<string, CategoryMatchRules>;
19
+ export declare function resolveCategoryMatchRules(category?: string): CategoryMatchRules | undefined;
20
+ export declare function listCategoryMatchRules(): string[];
21
+ export declare function registerCategoryMatchRules(rules: CategoryMatchRules, replace?: boolean): boolean;
22
+ export declare function toSoftWeightInjection(rules: CategoryMatchRules): UserInjection;
23
+ export interface HardConstraintResult<T> {
24
+ passed: T[];
25
+ dropped: Array<{
26
+ candidate: T;
27
+ constraint: HardConstraint;
28
+ }>;
29
+ }
30
+ export declare function applyHardConstraints<T>(rules: CategoryMatchRules, candidates: T[]): HardConstraintResult<T>;