@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,200 +1 @@
1
- import { MAX_IM_COUNT } from "@wowok/wowok";
2
- const R_C_01 = {
3
- rule: {
4
- id: "R-CONTACT-01",
5
- level: "MEDIUM",
6
- category: "permission",
7
- title: "change_status has no permission check — IM list pollution risk",
8
- description: "change_status lets any IM member self-update their status string without Permission " +
9
- "verification (contact.move:32-43). If an attacker's address is added to the ims list " +
10
- "(via im_add, which requires permission index 453), the attacker can freely pollute " +
11
- "their status field (e.g. set status to 'fraud'). The risk is bounded by the im_add " +
12
- "permission gate, but a misconfigured Permission could expose the IM list.",
13
- affected_stakeholders: ["creator", "im_member"],
14
- scenario: "Contact's IM list is misconfigured to allow public adds; attacker pollutes status",
15
- mitigation: "Restrict permission index 453 (CONTACT_IM) to trusted guardians. Audit the IM list " +
16
- "periodically. Business layer may validate status strings against an allowlist.",
17
- auto_fixable: false,
18
- },
19
- check: (ctx) => {
20
- if (!ctx.change_status_no_permission)
21
- return null;
22
- return { ...R_C_01.rule, evidence: "change_status_no_permission=true" };
23
- },
24
- };
25
- const R_C_02 = {
26
- rule: {
27
- id: "R-CONTACT-02",
28
- level: "LOW",
29
- category: "structural",
30
- title: `MAX_IM_COUNT=${MAX_IM_COUNT} is permissive — on-chain storage cost`,
31
- description: `A single Contact may hold up to MAX_IM_COUNT=${MAX_IM_COUNT} IM entries (contact.move:14). ` +
32
- `Aborting with E_IM_COUNT_EXCEEDED (1) only triggers at the boundary. 200 entries is ` +
33
- `relatively permissive for a social scenario; loading the full list on every read ` +
34
- `increases gas and storage cost.`,
35
- affected_stakeholders: ["creator"],
36
- scenario: "Caller adds 200 IM entries to a single Contact",
37
- mitigation: "Business layer should self-limit IM count well below 200. For high-volume contact " +
38
- "lists, shard across multiple Contact objects and aggregate off-chain.",
39
- related_move_error: "E_IM_COUNT_EXCEEDED (1)",
40
- auto_fixable: false,
41
- },
42
- check: (ctx) => {
43
- if (ctx.im_count === undefined)
44
- return null;
45
- if (ctx.im_count < MAX_IM_COUNT)
46
- return null;
47
- return { ...R_C_02.rule, evidence: `im_count=${ctx.im_count}, limit=${MAX_IM_COUNT}` };
48
- },
49
- };
50
- const R_C_03 = {
51
- rule: {
52
- id: "R-CONTACT-03",
53
- level: "MEDIUM",
54
- category: "semantic",
55
- title: "IM list mutations emit no events — external indexers must poll",
56
- description: "im_add / im_remove / im_clear do not emit events (contact.move:70-100). External " +
57
- "indexers and notification systems cannot rely on event streams to track IM list " +
58
- "changes; they must poll the ims field directly, increasing latency and RPC cost.",
59
- affected_stakeholders: ["creator", "consumer"],
60
- scenario: "Indexer expects an event on im_add but none is emitted; UI fails to refresh",
61
- mitigation: "External indexers should poll the Contact.ims field on a cadence. A future version " +
62
- "may add IMEvent; until then, do not build critical UX on IM event streams.",
63
- auto_fixable: false,
64
- },
65
- check: (ctx) => null,
66
- };
67
- const R_C_04 = {
68
- rule: {
69
- id: "R-CONTACT-04",
70
- level: "LOW",
71
- category: "semantic",
72
- title: "location defaults to empty string — may be misread as 'unset'",
73
- description: "A freshly created Contact has location=\"\" (empty String). The Move type does not " +
74
- "distinguish 'unset' from 'empty', so consumers may misinterpret an empty location " +
75
- "as 'globally applicable' or as 'missing data'.",
76
- affected_stakeholders: ["creator", "consumer"],
77
- scenario: "Consumer reads location=\"\" and treats the Contact as global when it was never set",
78
- mitigation: "Document that empty location means 'not specified'. If a default region is required, " +
79
- "set location explicitly at creation time.",
80
- auto_fixable: true,
81
- },
82
- check: (ctx) => {
83
- if (!ctx.location_empty)
84
- return null;
85
- return { ...R_C_04.rule, evidence: "location=\"\" (empty, default)" };
86
- },
87
- };
88
- const R_C_05 = {
89
- rule: {
90
- id: "R-CONTACT-05",
91
- level: "MEDIUM",
92
- category: "lifecycle",
93
- title: "my_status silently fails for non-IM-members",
94
- description: "my_status only updates the caller's status entry if the caller is in the ims list " +
95
- "(contact.move:35-42). For a non-IM-member, the call silently succeeds without any " +
96
- "state change — there is no abort and no event. Users get no feedback, making it " +
97
- "impossible to distinguish 'status updated' from 'operation ignored'.",
98
- affected_stakeholders: ["im_member"],
99
- scenario: "Non-IM-member calls my_status expecting an error; operation is silently ignored",
100
- mitigation: "SDK layer should pre-validate IM membership before submitting my_status and return a " +
101
- "clear error. UI should show 'not an IM member' instead of 'success'.",
102
- auto_fixable: false,
103
- },
104
- check: (ctx) => {
105
- if (!ctx.my_status_from_non_member)
106
- return null;
107
- return { ...R_C_05.rule, evidence: "my_status_from_non_member=true (will be silently ignored)" };
108
- },
109
- };
110
- const R_C_06 = {
111
- rule: {
112
- id: "R-CONTACT-06",
113
- level: "LOW",
114
- category: "semantic",
115
- title: "im_add description uses LONG_NAME (not DESCRIPTION) — different length cap",
116
- description: "im_add's description parameter is validated with common::LONG_NAME rather than " +
117
- "common::DESCRIPTION (contact.move:70-86). The two validators have different length " +
118
- "limits; callers expecting DESCRIPTION semantics may submit overly long strings and " +
119
- "hit an unexpected abort.",
120
- affected_stakeholders: ["creator"],
121
- scenario: "Caller submits an im_add description sized for DESCRIPTION but hits LONG_NAME limit",
122
- mitigation: "Document that im_add description uses LONG_NAME validation. SDK should expose the " +
123
- "exact limit so callers size their strings correctly.",
124
- auto_fixable: false,
125
- },
126
- check: (ctx) => {
127
- if (!ctx.im_add_description_uses_long_name)
128
- return null;
129
- return { ...R_C_06.rule, evidence: "im_add description validated with LONG_NAME" };
130
- },
131
- };
132
- const R_C_07 = {
133
- rule: {
134
- id: "R-CONTACT-07",
135
- level: "MEDIUM",
136
- category: "cross_object",
137
- title: "permission_um_set creates Contact ↔ Permission bidirectional dependency",
138
- description: "When Contact is set as a Permission's um via permission_um_set (contact.move:207-209), " +
139
- "a bidirectional dependency forms: Permission.um → Contact, and Contact.permission → " +
140
- "Permission. Deleting the Contact without first clearing the um reference leaves a " +
141
- "dangling pointer in Permission.um.",
142
- affected_stakeholders: ["creator", "consumer"],
143
- scenario: "Contact is deleted while still bound as Permission.um; Permission.um becomes dangling",
144
- mitigation: "Document the deletion order: (1) clear Permission.um via permission_um_set(null) " +
145
- "first, (2) then delete the Contact. SDK should refuse to delete a Contact that is " +
146
- "still bound as a um.",
147
- auto_fixable: false,
148
- },
149
- check: (ctx) => {
150
- if (!ctx.bound_to_permission_um)
151
- return null;
152
- return { ...R_C_07.rule, evidence: "bound_to_permission_um=true (deletion requires unbinding)" };
153
- },
154
- };
155
- const R_C_08 = {
156
- rule: {
157
- id: "R-CONTACT-08",
158
- level: "LOW",
159
- category: "knowledge",
160
- title: "Knowledge layer & constant sync — RESOLVED",
161
- description: `MAX_IM_COUNT is now synced to onchain-constants.ts (${MAX_IM_COUNT}). The MCP ` +
162
- `Knowledge layer now includes contact-risk.ts. This risk rule is retained for ` +
163
- `historical audit and to detect future regressions.`,
164
- affected_stakeholders: ["system"],
165
- scenario: "Future regression: someone removes MAX_IM_COUNT from onchain-constants.ts",
166
- mitigation: "Run the onchain-constants sync test to detect drift.",
167
- auto_fixable: false,
168
- },
169
- check: (ctx) => {
170
- if (ctx.constants_synced)
171
- return null;
172
- return { ...R_C_08.rule, evidence: "constants_synced=false" };
173
- },
174
- };
175
- export const CONTACT_RISK_RULES = [
176
- R_C_01,
177
- R_C_02,
178
- R_C_03,
179
- R_C_04,
180
- R_C_05,
181
- R_C_06,
182
- R_C_07,
183
- R_C_08,
184
- ];
185
- export const CONTACT_RISK_VERSION = "1.0.0";
186
- export function checkContactRisks(ctx) {
187
- const risks = [];
188
- for (const rule of CONTACT_RISK_RULES) {
189
- const r = rule.check(ctx);
190
- if (r)
191
- risks.push(r);
192
- }
193
- if (!risks.find(r => r.id === "R-CONTACT-03")) {
194
- risks.push(R_C_03.rule);
195
- }
196
- return risks;
197
- }
198
- export function getContactRiskById(id) {
199
- return CONTACT_RISK_RULES.find(r => r.rule.id === id)?.rule;
200
- }
1
+ import{MAX_IM_COUNT}from'@wowok/wowok';const R_C_01={'rule':{'id':'R-CONTACT-01','level':'MEDIUM','category':'permission','title':'change_status\x20has\x20no\x20permission\x20check\x20—\x20IM\x20list\x20pollution\x20risk','description':'change_status\x20lets\x20any\x20IM\x20member\x20self-update\x20their\x20status\x20string\x20without\x20Permission\x20'+'verification\x20(contact.move:32-43).\x20If\x20an\x20attacker\x27s\x20address\x20is\x20added\x20to\x20the\x20ims\x20list\x20'+'(via\x20im_add,\x20which\x20requires\x20permission\x20index\x20453),\x20the\x20attacker\x20can\x20freely\x20pollute\x20'+'their\x20status\x20field\x20(e.g.\x20set\x20status\x20to\x20\x27fraud\x27).\x20The\x20risk\x20is\x20bounded\x20by\x20the\x20im_add\x20'+'permission\x20gate,\x20but\x20a\x20misconfigured\x20Permission\x20could\x20expose\x20the\x20IM\x20list.','affected_stakeholders':['creator','im_member'],'scenario':'Contact\x27s\x20IM\x20list\x20is\x20misconfigured\x20to\x20allow\x20public\x20adds;\x20attacker\x20pollutes\x20status','mitigation':'Restrict\x20permission\x20index\x20453\x20(CONTACT_IM)\x20to\x20trusted\x20guardians.\x20Audit\x20the\x20IM\x20list\x20'+'periodically.\x20Business\x20layer\x20may\x20validate\x20status\x20strings\x20against\x20an\x20allowlist.','auto_fixable':![]},'check':a=>{if(!a['change_status_no_permission'])return null;return{...R_C_01['rule'],'evidence':'change_status_no_permission=true'};}},R_C_02={'rule':{'id':'R-CONTACT-02','level':'LOW','category':'structural','title':'MAX_IM_COUNT='+MAX_IM_COUNT+'\x20is\x20permissive\x20—\x20on-chain\x20storage\x20cost','description':'A\x20single\x20Contact\x20may\x20hold\x20up\x20to\x20MAX_IM_COUNT='+MAX_IM_COUNT+'\x20IM\x20entries\x20(contact.move:14).\x20'+'Aborting\x20with\x20E_IM_COUNT_EXCEEDED\x20(1)\x20only\x20triggers\x20at\x20the\x20boundary.\x20200\x20entries\x20is\x20'+'relatively\x20permissive\x20for\x20a\x20social\x20scenario;\x20loading\x20the\x20full\x20list\x20on\x20every\x20read\x20'+'increases\x20gas\x20and\x20storage\x20cost.','affected_stakeholders':['creator'],'scenario':'Caller\x20adds\x20200\x20IM\x20entries\x20to\x20a\x20single\x20Contact','mitigation':'Business\x20layer\x20should\x20self-limit\x20IM\x20count\x20well\x20below\x20200.\x20For\x20high-volume\x20contact\x20'+'lists,\x20shard\x20across\x20multiple\x20Contact\x20objects\x20and\x20aggregate\x20off-chain.','related_move_error':'E_IM_COUNT_EXCEEDED\x20(1)','auto_fixable':![]},'check':a=>{if(a['im_count']===undefined)return null;if(a['im_count']<MAX_IM_COUNT)return null;return{...R_C_02['rule'],'evidence':'im_count='+a['im_count']+',\x20limit='+MAX_IM_COUNT};}},R_C_03={'rule':{'id':'R-CONTACT-03','level':'MEDIUM','category':'semantic','title':'IM\x20list\x20mutations\x20emit\x20no\x20events\x20—\x20external\x20indexers\x20must\x20poll','description':'im_add\x20/\x20im_remove\x20/\x20im_clear\x20do\x20not\x20emit\x20events\x20(contact.move:70-100).\x20External\x20'+'indexers\x20and\x20notification\x20systems\x20cannot\x20rely\x20on\x20event\x20streams\x20to\x20track\x20IM\x20list\x20'+'changes;\x20they\x20must\x20poll\x20the\x20ims\x20field\x20directly,\x20increasing\x20latency\x20and\x20RPC\x20cost.','affected_stakeholders':['creator','consumer'],'scenario':'Indexer\x20expects\x20an\x20event\x20on\x20im_add\x20but\x20none\x20is\x20emitted;\x20UI\x20fails\x20to\x20refresh','mitigation':'External\x20indexers\x20should\x20poll\x20the\x20Contact.ims\x20field\x20on\x20a\x20cadence.\x20A\x20future\x20version\x20'+'may\x20add\x20IMEvent;\x20until\x20then,\x20do\x20not\x20build\x20critical\x20UX\x20on\x20IM\x20event\x20streams.','auto_fixable':![]},'check':a=>null},R_C_04={'rule':{'id':'R-CONTACT-04','level':'LOW','category':'semantic','title':'location\x20defaults\x20to\x20empty\x20string\x20—\x20may\x20be\x20misread\x20as\x20\x27unset\x27','description':'A\x20freshly\x20created\x20Contact\x20has\x20location=\x22\x22\x20(empty\x20String).\x20The\x20Move\x20type\x20does\x20not\x20'+'distinguish\x20\x27unset\x27\x20from\x20\x27empty\x27,\x20so\x20consumers\x20may\x20misinterpret\x20an\x20empty\x20location\x20'+'as\x20\x27globally\x20applicable\x27\x20or\x20as\x20\x27missing\x20data\x27.','affected_stakeholders':['creator','consumer'],'scenario':'Consumer\x20reads\x20location=\x22\x22\x20and\x20treats\x20the\x20Contact\x20as\x20global\x20when\x20it\x20was\x20never\x20set','mitigation':'Document\x20that\x20empty\x20location\x20means\x20\x27not\x20specified\x27.\x20If\x20a\x20default\x20region\x20is\x20required,\x20'+'set\x20location\x20explicitly\x20at\x20creation\x20time.','auto_fixable':!![]},'check':a=>{if(!a['location_empty'])return null;return{...R_C_04['rule'],'evidence':'location=\x22\x22\x20(empty,\x20default)'};}},R_C_05={'rule':{'id':'R-CONTACT-05','level':'MEDIUM','category':'lifecycle','title':'my_status\x20silently\x20fails\x20for\x20non-IM-members','description':'my_status\x20only\x20updates\x20the\x20caller\x27s\x20status\x20entry\x20if\x20the\x20caller\x20is\x20in\x20the\x20ims\x20list\x20'+'(contact.move:35-42).\x20For\x20a\x20non-IM-member,\x20the\x20call\x20silently\x20succeeds\x20without\x20any\x20'+'state\x20change\x20—\x20there\x20is\x20no\x20abort\x20and\x20no\x20event.\x20Users\x20get\x20no\x20feedback,\x20making\x20it\x20'+'impossible\x20to\x20distinguish\x20\x27status\x20updated\x27\x20from\x20\x27operation\x20ignored\x27.','affected_stakeholders':['im_member'],'scenario':'Non-IM-member\x20calls\x20my_status\x20expecting\x20an\x20error;\x20operation\x20is\x20silently\x20ignored','mitigation':'SDK\x20layer\x20should\x20pre-validate\x20IM\x20membership\x20before\x20submitting\x20my_status\x20and\x20return\x20a\x20'+'clear\x20error.\x20UI\x20should\x20show\x20\x27not\x20an\x20IM\x20member\x27\x20instead\x20of\x20\x27success\x27.','auto_fixable':![]},'check':a=>{if(!a['my_status_from_non_member'])return null;return{...R_C_05['rule'],'evidence':'my_status_from_non_member=true\x20(will\x20be\x20silently\x20ignored)'};}},R_C_06={'rule':{'id':'R-CONTACT-06','level':'LOW','category':'semantic','title':'im_add\x20description\x20uses\x20LONG_NAME\x20(not\x20DESCRIPTION)\x20—\x20different\x20length\x20cap','description':'im_add\x27s\x20description\x20parameter\x20is\x20validated\x20with\x20common::LONG_NAME\x20rather\x20than\x20'+'common::DESCRIPTION\x20(contact.move:70-86).\x20The\x20two\x20validators\x20have\x20different\x20length\x20'+'limits;\x20callers\x20expecting\x20DESCRIPTION\x20semantics\x20may\x20submit\x20overly\x20long\x20strings\x20and\x20'+'hit\x20an\x20unexpected\x20abort.','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20an\x20im_add\x20description\x20sized\x20for\x20DESCRIPTION\x20but\x20hits\x20LONG_NAME\x20limit','mitigation':'Document\x20that\x20im_add\x20description\x20uses\x20LONG_NAME\x20validation.\x20SDK\x20should\x20expose\x20the\x20'+'exact\x20limit\x20so\x20callers\x20size\x20their\x20strings\x20correctly.','auto_fixable':![]},'check':a=>{if(!a['im_add_description_uses_long_name'])return null;return{...R_C_06['rule'],'evidence':'im_add\x20description\x20validated\x20with\x20LONG_NAME'};}},R_C_07={'rule':{'id':'R-CONTACT-07','level':'MEDIUM','category':'cross_object','title':'permission_um_set\x20creates\x20Contact\x20↔\x20Permission\x20bidirectional\x20dependency','description':'When\x20Contact\x20is\x20set\x20as\x20a\x20Permission\x27s\x20um\x20via\x20permission_um_set\x20(contact.move:207-209),\x20'+'a\x20bidirectional\x20dependency\x20forms:\x20Permission.um\x20→\x20Contact,\x20and\x20Contact.permission\x20→\x20'+'Permission.\x20Deleting\x20the\x20Contact\x20without\x20first\x20clearing\x20the\x20um\x20reference\x20leaves\x20a\x20'+'dangling\x20pointer\x20in\x20Permission.um.','affected_stakeholders':['creator','consumer'],'scenario':'Contact\x20is\x20deleted\x20while\x20still\x20bound\x20as\x20Permission.um;\x20Permission.um\x20becomes\x20dangling','mitigation':'Document\x20the\x20deletion\x20order:\x20(1)\x20clear\x20Permission.um\x20via\x20permission_um_set(null)\x20'+'first,\x20(2)\x20then\x20delete\x20the\x20Contact.\x20SDK\x20should\x20refuse\x20to\x20delete\x20a\x20Contact\x20that\x20is\x20'+'still\x20bound\x20as\x20a\x20um.','auto_fixable':![]},'check':a=>{if(!a['bound_to_permission_um'])return null;return{...R_C_07['rule'],'evidence':'bound_to_permission_um=true\x20(deletion\x20requires\x20unbinding)'};}},R_C_08={'rule':{'id':'R-CONTACT-08','level':'LOW','category':'knowledge','title':'Knowledge\x20layer\x20&\x20constant\x20sync\x20—\x20RESOLVED','description':'MAX_IM_COUNT\x20is\x20now\x20synced\x20to\x20onchain-constants.ts\x20('+MAX_IM_COUNT+').\x20The\x20MCP\x20'+'Knowledge\x20layer\x20now\x20includes\x20contact-risk.ts.\x20This\x20risk\x20rule\x20is\x20retained\x20for\x20'+'historical\x20audit\x20and\x20to\x20detect\x20future\x20regressions.','affected_stakeholders':['system'],'scenario':'Future\x20regression:\x20someone\x20removes\x20MAX_IM_COUNT\x20from\x20onchain-constants.ts','mitigation':'Run\x20the\x20onchain-constants\x20sync\x20test\x20to\x20detect\x20drift.','auto_fixable':![]},'check':a=>{if(a['constants_synced'])return null;return{...R_C_08['rule'],'evidence':'constants_synced=false'};}};export const CONTACT_RISK_RULES=[R_C_01,R_C_02,R_C_03,R_C_04,R_C_05,R_C_06,R_C_07,R_C_08];export const CONTACT_RISK_VERSION='1.0.0';export function checkContactRisks(a){const b=[];for(const c of CONTACT_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-CONTACT-03')&&b['push'](R_C_03['rule']),b;}export function getContactRiskById(a){return CONTACT_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
@@ -0,0 +1,27 @@
1
+ export type ContactTemplateParamType = "string";
2
+ export interface ContactTemplateParam {
3
+ name: string;
4
+ type: ContactTemplateParamType;
5
+ description: string;
6
+ required: boolean;
7
+ }
8
+ export interface ContactTemplate {
9
+ id: string;
10
+ name: string;
11
+ description: string;
12
+ applicable_scenes: string[];
13
+ industry_tags: string[];
14
+ params: ContactTemplateParam[];
15
+ body: (params: Record<string, string>) => object;
16
+ notes?: string[];
17
+ }
18
+ export declare const CONTACT_TEMPLATES: ContactTemplate[];
19
+ export declare const CONTACT_TEMPLATES_VERSION = "1.0.0";
20
+ export declare function getContactTemplateById(id: string): ContactTemplate | undefined;
21
+ export declare function fillTemplate(templateId: string, params: Record<string, string>): {
22
+ ok: true;
23
+ body: object;
24
+ } | {
25
+ ok: false;
26
+ error: string;
27
+ };
@@ -0,0 +1 @@
1
+ export const CONTACT_TEMPLATES=[{'id':'T-C-01','name':'Basic\x20contact','description':'Named\x20contact\x20with\x20a\x20permission\x20reference\x20and\x20description.\x20Bind\x20to\x20a\x20Service\x20via\x20`um`.','applicable_scenes':['contact_basic'],'industry_tags':['universal'],'params':[{'name':'name','type':'string','description':'Contact\x20object\x20name','required':!![]},{'name':'permission','type':'string','description':'Permission\x20object\x20name/address','required':!![]},{'name':'description','type':'string','description':'Contact\x20description\x20shown\x20to\x20customers','required':!![]}],'body':a=>({'object':{'name':a['name'],'permission':a['permission'],'replaceExistName':!![]},'description':a['description']}),'notes':['Bind\x20this\x20contact\x20to\x20a\x20Service\x20via\x20the\x20service\x20call\x27s\x20\x27um\x27\x20field']},{'id':'T-C-02','name':'Support\x20contact\x20with\x20IM','description':'Contact\x20with\x20an\x20initial\x20IM\x20entry\x20pointing\x20at\x20a\x20support\x20account\x20(after-sales\x20/\x20pre-order).','applicable_scenes':['contact_support'],'industry_tags':['retail','rental','education','travel','freelance','subscription'],'params':[{'name':'name','type':'string','description':'Contact\x20object\x20name','required':!![]},{'name':'permission','type':'string','description':'Permission\x20object\x20name/address','required':!![]},{'name':'description','type':'string','description':'Contact\x20description\x20shown\x20to\x20customers','required':!![]},{'name':'support_account','type':'string','description':'Support\x20account\x20name\x20or\x200x\x20address\x20for\x20IM','required':!![]},{'name':'im_description','type':'string','description':'IM\x20entry\x20description\x20(e.g.\x20\x27Primary\x20support\x20representative\x27)','required':!![]}],'body':a=>({'object':{'name':a['name'],'permission':a['permission'],'replaceExistName':!![]},'description':a['description'],'ims':{'op':'add','im':[{'at':a['support_account'],'description':a['im_description']}]}}),'notes':['ims.im[].at\x20accepts\x20an\x20account\x20name\x20or\x20a\x20full\x200x\x20address','ims\x20is\x20an\x20op\x20discriminated\x20union\x20—\x20{op:\x27add\x27|\x27set\x27|\x27remove\x27|\x27clear\x27}']}];export const CONTACT_TEMPLATES_VERSION='1.0.0';export function getContactTemplateById(a){return CONTACT_TEMPLATES['find'](b=>b['id']===a);}export function fillTemplate(a,b){const c=getContactTemplateById(a);if(!c)return{'ok':![],'error':'Template\x20'+a+'\x20not\x20found'};for(const d of c['params']){if(d['required']&&!(d['name']in b))return{'ok':![],'error':'Missing\x20required\x20param:\x20'+d['name']};}return{'ok':!![],'body':c['body'](b)};}
@@ -1,206 +1 @@
1
- import { MAX_REWARD_COUNT, MAX_GUARD_COUNT_DEMAND, MAX_DESCRIPTION_LENGTH, MAX_LONG_NAME_LENGTH, } from "@wowok/wowok";
2
- const MAX_FEEDBACK_COUNT = 20;
3
- function checkDescription(input) {
4
- const len = input.description?.length ?? 0;
5
- const passed = len > 0 && len <= MAX_DESCRIPTION_LENGTH;
6
- return {
7
- id: "C-DEM-01",
8
- severity: passed ? "info" : (len === 0 ? "warn" : "block"),
9
- title: `description non-empty and within MAX_DESCRIPTION_LENGTH (${MAX_DESCRIPTION_LENGTH} chars)`,
10
- description: "description is a REQUIRED field. Move contract validates via common::DESCRIPTION (demand.move:157,177). " +
11
- "Empty string is technically rejected by common::DESCRIPTION only if NAME_ALLOW_EMPTY is not used; the new_imp " +
12
- "path uses common::DESCRIPTION which allows empty but enforces the 4000-char limit. Non-empty descriptions are " +
13
- "strongly recommended for Demand discoverability.",
14
- passed,
15
- evidence: input.description === undefined ? "undefined" : `length=${len}, limit=${MAX_DESCRIPTION_LENGTH}`,
16
- fix_hint: passed ? undefined : `Provide a description of 1..${MAX_DESCRIPTION_LENGTH} characters.`,
17
- };
18
- }
19
- function checkLocation(input) {
20
- const len = input.location?.length ?? 0;
21
- const passed = len <= MAX_LONG_NAME_LENGTH;
22
- return {
23
- id: "C-DEM-02",
24
- severity: passed ? "info" : "block",
25
- title: `location within MAX_LONG_NAME_LENGTH (${MAX_LONG_NAME_LENGTH} chars)`,
26
- description: "location is set via location_set_imp (demand.move:179-182) which validates via common::LONG_NAME. " +
27
- "Move aborts with E_LONG_NAME_LENGTH_EXCEEDED (11) on overflow. Empty location (\"\") is valid — new_imp " +
28
- "initializes location to empty string. Use location_set to update after creation.",
29
- passed,
30
- evidence: input.location === undefined ? "undefined" : `length=${len}, limit=${MAX_LONG_NAME_LENGTH}`,
31
- fix_hint: passed ? undefined : `Trim location to ≤ ${MAX_LONG_NAME_LENGTH} characters.`,
32
- };
33
- }
34
- function checkRewards(input) {
35
- const count = input.rewards?.length ?? 0;
36
- const passed = count <= MAX_REWARD_COUNT;
37
- return {
38
- id: "C-DEM-03",
39
- severity: passed ? "info" : "block",
40
- title: `rewards count within MAX_REWARD_COUNT (${MAX_REWARD_COUNT})`,
41
- description: "Each reward_add_imp (demand.move:184-191) checks `vector::length(&self.rewards) < MAX_REWARD_COUNT` " +
42
- "before pushing (after de-duplication). Move aborts with E_MAX_REWARD_COUNT_EXCEEDED (1) on overflow. " +
43
- "Rewards are affiliated via the Registrar — adding/removing triggers affiliation/disaffiliation.",
44
- passed,
45
- evidence: `count=${count}, limit=${MAX_REWARD_COUNT}`,
46
- fix_hint: passed ? undefined : `Remove rewards before adding new ones. Limit=${MAX_REWARD_COUNT}.`,
47
- };
48
- }
49
- function checkGuards(input) {
50
- const count = input.guards?.length ?? 0;
51
- const passed = count <= MAX_GUARD_COUNT_DEMAND;
52
- return {
53
- id: "C-DEM-04",
54
- severity: passed ? "info" : "block",
55
- title: `guards count within MAX_GUARD_COUNT_DEMAND (${MAX_GUARD_COUNT_DEMAND})`,
56
- description: "Each guard_add_imp (demand.move:213-242) checks `vector::length(&self.guards) < MAX_GUARD_COUNT` " +
57
- "before pushing (after duplicate check — duplicates update service_identifier in place). " +
58
- "Move aborts with E_MAX_GUARD_COUNT_EXCEEDED (2) on overflow. Guards are affiliated via the Registrar.",
59
- passed,
60
- evidence: `count=${count}, limit=${MAX_GUARD_COUNT_DEMAND}`,
61
- fix_hint: passed ? undefined : `Remove guards before adding new ones. Limit=${MAX_GUARD_COUNT_DEMAND}.`,
62
- };
63
- }
64
- function checkFeedback(input) {
65
- const count = input.feedback?.length ?? 0;
66
- const passed = count <= MAX_FEEDBACK_COUNT;
67
- return {
68
- id: "C-DEM-05",
69
- severity: passed ? "info" : "block",
70
- title: `feedback batch count within MAX_FEEDBACK_COUNT (${MAX_FEEDBACK_COUNT})`,
71
- description: "Move feedback (demand.move:352) updates ONE presenter per call — feedback_imp writes to a single " +
72
- "ServiceInfo record. The SDK batches multiple feedback calls and caps the batch at MAX_FEEDBACK_COUNT=" +
73
- `${MAX_FEEDBACK_COUNT} (SDK-only limit, NOT in onchain-constants.ts). Exceeding the SDK batch limit is ` +
74
- "rejected before transaction building. Each feedback string is validated by common::DESCRIPTION (4000 chars).",
75
- passed,
76
- evidence: `count=${count}, limit=${MAX_FEEDBACK_COUNT}`,
77
- fix_hint: passed ? undefined : `Split feedback into batches of ≤ ${MAX_FEEDBACK_COUNT} entries.`,
78
- };
79
- }
80
- function checkServiceIdentifier(input) {
81
- const sid = input.service_identifier;
82
- if (sid === null || sid === undefined) {
83
- return {
84
- id: "C-DEM-06",
85
- severity: "info",
86
- title: "service_identifier is null/undefined → Option::none (use supplied service address)",
87
- description: "When service_identifier is None, guard_add_imp stores Option::none in ServiceGuard. At present_with_passport " +
88
- "time, present_with_passport_imp uses the service parameter (or Option::none for plain present_with_passport). " +
89
- "Use None when the Demand does not need to route presentations through a specific Service submission.",
90
- passed: true,
91
- evidence: "null/undefined → Option::none",
92
- };
93
- }
94
- const isU8 = typeof sid === "number" && Number.isInteger(sid) && sid >= 0 && sid <= 255;
95
- return {
96
- id: "C-DEM-06",
97
- severity: isU8 ? "info" : "block",
98
- title: "service_identifier is a valid u8 (0-255) when provided",
99
- description: "When provided, service_identifier must be a u8 index into the Guard's submission registry. " +
100
- "guard_add_imp (demand.move:218-222) calls guard::get_submission_object_type(guard, *i) and " +
101
- "common::assert_service_object_type(t) — the submission at that index MUST exist and have type " +
102
- "ObjectType::Service. At present_with_passport time, the submission address is extracted from the Passport " +
103
- "via passport::submission_get(passport, &g, *service_identifier).",
104
- passed: isU8,
105
- evidence: `service_identifier=${sid}`,
106
- fix_hint: isU8 ? undefined : "Provide an integer in [0, 255] that indexes a Service-typed submission in the Guard.",
107
- };
108
- }
109
- function checkByGuard(input) {
110
- const byGuard = input.by_guard;
111
- if (byGuard === null || byGuard === undefined) {
112
- return {
113
- id: "C-DEM-07",
114
- severity: "info",
115
- title: "by_guard is null → use plain present (requires empty guards vector)",
116
- description: "When by_guard is None, the caller uses plain present (demand.move:100) which asserts " +
117
- "`vector::is_empty(&self.guards)` — aborts with E_NEED_PASSPORT (3) if guards exist. Use this path " +
118
- "for open Demands (no guards).",
119
- passed: true,
120
- evidence: "null/undefined → plain present path",
121
- };
122
- }
123
- if (input.guards === undefined) {
124
- return {
125
- id: "C-DEM-07",
126
- severity: "info",
127
- title: "by_guard provided (cannot verify membership — guards list not supplied)",
128
- description: "present_with_passport_imp (demand.move:110-129) iterates the guards vector looking for a matching " +
129
- "guard address. If not found, it aborts with E_GUARD_NOT_FOUND (4). The caller must ensure by_guard " +
130
- "is in Demand.guards — this check could not verify because the guards list was not supplied.",
131
- passed: true,
132
- evidence: `by_guard=${byGuard.substring(0, 10)}... (guards list not supplied)`,
133
- fix_hint: "Pass input.guards to enable membership verification.",
134
- };
135
- }
136
- const isInGuards = input.guards.includes(byGuard);
137
- return {
138
- id: "C-DEM-07",
139
- severity: isInGuards ? "info" : "block",
140
- title: "by_guard exists in Demand.guards (when specified)",
141
- description: "When by_guard is specified, present_with_passport_imp (demand.move:110-129) iterates the guards vector " +
142
- "looking for a matching guard address. If not found, it aborts with E_GUARD_NOT_FOUND (4). The caller " +
143
- "MUST ensure by_guard was previously added via guard_add.",
144
- passed: isInGuards,
145
- evidence: `by_guard=${byGuard.substring(0, 10)}..., in guards=${isInGuards}`,
146
- fix_hint: isInGuards ? undefined : "Call guard_add(permission, guard, service_identifier) first.",
147
- };
148
- }
149
- function checkPermissionSetAvailable(input) {
150
- const available = input.permission_set_available !== false;
151
- return {
152
- id: "C-DEM-08",
153
- severity: available ? "info" : "warn",
154
- title: "permission_set available via CallPermission.apply (DE-D-2=A)",
155
- description: "The Move permission_set function (demand.move:286) is exposed in the SDK via the CallPermission.apply " +
156
- "mechanism (DE-D-2=A). It calls permission::assert_owner(old) and registrar::affiliation_change to migrate " +
157
- "the affiliation. Permission indices for Demand (demand.move:20): 400=DEMAND_NEW, 401=DEMAND_DESCRIPTION, " +
158
- "402=DEMAND_LOCATION, 404=DEMAND_GUARD, 405=DEMAND_REWARD, 406=DEMAND_FEEDBACK, 407=DEMAND_OWNER_RECEIVE, " +
159
- "408=DEMAND_UM. This is an info check — it confirms the capability is available, not a creation prerequisite.",
160
- passed: available,
161
- evidence: available ? "exposed via CallPermission.apply" : "not available (regression)",
162
- fix_hint: available ? undefined : "Restore the CallPermission.apply path for permission_set.",
163
- };
164
- }
165
- export function preCheckDemandCreation(input) {
166
- return [
167
- checkDescription(input),
168
- checkLocation(input),
169
- checkRewards(input),
170
- checkGuards(input),
171
- checkFeedback(input),
172
- checkServiceIdentifier(input),
173
- checkByGuard(input),
174
- checkPermissionSetAvailable(input),
175
- ];
176
- }
177
- export function canCreateDemand(input) {
178
- const items = preCheckDemandCreation(input);
179
- return {
180
- canCreate: items.every(i => i.severity !== "block" || i.passed),
181
- blockers: items.filter(i => i.severity === "block" && !i.passed),
182
- warnings: items.filter(i => i.severity === "warn" && !i.passed),
183
- info: items.filter(i => i.severity === "info"),
184
- };
185
- }
186
- export function formatDemandCreationSummary(input) {
187
- const { canCreate, blockers, warnings, info } = canCreateDemand(input);
188
- const lines = [];
189
- lines.push(canCreate ? "✓ Demand pre-check PASSED" : "✗ Demand pre-check FAILED");
190
- lines.push("");
191
- if (blockers.length > 0) {
192
- lines.push("BLOCKERS (must fix before operation):");
193
- blockers.forEach(b => lines.push(` [${b.id}] ${b.title} — ${b.evidence ?? ""}`));
194
- lines.push("");
195
- }
196
- if (warnings.length > 0) {
197
- lines.push("WARNINGS (review recommended):");
198
- warnings.forEach(w => lines.push(` [${w.id}] ${w.title} — ${w.evidence ?? ""}`));
199
- lines.push("");
200
- }
201
- if (info.length > 0) {
202
- lines.push("INFO:");
203
- info.forEach(i => lines.push(` [${i.id}] ${i.title}`));
204
- }
205
- return lines.join("\n");
206
- }
1
+ import{MAX_REWARD_COUNT,MAX_GUARD_COUNT_DEMAND,MAX_DESCRIPTION_LENGTH,MAX_LONG_NAME_LENGTH}from'@wowok/wowok';const MAX_FEEDBACK_COUNT=0x14;function checkDescription(a){const b=a['description']?.['length']??0x0,c=b>0x0&&b<=MAX_DESCRIPTION_LENGTH;return{'id':'C-DEM-01','severity':c?'info':b===0x0?'warn':'block','title':'description\x20non-empty\x20and\x20within\x20MAX_DESCRIPTION_LENGTH\x20('+MAX_DESCRIPTION_LENGTH+'\x20chars)','description':'description\x20is\x20a\x20REQUIRED\x20field.\x20Move\x20contract\x20validates\x20via\x20common::DESCRIPTION\x20(demand.move:157,177).\x20'+'Empty\x20string\x20is\x20technically\x20rejected\x20by\x20common::DESCRIPTION\x20only\x20if\x20NAME_ALLOW_EMPTY\x20is\x20not\x20used;\x20the\x20new_imp\x20'+'path\x20uses\x20common::DESCRIPTION\x20which\x20allows\x20empty\x20but\x20enforces\x20the\x204000-char\x20limit.\x20Non-empty\x20descriptions\x20are\x20'+'strongly\x20recommended\x20for\x20Demand\x20discoverability.','passed':c,'evidence':a['description']===undefined?'undefined':'length='+b+',\x20limit='+MAX_DESCRIPTION_LENGTH,'fix_hint':c?undefined:'Provide\x20a\x20description\x20of\x201..'+MAX_DESCRIPTION_LENGTH+'\x20characters.'};}function checkLocation(a){const b=a['location']?.['length']??0x0,c=b<=MAX_LONG_NAME_LENGTH;return{'id':'C-DEM-02','severity':c?'info':'block','title':'location\x20within\x20MAX_LONG_NAME_LENGTH\x20('+MAX_LONG_NAME_LENGTH+'\x20chars)','description':'location\x20is\x20set\x20via\x20location_set_imp\x20(demand.move:179-182)\x20which\x20validates\x20via\x20common::LONG_NAME.\x20'+'Move\x20aborts\x20with\x20E_LONG_NAME_LENGTH_EXCEEDED\x20(11)\x20on\x20overflow.\x20Empty\x20location\x20(\x22\x22)\x20is\x20valid\x20—\x20new_imp\x20'+'initializes\x20location\x20to\x20empty\x20string.\x20Use\x20location_set\x20to\x20update\x20after\x20creation.','passed':c,'evidence':a['location']===undefined?'undefined':'length='+b+',\x20limit='+MAX_LONG_NAME_LENGTH,'fix_hint':c?undefined:'Trim\x20location\x20to\x20≤\x20'+MAX_LONG_NAME_LENGTH+'\x20characters.'};}function checkRewards(a){const b=a['rewards']?.['length']??0x0,c=b<=MAX_REWARD_COUNT;return{'id':'C-DEM-03','severity':c?'info':'block','title':'rewards\x20count\x20within\x20MAX_REWARD_COUNT\x20('+MAX_REWARD_COUNT+')','description':'Each\x20reward_add_imp\x20(demand.move:184-191)\x20checks\x20`vector::length(&self.rewards)\x20<\x20MAX_REWARD_COUNT`\x20'+'before\x20pushing\x20(after\x20de-duplication).\x20Move\x20aborts\x20with\x20E_MAX_REWARD_COUNT_EXCEEDED\x20(1)\x20on\x20overflow.\x20'+'Rewards\x20are\x20affiliated\x20via\x20the\x20Registrar\x20—\x20adding/removing\x20triggers\x20affiliation/disaffiliation.','passed':c,'evidence':'count='+b+',\x20limit='+MAX_REWARD_COUNT,'fix_hint':c?undefined:'Remove\x20rewards\x20before\x20adding\x20new\x20ones.\x20Limit='+MAX_REWARD_COUNT+'.'};}function checkGuards(a){const b=a['guards']?.['length']??0x0,c=b<=MAX_GUARD_COUNT_DEMAND;return{'id':'C-DEM-04','severity':c?'info':'block','title':'guards\x20count\x20within\x20MAX_GUARD_COUNT_DEMAND\x20('+MAX_GUARD_COUNT_DEMAND+')','description':'Each\x20guard_add_imp\x20(demand.move:213-242)\x20checks\x20`vector::length(&self.guards)\x20<\x20MAX_GUARD_COUNT`\x20'+'before\x20pushing\x20(after\x20duplicate\x20check\x20—\x20duplicates\x20update\x20service_identifier\x20in\x20place).\x20'+'Move\x20aborts\x20with\x20E_MAX_GUARD_COUNT_EXCEEDED\x20(2)\x20on\x20overflow.\x20Guards\x20are\x20affiliated\x20via\x20the\x20Registrar.','passed':c,'evidence':'count='+b+',\x20limit='+MAX_GUARD_COUNT_DEMAND,'fix_hint':c?undefined:'Remove\x20guards\x20before\x20adding\x20new\x20ones.\x20Limit='+MAX_GUARD_COUNT_DEMAND+'.'};}function checkFeedback(a){const b=a['feedback']?.['length']??0x0,c=b<=MAX_FEEDBACK_COUNT;return{'id':'C-DEM-05','severity':c?'info':'block','title':'feedback\x20batch\x20count\x20within\x20MAX_FEEDBACK_COUNT\x20('+MAX_FEEDBACK_COUNT+')','description':'Move\x20feedback\x20(demand.move:352)\x20updates\x20ONE\x20presenter\x20per\x20call\x20—\x20feedback_imp\x20writes\x20to\x20a\x20single\x20'+'ServiceInfo\x20record.\x20The\x20SDK\x20batches\x20multiple\x20feedback\x20calls\x20and\x20caps\x20the\x20batch\x20at\x20MAX_FEEDBACK_COUNT='+(MAX_FEEDBACK_COUNT+'\x20(SDK-only\x20limit,\x20NOT\x20in\x20onchain-constants.ts).\x20Exceeding\x20the\x20SDK\x20batch\x20limit\x20is\x20')+'rejected\x20before\x20transaction\x20building.\x20Each\x20feedback\x20string\x20is\x20validated\x20by\x20common::DESCRIPTION\x20(4000\x20chars).','passed':c,'evidence':'count='+b+',\x20limit='+MAX_FEEDBACK_COUNT,'fix_hint':c?undefined:'Split\x20feedback\x20into\x20batches\x20of\x20≤\x20'+MAX_FEEDBACK_COUNT+'\x20entries.'};}function checkServiceIdentifier(a){const b=a['service_identifier'];if(b===null||b===undefined)return{'id':'C-DEM-06','severity':'info','title':'service_identifier\x20is\x20null/undefined\x20→\x20Option::none\x20(use\x20supplied\x20service\x20address)','description':'When\x20service_identifier\x20is\x20None,\x20guard_add_imp\x20stores\x20Option::none\x20in\x20ServiceGuard.\x20At\x20present_with_passport\x20'+'time,\x20present_with_passport_imp\x20uses\x20the\x20service\x20parameter\x20(or\x20Option::none\x20for\x20plain\x20present_with_passport).\x20'+'Use\x20None\x20when\x20the\x20Demand\x20does\x20not\x20need\x20to\x20route\x20presentations\x20through\x20a\x20specific\x20Service\x20submission.','passed':!![],'evidence':'null/undefined\x20→\x20Option::none'};const c=typeof b==='number'&&Number['isInteger'](b)&&b>=0x0&&b<=0xff;return{'id':'C-DEM-06','severity':c?'info':'block','title':'service_identifier\x20is\x20a\x20valid\x20u8\x20(0-255)\x20when\x20provided','description':'When\x20provided,\x20service_identifier\x20must\x20be\x20a\x20u8\x20index\x20into\x20the\x20Guard\x27s\x20submission\x20registry.\x20'+'guard_add_imp\x20(demand.move:218-222)\x20calls\x20guard::get_submission_object_type(guard,\x20*i)\x20and\x20'+'common::assert_service_object_type(t)\x20—\x20the\x20submission\x20at\x20that\x20index\x20MUST\x20exist\x20and\x20have\x20type\x20'+'ObjectType::Service.\x20At\x20present_with_passport\x20time,\x20the\x20submission\x20address\x20is\x20extracted\x20from\x20the\x20Passport\x20'+'via\x20passport::submission_get(passport,\x20&g,\x20*service_identifier).','passed':c,'evidence':'service_identifier='+b,'fix_hint':c?undefined:'Provide\x20an\x20integer\x20in\x20[0,\x20255]\x20that\x20indexes\x20a\x20Service-typed\x20submission\x20in\x20the\x20Guard.'};}function checkByGuard(a){const b=a['by_guard'];if(b===null||b===undefined)return{'id':'C-DEM-07','severity':'info','title':'by_guard\x20is\x20null\x20→\x20use\x20plain\x20present\x20(requires\x20empty\x20guards\x20vector)','description':'When\x20by_guard\x20is\x20None,\x20the\x20caller\x20uses\x20plain\x20present\x20(demand.move:100)\x20which\x20asserts\x20'+'`vector::is_empty(&self.guards)`\x20—\x20aborts\x20with\x20E_NEED_PASSPORT\x20(3)\x20if\x20guards\x20exist.\x20Use\x20this\x20path\x20'+'for\x20open\x20Demands\x20(no\x20guards).','passed':!![],'evidence':'null/undefined\x20→\x20plain\x20present\x20path'};if(a['guards']===undefined)return{'id':'C-DEM-07','severity':'info','title':'by_guard\x20provided\x20(cannot\x20verify\x20membership\x20—\x20guards\x20list\x20not\x20supplied)','description':'present_with_passport_imp\x20(demand.move:110-129)\x20iterates\x20the\x20guards\x20vector\x20looking\x20for\x20a\x20matching\x20'+'guard\x20address.\x20If\x20not\x20found,\x20it\x20aborts\x20with\x20E_GUARD_NOT_FOUND\x20(4).\x20The\x20caller\x20must\x20ensure\x20by_guard\x20'+'is\x20in\x20Demand.guards\x20—\x20this\x20check\x20could\x20not\x20verify\x20because\x20the\x20guards\x20list\x20was\x20not\x20supplied.','passed':!![],'evidence':'by_guard='+b['substring'](0x0,0xa)+'...\x20(guards\x20list\x20not\x20supplied)','fix_hint':'Pass\x20input.guards\x20to\x20enable\x20membership\x20verification.'};const c=a['guards']['includes'](b);return{'id':'C-DEM-07','severity':c?'info':'block','title':'by_guard\x20exists\x20in\x20Demand.guards\x20(when\x20specified)','description':'When\x20by_guard\x20is\x20specified,\x20present_with_passport_imp\x20(demand.move:110-129)\x20iterates\x20the\x20guards\x20vector\x20'+'looking\x20for\x20a\x20matching\x20guard\x20address.\x20If\x20not\x20found,\x20it\x20aborts\x20with\x20E_GUARD_NOT_FOUND\x20(4).\x20The\x20caller\x20'+'MUST\x20ensure\x20by_guard\x20was\x20previously\x20added\x20via\x20guard_add.','passed':c,'evidence':'by_guard='+b['substring'](0x0,0xa)+'...,\x20in\x20guards='+c,'fix_hint':c?undefined:'Call\x20guard_add(permission,\x20guard,\x20service_identifier)\x20first.'};}function checkPermissionSetAvailable(a){const b=a['permission_set_available']!==![];return{'id':'C-DEM-08','severity':b?'info':'warn','title':'permission_set\x20available\x20via\x20CallPermission.apply\x20(DE-D-2=A)','description':'The\x20Move\x20permission_set\x20function\x20(demand.move:286)\x20is\x20exposed\x20in\x20the\x20SDK\x20via\x20the\x20CallPermission.apply\x20'+'mechanism\x20(DE-D-2=A).\x20It\x20calls\x20permission::assert_owner(old)\x20and\x20registrar::affiliation_change\x20to\x20migrate\x20'+'the\x20affiliation.\x20Permission\x20indices\x20for\x20Demand\x20(demand.move:20):\x20400=DEMAND_NEW,\x20401=DEMAND_DESCRIPTION,\x20'+'402=DEMAND_LOCATION,\x20404=DEMAND_GUARD,\x20405=DEMAND_REWARD,\x20406=DEMAND_FEEDBACK,\x20407=DEMAND_OWNER_RECEIVE,\x20'+'408=DEMAND_UM.\x20This\x20is\x20an\x20info\x20check\x20—\x20it\x20confirms\x20the\x20capability\x20is\x20available,\x20not\x20a\x20creation\x20prerequisite.','passed':b,'evidence':b?'exposed\x20via\x20CallPermission.apply':'not\x20available\x20(regression)','fix_hint':b?undefined:'Restore\x20the\x20CallPermission.apply\x20path\x20for\x20permission_set.'};}export function preCheckDemandCreation(a){return[checkDescription(a),checkLocation(a),checkRewards(a),checkGuards(a),checkFeedback(a),checkServiceIdentifier(a),checkByGuard(a),checkPermissionSetAvailable(a)];}export function canCreateDemand(a){const b=preCheckDemandCreation(a);return{'canCreate':b['every'](c=>c['severity']!=='block'||c['passed']),'blockers':b['filter'](c=>c['severity']==='block'&&!c['passed']),'warnings':b['filter'](c=>c['severity']==='warn'&&!c['passed']),'info':b['filter'](c=>c['severity']==='info')};}export function formatDemandCreationSummary(a){const {canCreate:b,blockers:c,warnings:d,info:e}=canCreateDemand(a),f=[];return f['push'](b?'✓\x20Demand\x20pre-check\x20PASSED':'✗\x20Demand\x20pre-check\x20FAILED'),f['push'](''),c['length']>0x0&&(f['push']('BLOCKERS\x20(must\x20fix\x20before\x20operation):'),c['forEach'](g=>f['push']('\x20\x20['+g['id']+']\x20'+g['title']+'\x20—\x20'+(g['evidence']??''))),f['push']('')),d['length']>0x0&&(f['push']('WARNINGS\x20(review\x20recommended):'),d['forEach'](g=>f['push']('\x20\x20['+g['id']+']\x20'+g['title']+'\x20—\x20'+(g['evidence']??''))),f['push']('')),e['length']>0x0&&(f['push']('INFO:'),e['forEach'](g=>f['push']('\x20\x20['+g['id']+']\x20'+g['title']))),f['join']('\x0a');}
@@ -1,132 +1 @@
1
- export const DEMAND_MATCHING_VERSION = 1;
2
- const WEIGHTS = {
3
- tags: 30,
4
- price: 20,
5
- scenario: 15,
6
- trust: 20,
7
- location: 10,
8
- keyword: 5,
9
- };
10
- export function matchDemand(demand, services, limit = 5) {
11
- const matches = services
12
- .filter((s) => s.published !== false)
13
- .map((s) => computeMatchScore(demand, s))
14
- .filter((m) => m.score >= 60)
15
- .sort((a, b) => b.score - a.score)
16
- .slice(0, limit);
17
- return matches;
18
- }
19
- function computeMatchScore(demand, service) {
20
- const reasons = [];
21
- const warnings = [];
22
- let score = 0;
23
- const tagScore = computeTagScore(demand.tags, service.tags);
24
- score += tagScore;
25
- if (tagScore >= WEIGHTS.tags * 0.8) {
26
- reasons.push(`High tags match (${tagScore}/${WEIGHTS.tags})`);
27
- }
28
- const priceScore = computePriceScore(demand.maxPrice, service.price);
29
- score += priceScore;
30
- if (priceScore === WEIGHTS.price) {
31
- reasons.push(`Price within budget`);
32
- }
33
- else if (priceScore === 0 && demand.maxPrice && service.price) {
34
- warnings.push(`Price exceeds budget (${service.price} > ${demand.maxPrice})`);
35
- }
36
- const scenarioScore = computeScenarioScore(demand.scenario, service.scenario);
37
- score += scenarioScore;
38
- if (scenarioScore === WEIGHTS.scenario) {
39
- reasons.push(`Industry scenario matches (${service.scenario})`);
40
- }
41
- const trustScore = computeTrustScore(service.trustScore, demand.minTrustScore);
42
- score += trustScore;
43
- if (service.trustScore !== undefined) {
44
- if (service.trustScore >= 75) {
45
- reasons.push(`High trust score (${service.trustScore}/100)`);
46
- }
47
- else if (service.trustScore < 50) {
48
- warnings.push(`Low trust score (${service.trustScore}/100)`);
49
- }
50
- }
51
- const locationScore = computeLocationScore(demand.location, service.location);
52
- score += locationScore;
53
- if (locationScore === WEIGHTS.location && demand.location) {
54
- reasons.push(`Geographic location matches (${service.location})`);
55
- }
56
- const keywordScore = computeKeywordScore(demand.keywords, service.description);
57
- score += keywordScore;
58
- if (demand.minTrustScore !== undefined && service.trustScore !== undefined) {
59
- if (service.trustScore < demand.minTrustScore) {
60
- warnings.push(`Trust score below requirement (${service.trustScore} < ${demand.minTrustScore})`);
61
- score -= 10;
62
- }
63
- }
64
- return {
65
- service,
66
- score: Math.max(0, Math.min(100, score)),
67
- reasons,
68
- warnings,
69
- };
70
- }
71
- function computeTagScore(demandTags, serviceTags) {
72
- if (!demandTags || !serviceTags || demandTags.length === 0 || serviceTags.length === 0)
73
- return 0;
74
- const demandSet = new Set(demandTags.map((t) => t.toLowerCase()));
75
- const serviceSet = new Set(serviceTags.map((t) => t.toLowerCase()));
76
- const overlap = [...demandSet].filter((t) => serviceSet.has(t)).length;
77
- return Math.round((overlap / demandSet.size) * WEIGHTS.tags);
78
- }
79
- function computePriceScore(maxPrice, servicePrice) {
80
- if (!maxPrice || !servicePrice)
81
- return WEIGHTS.price / 2;
82
- try {
83
- const max = BigInt(maxPrice);
84
- const price = BigInt(servicePrice);
85
- if (price <= max)
86
- return WEIGHTS.price;
87
- if (price <= max * 110n / 100n)
88
- return WEIGHTS.price * 0.5;
89
- return 0;
90
- }
91
- catch {
92
- return WEIGHTS.price / 2;
93
- }
94
- }
95
- function computeScenarioScore(demandScenario, serviceScenario) {
96
- if (!demandScenario || !serviceScenario)
97
- return 0;
98
- return demandScenario.toLowerCase() === serviceScenario.toLowerCase() ? WEIGHTS.scenario : 0;
99
- }
100
- function computeTrustScore(serviceTrust, minTrust) {
101
- if (serviceTrust === undefined)
102
- return WEIGHTS.trust / 2;
103
- if (serviceTrust >= 75)
104
- return WEIGHTS.trust;
105
- if (serviceTrust >= 50)
106
- return WEIGHTS.trust * 0.6;
107
- if (serviceTrust >= 25)
108
- return WEIGHTS.trust * 0.3;
109
- return 0;
110
- }
111
- function computeLocationScore(demandLocation, serviceLocation) {
112
- if (!demandLocation || !serviceLocation)
113
- return 0;
114
- return demandLocation.toLowerCase() === serviceLocation.toLowerCase() ? WEIGHTS.location : 0;
115
- }
116
- function computeKeywordScore(keywords, description) {
117
- if (!keywords || !description || keywords.length === 0)
118
- return 0;
119
- const desc = description.toLowerCase();
120
- const matches = keywords.filter((k) => desc.includes(k.toLowerCase()));
121
- return Math.min(WEIGHTS.keyword, matches.length);
122
- }
123
- export function extractDemandInfo(demandData) {
124
- return {
125
- tags: demandData?.tags,
126
- maxPrice: demandData?.max_price ?? demandData?.maxPrice,
127
- scenario: demandData?.scenario,
128
- location: demandData?.location,
129
- minTrustScore: demandData?.min_trust_score ?? demandData?.minTrustScore,
130
- keywords: demandData?.keywords,
131
- };
132
- }
1
+ export const DEMAND_MATCHING_VERSION=0x1;const WEIGHTS={'tags':0x1e,'price':0x14,'scenario':0xf,'trust':0x14,'location':0xa,'keyword':0x5};export function matchDemand(a,b,c=0x5){const d=b['filter'](e=>e['published']!==![])['map'](e=>computeMatchScore(a,e))['filter'](e=>e['score']>=0x3c)['sort']((e,f)=>f['score']-e['score'])['slice'](0x0,c);return d;}function computeMatchScore(a,b){const c=[],d=[];let e=0x0;const f=computeTagScore(a['tags'],b['tags']);e+=f;f>=WEIGHTS['tags']*0.8&&c['push']('High\x20tags\x20match\x20('+f+'/'+WEIGHTS['tags']+')');const g=computePriceScore(a['maxPrice'],b['price']);e+=g;if(g===WEIGHTS['price'])c['push']('Price\x20within\x20budget');else g===0x0&&a['maxPrice']&&b['price']&&d['push']('Price\x20exceeds\x20budget\x20('+b['price']+'\x20>\x20'+a['maxPrice']+')');const h=computeScenarioScore(a['scenario'],b['scenario']);e+=h;h===WEIGHTS['scenario']&&c['push']('Industry\x20scenario\x20matches\x20('+b['scenario']+')');const i=computeTrustScore(b['trustScore'],a['minTrustScore']);e+=i;if(b['trustScore']!==undefined){if(b['trustScore']>=0x4b)c['push']('High\x20trust\x20score\x20('+b['trustScore']+'/100)');else b['trustScore']<0x32&&d['push']('Low\x20trust\x20score\x20('+b['trustScore']+'/100)');}const j=computeLocationScore(a['location'],b['location']);e+=j;j===WEIGHTS['location']&&a['location']&&c['push']('Geographic\x20location\x20matches\x20('+b['location']+')');const k=computeKeywordScore(a['keywords'],b['description']);return e+=k,a['minTrustScore']!==undefined&&b['trustScore']!==undefined&&(b['trustScore']<a['minTrustScore']&&(d['push']('Trust\x20score\x20below\x20requirement\x20('+b['trustScore']+'\x20<\x20'+a['minTrustScore']+')'),e-=0xa)),{'service':b,'score':Math['max'](0x0,Math['min'](0x64,e)),'reasons':c,'warnings':d};}function computeTagScore(a,b){if(!a||!b||a['length']===0x0||b['length']===0x0)return 0x0;const c=new Set(a['map'](f=>f['toLowerCase']())),d=new Set(b['map'](f=>f['toLowerCase']())),e=[...c]['filter'](f=>d['has'](f))['length'];return Math['round'](e/c['size']*WEIGHTS['tags']);}function computePriceScore(a,b){if(!a||!b)return WEIGHTS['price']/0x2;try{const c=BigInt(a),d=BigInt(b);if(d<=c)return WEIGHTS['price'];if(d<=c*0x6en/0x64n)return WEIGHTS['price']*0.5;return 0x0;}catch{return WEIGHTS['price']/0x2;}}function computeScenarioScore(a,b){if(!a||!b)return 0x0;return a['toLowerCase']()===b['toLowerCase']()?WEIGHTS['scenario']:0x0;}function computeTrustScore(a,b){if(a===undefined)return WEIGHTS['trust']/0x2;if(a>=0x4b)return WEIGHTS['trust'];if(a>=0x32)return WEIGHTS['trust']*0.6;if(a>=0x19)return WEIGHTS['trust']*0.3;return 0x0;}function computeLocationScore(a,b){if(!a||!b)return 0x0;return a['toLowerCase']()===b['toLowerCase']()?WEIGHTS['location']:0x0;}function computeKeywordScore(a,b){if(!a||!b||a['length']===0x0)return 0x0;const c=b['toLowerCase'](),d=a['filter'](e=>c['includes'](e['toLowerCase']()));return Math['min'](WEIGHTS['keyword'],d['length']);}export function extractDemandInfo(a){return{'tags':a?.['tags'],'maxPrice':a?.['max_price']??a?.['maxPrice'],'scenario':a?.['scenario'],'location':a?.['location'],'minTrustScore':a?.['min_trust_score']??a?.['minTrustScore'],'keywords':a?.['keywords']};}