@wowok/agent-mcp 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -1,170 +1,2 @@
1
- import { z } from "zod";
2
1
  import type { ToolDispatchResult } from "../types.js";
3
- export declare const QueryTaskStatusInputSchema: z.ZodObject<{
4
- task_id: z.ZodOptional<z.ZodString>;
5
- project_id: z.ZodOptional<z.ZodString>;
6
- }, "strict", z.ZodTypeAny, {
7
- project_id?: string | undefined;
8
- task_id?: string | undefined;
9
- }, {
10
- project_id?: string | undefined;
11
- task_id?: string | undefined;
12
- }>;
13
- export declare const TaskStateSchema: z.ZodObject<{
14
- task_id: z.ZodString;
15
- operation: z.ZodString;
16
- status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled"]>;
17
- progress: z.ZodNumber;
18
- message: z.ZodString;
19
- result: z.ZodNullable<z.ZodUnknown>;
20
- error: z.ZodNullable<z.ZodString>;
21
- started_at: z.ZodNumber;
22
- completed_at: z.ZodNullable<z.ZodNumber>;
23
- project_id: z.ZodNullable<z.ZodString>;
24
- }, "strict", z.ZodTypeAny, {
25
- message: string;
26
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
27
- error: string | null;
28
- operation: string;
29
- progress: number;
30
- completed_at: number | null;
31
- project_id: string | null;
32
- task_id: string;
33
- started_at: number;
34
- result?: unknown;
35
- }, {
36
- message: string;
37
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
38
- error: string | null;
39
- operation: string;
40
- progress: number;
41
- completed_at: number | null;
42
- project_id: string | null;
43
- task_id: string;
44
- started_at: number;
45
- result?: unknown;
46
- }>;
47
- export declare const QueryTaskStatusOutputSchema: z.ZodObject<{
48
- task_id: z.ZodOptional<z.ZodString>;
49
- task: z.ZodNullable<z.ZodObject<{
50
- task_id: z.ZodString;
51
- operation: z.ZodString;
52
- status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled"]>;
53
- progress: z.ZodNumber;
54
- message: z.ZodString;
55
- result: z.ZodNullable<z.ZodUnknown>;
56
- error: z.ZodNullable<z.ZodString>;
57
- started_at: z.ZodNumber;
58
- completed_at: z.ZodNullable<z.ZodNumber>;
59
- project_id: z.ZodNullable<z.ZodString>;
60
- }, "strict", z.ZodTypeAny, {
61
- message: string;
62
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
63
- error: string | null;
64
- operation: string;
65
- progress: number;
66
- completed_at: number | null;
67
- project_id: string | null;
68
- task_id: string;
69
- started_at: number;
70
- result?: unknown;
71
- }, {
72
- message: string;
73
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
74
- error: string | null;
75
- operation: string;
76
- progress: number;
77
- completed_at: number | null;
78
- project_id: string | null;
79
- task_id: string;
80
- started_at: number;
81
- result?: unknown;
82
- }>>;
83
- tasks: z.ZodOptional<z.ZodArray<z.ZodObject<{
84
- task_id: z.ZodString;
85
- operation: z.ZodString;
86
- status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled"]>;
87
- progress: z.ZodNumber;
88
- message: z.ZodString;
89
- result: z.ZodNullable<z.ZodUnknown>;
90
- error: z.ZodNullable<z.ZodString>;
91
- started_at: z.ZodNumber;
92
- completed_at: z.ZodNullable<z.ZodNumber>;
93
- project_id: z.ZodNullable<z.ZodString>;
94
- }, "strict", z.ZodTypeAny, {
95
- message: string;
96
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
97
- error: string | null;
98
- operation: string;
99
- progress: number;
100
- completed_at: number | null;
101
- project_id: string | null;
102
- task_id: string;
103
- started_at: number;
104
- result?: unknown;
105
- }, {
106
- message: string;
107
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
108
- error: string | null;
109
- operation: string;
110
- progress: number;
111
- completed_at: number | null;
112
- project_id: string | null;
113
- task_id: string;
114
- started_at: number;
115
- result?: unknown;
116
- }>, "many">>;
117
- }, "strict", z.ZodTypeAny, {
118
- task: {
119
- message: string;
120
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
121
- error: string | null;
122
- operation: string;
123
- progress: number;
124
- completed_at: number | null;
125
- project_id: string | null;
126
- task_id: string;
127
- started_at: number;
128
- result?: unknown;
129
- } | null;
130
- task_id?: string | undefined;
131
- tasks?: {
132
- message: string;
133
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
134
- error: string | null;
135
- operation: string;
136
- progress: number;
137
- completed_at: number | null;
138
- project_id: string | null;
139
- task_id: string;
140
- started_at: number;
141
- result?: unknown;
142
- }[] | undefined;
143
- }, {
144
- task: {
145
- message: string;
146
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
147
- error: string | null;
148
- operation: string;
149
- progress: number;
150
- completed_at: number | null;
151
- project_id: string | null;
152
- task_id: string;
153
- started_at: number;
154
- result?: unknown;
155
- } | null;
156
- task_id?: string | undefined;
157
- tasks?: {
158
- message: string;
159
- status: "failed" | "completed" | "pending" | "cancelled" | "running";
160
- error: string | null;
161
- operation: string;
162
- progress: number;
163
- completed_at: number | null;
164
- project_id: string | null;
165
- task_id: string;
166
- started_at: number;
167
- result?: unknown;
168
- }[] | undefined;
169
- }>;
170
2
  export declare function handleQueryTaskStatus(args: unknown): Promise<ToolDispatchResult>;
@@ -1,55 +1 @@
1
- import { z } from "zod";
2
- import { TaskTracker } from "../../project/task-tracker.js";
3
- export const QueryTaskStatusInputSchema = z.object({
4
- task_id: z
5
- .string()
6
- .optional()
7
- .describe("The task ID to query (returned by a prior async operation). " +
8
- "If omitted, lists all recent tasks (most recent first, max 50)."),
9
- project_id: z
10
- .string()
11
- .optional()
12
- .describe("Optional filter — when listing tasks (task_id omitted), only return tasks for this project."),
13
- }).strict().describe("Query the status of an async task, or list all recent tasks when task_id is omitted.");
14
- export const TaskStateSchema = z.object({
15
- task_id: z.string().describe("Unique task identifier."),
16
- operation: z.string().describe("Operation type that created this task (e.g. 'build_graph')."),
17
- status: z.enum(["pending", "running", "completed", "failed", "cancelled"]).describe("Current task status."),
18
- progress: z.number().describe("Progress percentage 0-100."),
19
- message: z.string().describe("Human-readable progress message."),
20
- result: z.unknown().nullable().describe("Result payload (set when status='completed'). null otherwise."),
21
- error: z.string().nullable().describe("Error message (set when status='failed'). null otherwise."),
22
- started_at: z.number().describe("Timestamp (ms) when the task was created."),
23
- completed_at: z.number().nullable().describe("Timestamp (ms) when the task reached a terminal state. null if still running."),
24
- project_id: z.string().nullable().describe("Project ID associated with this task, if any."),
25
- }).strict();
26
- export const QueryTaskStatusOutputSchema = z.object({
27
- task_id: z.string().optional().describe("The queried task ID (present when a single task was queried)."),
28
- task: TaskStateSchema.nullable().describe("The task state. null if task_id not found or when listing."),
29
- tasks: z.array(TaskStateSchema).optional().describe("List of tasks (present when task_id was omitted)."),
30
- }).strict();
31
- export async function handleQueryTaskStatus(args) {
32
- const validated = (args && typeof args === "object" ? args : {});
33
- if (validated.task_id) {
34
- const task = TaskTracker.get(validated.task_id);
35
- const result = {
36
- task_id: validated.task_id,
37
- task: task ?? null,
38
- tasks: undefined,
39
- };
40
- return {
41
- content: [{ type: "text", text: JSON.stringify(result) }],
42
- structuredContent: result,
43
- };
44
- }
45
- const tasks = TaskTracker.list(validated.project_id).slice(0, 50);
46
- const result = {
47
- task_id: undefined,
48
- task: null,
49
- tasks,
50
- };
51
- return {
52
- content: [{ type: "text", text: JSON.stringify(result) }],
53
- structuredContent: result,
54
- };
55
- }
1
+ import{TaskTracker}from'../../project/task-tracker.js';export async function handleQueryTaskStatus(a){const b=a&&typeof a==='object'?a:{};if(b['task_id']){const e=TaskTracker['get'](b['task_id']),f={'task_id':b['task_id'],'task':e??null,'tasks':undefined};return{'content':[{'type':'text','text':JSON['stringify'](f)}],'structuredContent':f};}const c=TaskTracker['list'](b['project_id'])['slice'](0x0,0x32),d={'task_id':undefined,'task':null,'tasks':c};return{'content':[{'type':'text','text':JSON['stringify'](d)}],'structuredContent':d};}
@@ -1,380 +1 @@
1
- import { strictParse, TrustScoreInputSchema, } from "../../schema/index.js";
2
- import { query_objects, query_personal, } from "@wowok/wowok";
3
- import { computeServiceTrustScore, } from "../../knowledge/index.js";
4
- import { assembleInfoPuzzle, assemblePreorderAdvice, assessRisk, buildPreorderComparison, getDefaultPreferences, inferIndustry, mergePreferences, validatePreferences, } from "../../customer/index.js";
5
- import { getProfile } from "../../experience/user-profile.js";
6
- function extractTrustMetrics(serviceObj) {
7
- const data = serviceObj?.data ?? serviceObj ?? {};
8
- const sales = Array.isArray(data.sales) ? data.sales : [];
9
- const activeSales = sales.filter((s) => s && !s.suspension);
10
- void activeSales;
11
- const compensationFund = data.compensation_fund;
12
- const compBalance = (() => {
13
- if (compensationFund === null || compensationFund === undefined)
14
- return undefined;
15
- if (typeof compensationFund === "bigint")
16
- return compensationFund;
17
- if (typeof compensationFund === "number")
18
- return BigInt(compensationFund);
19
- if (typeof compensationFund === "string") {
20
- try {
21
- return BigInt(compensationFund);
22
- }
23
- catch {
24
- return undefined;
25
- }
26
- }
27
- if (typeof compensationFund === "object") {
28
- const bal = compensationFund.balance;
29
- if (bal === null || bal === undefined)
30
- return undefined;
31
- try {
32
- return BigInt(bal);
33
- }
34
- catch {
35
- return undefined;
36
- }
37
- }
38
- return undefined;
39
- })();
40
- return {
41
- arbitrationCases: Array.isArray(data.arbitrations) ? data.arbitrations.length : undefined,
42
- compensationFundBalance: compBalance,
43
- hasMachineBound: typeof data.machine === "string" && data.machine.length > 0,
44
- hasBuyGuard: typeof data.buy_guard === "string" && data.buy_guard.length > 0,
45
- };
46
- }
47
- function buildPuzzleRawData(serviceObj, orderAmount, trustScore, serviceOwner) {
48
- const data = serviceObj?.data ?? serviceObj ?? {};
49
- const sales = Array.isArray(data.sales) ? data.sales : [];
50
- const order_allocators = data.order_allocators
51
- ? Array.isArray(data.order_allocators.allocators)
52
- ? data.order_allocators
53
- : { allocators: data.order_allocators }
54
- : undefined;
55
- const serviceRaw = {
56
- name: data.name ?? serviceObj?.id,
57
- bPublished: data.bPublished,
58
- bPaused: data.bPaused,
59
- price: sales[0]?.price != null ? String(sales[0].price) : "0",
60
- priceRaw: sales[0]?.price != null ? BigInt(sales[0].price) : 0n,
61
- token_type: sales[0]?.price_type ?? (compensation_fund_token(data) ?? "0x2::wow::WOW"),
62
- sales,
63
- machine: data.machine ?? undefined,
64
- buy_guard: data.buy_guard ?? undefined,
65
- customer_required: data.customer_required,
66
- arbitrations: data.arbitrations,
67
- compensation_fund: data.compensation_fund
68
- ? { balance: extractBalance(data.compensation_fund) }
69
- : undefined,
70
- compensation_lock_duration: typeof data.setting_lock_duration === "number"
71
- ? data.setting_lock_duration
72
- : undefined,
73
- um: data.um ?? undefined,
74
- order_allocators: order_allocators ? [order_allocators] : undefined,
75
- };
76
- return {
77
- service: serviceRaw,
78
- order_amount: orderAmount,
79
- trust_score: trustScore,
80
- service_owner: serviceOwner,
81
- };
82
- }
83
- function compensation_fund_token(data) {
84
- if (data?.compensation_fund && typeof data.compensation_fund === "object") {
85
- return data.compensation_fund.token_type;
86
- }
87
- return undefined;
88
- }
89
- function extractBalance(b) {
90
- if (b === null || b === undefined)
91
- return 0n;
92
- if (typeof b === "bigint")
93
- return b;
94
- if (typeof b === "number")
95
- return BigInt(b);
96
- if (typeof b === "string") {
97
- try {
98
- return BigInt(b);
99
- }
100
- catch {
101
- return 0n;
102
- }
103
- }
104
- if (typeof b === "object") {
105
- const bal = b.balance;
106
- if (bal === null || bal === undefined)
107
- return 0n;
108
- try {
109
- return BigInt(bal);
110
- }
111
- catch {
112
- return 0n;
113
- }
114
- }
115
- return 0n;
116
- }
117
- function toUserMetricsConfig(input) {
118
- return {
119
- version: 1,
120
- metrics: input.metrics.map((m) => ({
121
- name: m.name,
122
- label: m.label,
123
- evaluator: m.evaluator,
124
- params: {
125
- ...m.params,
126
- threshold: m.params.threshold !== undefined ? String(m.params.threshold) : undefined,
127
- },
128
- weight: m.weight,
129
- advice_on_fail: m.advice_on_fail,
130
- advice_on_pass: m.advice_on_pass,
131
- })),
132
- adjustment_cap: input.adjustment_cap,
133
- };
134
- }
135
- function derivePreferences(validated, industry) {
136
- const profile = getProfile();
137
- const withProfile = mergePreferences(getDefaultPreferences(industry), {
138
- risk_appetite: profile.risk_appetite,
139
- min_trust_score: profile.risk_appetite === "conservative" ? 70
140
- : profile.risk_appetite === "aggressive" ? 30 : 50,
141
- });
142
- const manualInput = validated.preferences;
143
- const manual = manualInput
144
- ? {
145
- ...manualInput,
146
- budget_range: manualInput.budget_range
147
- ? {
148
- min: BigInt(manualInput.budget_range.min),
149
- max: BigInt(manualInput.budget_range.max),
150
- }
151
- : undefined,
152
- }
153
- : undefined;
154
- const prefs = manual ? mergePreferences(withProfile, manual) : withProfile;
155
- return { prefs, issues: validatePreferences(prefs) };
156
- }
157
- async function fetchMerchantReputation(permissionAddr, network, noCache) {
158
- try {
159
- if (typeof permissionAddr !== "string" || !permissionAddr.startsWith("0x")) {
160
- return undefined;
161
- }
162
- const permResult = await query_objects({
163
- objects: [permissionAddr],
164
- no_cache: noCache,
165
- network,
166
- });
167
- const permObj = permResult?.objects?.[0];
168
- const builder = (permObj?.data ?? permObj)?.builder;
169
- if (typeof builder !== "string" || !builder.startsWith("0x")) {
170
- return undefined;
171
- }
172
- const personal = await query_personal({
173
- account: builder,
174
- no_cache: noCache,
175
- network,
176
- });
177
- if (!personal)
178
- return undefined;
179
- return { likes: personal.like ?? 0, dislikes: personal.dislike ?? 0 };
180
- }
181
- catch {
182
- return undefined;
183
- }
184
- }
185
- async function runTrustEvaluation(validated) {
186
- const depth = (validated.depth ?? "evaluate");
187
- const queryResult = await query_objects({
188
- objects: [validated.service],
189
- no_cache: validated.no_cache,
190
- network: validated.network,
191
- });
192
- const objects = queryResult?.objects;
193
- if (!objects || !Array.isArray(objects) || objects.length === 0) {
194
- throw new Error(`Service object not found for '${validated.service}'. ` +
195
- `Verify the ID/name and network, or use query_toolkit with query_type='onchain_objects' to debug.`);
196
- }
197
- const serviceObj = objects[0];
198
- const objType = serviceObj?.data?.object_type ?? serviceObj?.object_type ?? serviceObj?.type;
199
- if (objType && typeof objType === "string" && !objType.includes("Service")) {
200
- throw new Error(`Object '${validated.service}' is not a Service (type: ${objType}). ` +
201
- `trust_score only evaluates Service objects.`);
202
- }
203
- const metrics = extractTrustMetrics(serviceObj);
204
- const trustScore = computeServiceTrustScore(metrics);
205
- const sales = Array.isArray(serviceObj?.data?.sales) ? serviceObj.data.sales : [];
206
- const activeSale = sales.find((s) => s && !s.suspension) ?? sales[0];
207
- const salePriceRaw = activeSale?.price != null ? BigInt(activeSale.price) : 0n;
208
- const orderAmount = validated.order_amount != null
209
- ? BigInt(validated.order_amount)
210
- : salePriceRaw;
211
- let riskScore;
212
- let infoPuzzle;
213
- let preorderAdvice;
214
- let preferenceIssues;
215
- if (depth === "evaluate" || depth === "preorder") {
216
- const puzzleRaw = buildPuzzleRawData(serviceObj, orderAmount, { score: trustScore.score, level: trustScore.level }, undefined);
217
- if (validated.user_metrics) {
218
- puzzleRaw.user_metrics_config = toUserMetricsConfig(validated.user_metrics);
219
- }
220
- if (depth === "preorder") {
221
- const reputation = await fetchMerchantReputation((serviceObj?.data ?? serviceObj)?.permission, validated.network, validated.no_cache);
222
- if (reputation)
223
- puzzleRaw.merchant_reputation = reputation;
224
- }
225
- infoPuzzle = assembleInfoPuzzle(validated.service, puzzleRaw, depth);
226
- riskScore = assessRisk(infoPuzzle);
227
- if (depth === "preorder") {
228
- const industry = validated.industry ?? inferIndustry(infoPuzzle);
229
- const { prefs, issues } = derivePreferences(validated, industry);
230
- preferenceIssues = issues.length > 0 ? issues : undefined;
231
- preorderAdvice = assemblePreorderAdvice({
232
- puzzle: infoPuzzle,
233
- risk: riskScore,
234
- preferences: prefs,
235
- industry,
236
- });
237
- }
238
- }
239
- return {
240
- serviceId: validated.service,
241
- serviceName: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
242
- serviceObj,
243
- sales,
244
- trustScore,
245
- orderAmount,
246
- infoPuzzle,
247
- riskScore,
248
- preorderAdvice,
249
- preferenceIssues,
250
- };
251
- }
252
- export async function handleTrustScore(args) {
253
- const validated = strictParse(TrustScoreInputSchema, args, "trust_score input");
254
- const depth = (validated.depth ?? "evaluate");
255
- const core = await runTrustEvaluation(validated);
256
- const { serviceObj, sales, trustScore, orderAmount, infoPuzzle, riskScore, preorderAdvice, preferenceIssues } = core;
257
- const result = {
258
- service_id: validated.service,
259
- service_name: serviceObj?.data?.name ?? serviceObj?.name ?? validated.service,
260
- service_basics: {
261
- bPublished: serviceObj?.data?.bPublished ?? false,
262
- bPaused: serviceObj?.data?.bPaused ?? false,
263
- sales_count: sales.filter((s) => s && !s.suspension).length,
264
- has_machine: !!serviceObj?.data?.machine,
265
- has_buy_guard: !!serviceObj?.data?.buy_guard,
266
- has_um_contact: !!serviceObj?.data?.um,
267
- arbitrations_count: Array.isArray(serviceObj?.data?.arbitrations)
268
- ? serviceObj.data.arbitrations.length
269
- : 0,
270
- },
271
- trust_score: {
272
- score: trustScore.score,
273
- level: trustScore.level,
274
- summary: trustScore.summary,
275
- warnings: trustScore.warnings,
276
- breakdown: trustScore.breakdown,
277
- },
278
- order_amount: orderAmount.toString(),
279
- depth,
280
- ...(riskScore ? {
281
- risk_score: {
282
- total: riskScore.total,
283
- level: riskScore.level,
284
- red_flags: riskScore.red_flags,
285
- advice: riskScore.advice,
286
- dimensions: riskScore.dimensions,
287
- },
288
- } : {}),
289
- ...(infoPuzzle ? {
290
- info_puzzle: {
291
- completeness: infoPuzzle.completeness,
292
- gaps: infoPuzzle.gaps,
293
- assembled_at: infoPuzzle.assembled_at,
294
- },
295
- } : {}),
296
- ...(preorderAdvice ? {
297
- preorder_advice: {
298
- confidence: preorderAdvice.confidence,
299
- industry: preorderAdvice.industry,
300
- strategies: preorderAdvice.strategies.map((s) => ({
301
- scenario: s.scenario,
302
- merchant_tactic: s.strategy.merchant_tactic,
303
- user_strategy: s.strategy.user_strategy,
304
- nash_equilibrium: s.strategy.nash_equilibrium,
305
- confidence: s.confidence,
306
- fallback: s.fallback,
307
- rationale: s.rationale,
308
- })),
309
- ...(preorderAdvice.preference_match
310
- ? { preference_match: preorderAdvice.preference_match }
311
- : {}),
312
- ...(preferenceIssues ? { preference_issues: preferenceIssues } : {}),
313
- ...(preorderAdvice.industry_risks
314
- ? {
315
- industry_risks: {
316
- score_adjustment: preorderAdvice.industry_risks.score_adjustment,
317
- summary: preorderAdvice.industry_risks.summary,
318
- checks: preorderAdvice.industry_risks.checks,
319
- unmet_needs: preorderAdvice.industry_risks.unmet_needs.map((n) => ({
320
- id: n.id,
321
- tier: n.tier,
322
- description: n.description,
323
- advice: n.advice,
324
- })),
325
- },
326
- }
327
- : {}),
328
- reminders: preorderAdvice.reminders,
329
- blocking_reminders: preorderAdvice.blocking_reminders,
330
- summary: preorderAdvice.summary,
331
- },
332
- } : {}),
333
- };
334
- let comparison;
335
- if (depth === "preorder" && validated.compare_with && validated.compare_with.length > 0) {
336
- const rows = [coreToCompareRow(core)];
337
- for (const candidate of validated.compare_with) {
338
- try {
339
- const candidateCore = await runTrustEvaluation({
340
- ...validated,
341
- service: candidate,
342
- depth: "preorder",
343
- });
344
- rows.push(coreToCompareRow(candidateCore));
345
- }
346
- catch (e) {
347
- rows.push({
348
- service_id: candidate,
349
- service_name: candidate,
350
- error: e.message,
351
- });
352
- }
353
- }
354
- comparison = buildPreorderComparison(rows);
355
- }
356
- const finalResult = comparison ? { ...result, comparison } : result;
357
- return {
358
- content: [{ type: "text", text: JSON.stringify({ result: finalResult }) }],
359
- structuredContent: { result: finalResult },
360
- };
361
- }
362
- function coreToCompareRow(core) {
363
- const reputation = core.infoPuzzle?.merchant_behavior?.reputation;
364
- return {
365
- service_id: core.serviceId,
366
- service_name: core.serviceName,
367
- industry: core.preorderAdvice?.industry,
368
- confidence: core.preorderAdvice?.confidence.score,
369
- risk_total: core.riskScore?.total,
370
- risk_level: core.riskScore?.level,
371
- trust_score: core.trustScore.score,
372
- trust_level: core.trustScore.level,
373
- preference_match: core.preorderAdvice?.preference_match?.score,
374
- reputation_like_ratio: reputation?.like_ratio,
375
- reputation_votes: reputation ? reputation.likes + reputation.dislikes : undefined,
376
- red_flags_count: core.riskScore?.red_flags.length,
377
- blocking_reminders_count: core.preorderAdvice?.blocking_reminders.length,
378
- info_gaps_count: core.infoPuzzle?.gaps.length,
379
- };
380
- }
1
+ import{strictParse,TrustScoreInputSchema}from'../../schema/index.js';import{query_objects,query_personal}from'@wowok/wowok';import{computeServiceTrustScore}from'../../knowledge/index.js';import{assembleInfoPuzzle,assemblePreorderAdvice,assessRisk,buildPreorderComparison,getDefaultPreferences,inferIndustry,mergePreferences,validatePreferences}from'../../customer/index.js';import{getProfile}from'../../experience/user-profile.js';function extractTrustMetrics(a){const b=a?.['data']??a??{},c=Array['isArray'](b['sales'])?b['sales']:[],d=c['filter'](g=>g&&!g['suspension']);void d;const e=b['compensation_fund'],f=((()=>{if(e===null||e===undefined)return undefined;if(typeof e==='bigint')return e;if(typeof e==='number')return BigInt(e);if(typeof e==='string')try{return BigInt(e);}catch{return undefined;}if(typeof e==='object'){const g=e['balance'];if(g===null||g===undefined)return undefined;try{return BigInt(g);}catch{return undefined;}}return undefined;})());return{'arbitrationCases':Array['isArray'](b['arbitrations'])?b['arbitrations']['length']:undefined,'compensationFundBalance':f,'hasMachineBound':typeof b['machine']==='string'&&b['machine']['length']>0x0,'hasBuyGuard':typeof b['buy_guard']==='string'&&b['buy_guard']['length']>0x0};}function buildPuzzleRawData(a,b,c,d){const e=a?.['data']??a??{},f=Array['isArray'](e['sales'])?e['sales']:[],g=e['order_allocators']?Array['isArray'](e['order_allocators']['allocators'])?e['order_allocators']:{'allocators':e['order_allocators']}:undefined,h={'name':e['name']??a?.['id'],'bPublished':e['bPublished'],'bPaused':e['bPaused'],'price':f[0x0]?.['price']!=null?String(f[0x0]['price']):'0','priceRaw':f[0x0]?.['price']!=null?BigInt(f[0x0]['price']):0x0n,'token_type':f[0x0]?.['price_type']??(compensation_fund_token(e)??'0x2::wow::WOW'),'sales':f,'machine':e['machine']??undefined,'buy_guard':e['buy_guard']??undefined,'customer_required':e['customer_required'],'arbitrations':e['arbitrations'],'compensation_fund':e['compensation_fund']?{'balance':extractBalance(e['compensation_fund'])}:undefined,'compensation_lock_duration':typeof e['setting_lock_duration']==='number'?e['setting_lock_duration']:undefined,'um':e['um']??undefined,'order_allocators':g?[g]:undefined};return{'service':h,'order_amount':b,'trust_score':c,'service_owner':d};}function compensation_fund_token(a){if(a?.['compensation_fund']&&typeof a['compensation_fund']==='object')return a['compensation_fund']['token_type'];return undefined;}function extractBalance(a){if(a===null||a===undefined)return 0x0n;if(typeof a==='bigint')return a;if(typeof a==='number')return BigInt(a);if(typeof a==='string')try{return BigInt(a);}catch{return 0x0n;}if(typeof a==='object'){const c=a['balance'];if(c===null||c===undefined)return 0x0n;try{return BigInt(c);}catch{return 0x0n;}}return 0x0n;}function toUserMetricsConfig(a){return{'version':0x1,'metrics':a['metrics']['map'](b=>({'name':b['name'],'label':b['label'],'evaluator':b['evaluator'],'params':{...b['params'],'threshold':b['params']['threshold']!==undefined?String(b['params']['threshold']):undefined},'weight':b['weight'],'advice_on_fail':b['advice_on_fail'],'advice_on_pass':b['advice_on_pass']})),'adjustment_cap':a['adjustment_cap']};}function derivePreferences(a,b){const c=getProfile(),d=mergePreferences(getDefaultPreferences(b),{'risk_appetite':c['risk_appetite'],'min_trust_score':c['risk_appetite']==='conservative'?0x46:c['risk_appetite']==='aggressive'?0x1e:0x32}),e=a['preferences'],f=e?{...e,'budget_range':e['budget_range']?{'min':BigInt(e['budget_range']['min']),'max':BigInt(e['budget_range']['max'])}:undefined}:undefined,g=f?mergePreferences(d,f):d;return{'prefs':g,'issues':validatePreferences(g)};}async function fetchMerchantReputation(a,b,c){try{if(typeof a!=='string'||!a['startsWith']('0x'))return undefined;const d=await query_objects({'objects':[a],'no_cache':c,'network':b}),e=d?.['objects']?.[0x0],f=(e?.['data']??e)?.['builder'];if(typeof f!=='string'||!f['startsWith']('0x'))return undefined;const g=await query_personal({'account':f,'no_cache':c,'network':b});if(!g)return undefined;return{'likes':g['like']??0x0,'dislikes':g['dislike']??0x0};}catch{return undefined;}}async function runTrustEvaluation(a){const b=a['depth']??'evaluate',c=await query_objects({'objects':[a['service']],'no_cache':a['no_cache'],'network':a['network']}),d=c?.['objects'];if(!d||!Array['isArray'](d)||d['length']===0x0)throw new Error('Service\x20object\x20not\x20found\x20for\x20\x27'+a['service']+'\x27.\x20'+'Verify\x20the\x20ID/name\x20and\x20network,\x20or\x20use\x20query_toolkit\x20with\x20query_type=\x27onchain_objects\x27\x20to\x20debug.');const e=d[0x0],f=e?.['data']?.['object_type']??e?.['object_type']??e?.['type'];if(f&&typeof f==='string'&&!f['includes']('Service'))throw new Error('Object\x20\x27'+a['service']+'\x27\x20is\x20not\x20a\x20Service\x20(type:\x20'+f+').\x20'+'trust_score\x20only\x20evaluates\x20Service\x20objects.');const g=extractTrustMetrics(e),h=computeServiceTrustScore(g),i=Array['isArray'](e?.['data']?.['sales'])?e['data']['sales']:[],j=i['find'](q=>q&&!q['suspension'])??i[0x0],k=j?.['price']!=null?BigInt(j['price']):0x0n,l=a['order_amount']!=null?BigInt(a['order_amount']):k;let m,n,o,p;if(b==='evaluate'||b==='preorder'){const q=buildPuzzleRawData(e,l,{'score':h['score'],'level':h['level']},undefined);a['user_metrics']&&(q['user_metrics_config']=toUserMetricsConfig(a['user_metrics']));if(b==='preorder'){const r=await fetchMerchantReputation((e?.['data']??e)?.['permission'],a['network'],a['no_cache']);if(r)q['merchant_reputation']=r;}n=assembleInfoPuzzle(a['service'],q,b),m=assessRisk(n);if(b==='preorder'){const s=a['industry']??inferIndustry(n),{prefs:t,issues:u}=derivePreferences(a,s);p=u['length']>0x0?u:undefined,o=assemblePreorderAdvice({'puzzle':n,'risk':m,'preferences':t,'industry':s});}}return{'serviceId':a['service'],'serviceName':e?.['data']?.['name']??e?.['name']??a['service'],'serviceObj':e,'sales':i,'trustScore':h,'orderAmount':l,'infoPuzzle':n,'riskScore':m,'preorderAdvice':o,'preferenceIssues':p};}export async function handleTrustScore(a){const b=strictParse(TrustScoreInputSchema,a,'trust_score\x20input'),c=b['depth']??'evaluate',d=await runTrustEvaluation(b),{serviceObj:f,sales:g,trustScore:h,orderAmount:i,infoPuzzle:j,riskScore:k,preorderAdvice:l,preferenceIssues:m}=d,n={'service_id':b['service'],'service_name':f?.['data']?.['name']??f?.['name']??b['service'],'service_basics':{'bPublished':f?.['data']?.['bPublished']??![],'bPaused':f?.['data']?.['bPaused']??![],'sales_count':g['filter'](q=>q&&!q['suspension'])['length'],'has_machine':!!f?.['data']?.['machine'],'has_buy_guard':!!f?.['data']?.['buy_guard'],'has_um_contact':!!f?.['data']?.['um'],'arbitrations_count':Array['isArray'](f?.['data']?.['arbitrations'])?f['data']['arbitrations']['length']:0x0},'trust_score':{'score':h['score'],'level':h['level'],'summary':h['summary'],'warnings':h['warnings'],'breakdown':h['breakdown']},'order_amount':i['toString'](),'depth':c,...k?{'risk_score':{'total':k['total'],'level':k['level'],'red_flags':k['red_flags'],'advice':k['advice'],'dimensions':k['dimensions']}}:{},...j?{'info_puzzle':{'completeness':j['completeness'],'gaps':j['gaps'],'assembled_at':j['assembled_at']}}:{},...l?{'preorder_advice':{'confidence':l['confidence'],'industry':l['industry'],'strategies':l['strategies']['map'](q=>({'scenario':q['scenario'],'merchant_tactic':q['strategy']['merchant_tactic'],'user_strategy':q['strategy']['user_strategy'],'nash_equilibrium':q['strategy']['nash_equilibrium'],'confidence':q['confidence'],'fallback':q['fallback'],'rationale':q['rationale']})),...l['preference_match']?{'preference_match':l['preference_match']}:{},...m?{'preference_issues':m}:{},...l['industry_risks']?{'industry_risks':{'score_adjustment':l['industry_risks']['score_adjustment'],'summary':l['industry_risks']['summary'],'checks':l['industry_risks']['checks'],'unmet_needs':l['industry_risks']['unmet_needs']['map'](q=>({'id':q['id'],'tier':q['tier'],'description':q['description'],'advice':q['advice']}))}}:{},'reminders':l['reminders'],'blocking_reminders':l['blocking_reminders'],'summary':l['summary']}}:{}};let o;if(c==='preorder'&&b['compare_with']&&b['compare_with']['length']>0x0){const q=[coreToCompareRow(d)];for(const r of b['compare_with']){try{const s=await runTrustEvaluation({...b,'service':r,'depth':'preorder'});q['push'](coreToCompareRow(s));}catch(t){q['push']({'service_id':r,'service_name':r,'error':t['message']});}}o=buildPreorderComparison(q);}const p=o?{...n,'comparison':o}:n;return{'content':[{'type':'text','text':JSON['stringify']({'result':p})}],'structuredContent':{'result':p}};}function coreToCompareRow(a){const b=a['infoPuzzle']?.['merchant_behavior']?.['reputation'];return{'service_id':a['serviceId'],'service_name':a['serviceName'],'industry':a['preorderAdvice']?.['industry'],'confidence':a['preorderAdvice']?.['confidence']['score'],'risk_total':a['riskScore']?.['total'],'risk_level':a['riskScore']?.['level'],'trust_score':a['trustScore']['score'],'trust_level':a['trustScore']['level'],'preference_match':a['preorderAdvice']?.['preference_match']?.['score'],'reputation_like_ratio':b?.['like_ratio'],'reputation_votes':b?b['likes']+b['dislikes']:undefined,'red_flags_count':a['riskScore']?.['red_flags']['length'],'blocking_reminders_count':a['preorderAdvice']?.['blocking_reminders']['length'],'info_gaps_count':a['infoPuzzle']?.['gaps']['length']};}