@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,670 +1 @@
1
- import { validateGuardData, MAX_DESCRIPTION_LENGTH, MAX_TABLE_SIZE, } from "@wowok/wowok";
2
- import { assessGuardRisks } from "./guard-risk.js";
3
- import { findScene, inferSceneFromAction } from "./guard-ledger.js";
4
- import { suggestTemplateForScene } from "./guard-templates.js";
5
- function deepClone(obj) {
6
- return JSON.parse(JSON.stringify(obj));
7
- }
8
- function rootToString(root) {
9
- return JSON.stringify(root);
10
- }
11
- function hasSignerContext(root) {
12
- const str = rootToString(root);
13
- return str.includes('"Signer"') || str.includes('"context":"Signer"') || str.includes('"context": "Signer"');
14
- }
15
- function getSubmissionEntries(table) {
16
- return table.filter((e) => e.b_submission === true);
17
- }
18
- function inferValueType(value) {
19
- if (typeof value === "string") {
20
- if (value.startsWith("0x") && value.length >= 3)
21
- return "Address";
22
- return "String";
23
- }
24
- if (typeof value === "number") {
25
- if (Number.isInteger(value)) {
26
- if (value >= 0 && value <= 255)
27
- return "U8";
28
- if (value >= 0 && value <= 65535)
29
- return "U16";
30
- return "U64";
31
- }
32
- return "U256";
33
- }
34
- if (typeof value === "boolean")
35
- return "Bool";
36
- if (Array.isArray(value)) {
37
- if (value.length > 0) {
38
- const elemType = inferValueType(value[0]);
39
- if (elemType === "Address")
40
- return "Vec<Address>";
41
- if (elemType === "String")
42
- return "Vec<String>";
43
- if (elemType === "Bool")
44
- return "Vec<Bool>";
45
- }
46
- return "Vec<Address>";
47
- }
48
- return undefined;
49
- }
50
- function sdkIssueToDiagnostic(issue) {
51
- return {
52
- code: issue.code,
53
- message: issue.message,
54
- severity: issue.severity,
55
- source: "sdk",
56
- location: {
57
- path: issue.path,
58
- },
59
- fix: {
60
- description: `SDK validation failed (${issue.sdk_error ?? "InvalidParam"}); manual fix required`,
61
- auto_fixable: false,
62
- },
63
- };
64
- }
65
- async function checkSdkSyntax(json) {
66
- const tableForSdk = json.table.map((e) => ({
67
- identifier: e.identifier,
68
- b_submission: e.b_submission ?? false,
69
- value_type: (e.value_type ?? "Address"),
70
- value: e.value,
71
- name: e.name ?? "",
72
- }));
73
- const issues = await validateGuardData({
74
- description: json.description,
75
- table: tableForSdk,
76
- root: json.root,
77
- rely: json.rely,
78
- });
79
- return issues.map(sdkIssueToDiagnostic);
80
- }
81
- function checkSemanticErrors(json) {
82
- const diagnostics = [];
83
- const { table, root, binding_hint } = json;
84
- const scene = binding_hint ? findScene(binding_hint.host_object ?? "", binding_hint.binding_field ?? "") : undefined;
85
- const submissionEntries = getSubmissionEntries(table);
86
- if (submissionEntries.length > 0 && root && !hasSignerContext(root)) {
87
- const hasAddressSubmission = submissionEntries.some((e) => e.value_type === "Address");
88
- const isAllocatorsEntitySharing = scene?.id === "service_order_allocators_guard" &&
89
- binding_hint?.sharing_recipients !== undefined &&
90
- binding_hint.sharing_recipients.length > 0 &&
91
- !binding_hint.sharing_recipients.includes("Signer");
92
- if (hasAddressSubmission && !isAllocatorsEntitySharing) {
93
- const indices = submissionEntries
94
- .filter((e) => e.value_type === "Address")
95
- .map((e) => table.indexOf(e));
96
- diagnostics.push({
97
- code: "LE-04",
98
- message: "Submitted data has no Signer binding (submission forgery risk)",
99
- severity: "error",
100
- source: "lint",
101
- location: { path: indices.map((i) => `/table/${i}`).join(" → ") },
102
- fix: {
103
- description: "Add logic_equal(context(Signer), identifier[N]) in root to bind the submitter identity",
104
- auto_fixable: false,
105
- },
106
- });
107
- }
108
- }
109
- if (scene?.id === "arbitration_voting_guard") {
110
- const hasWeightSubmission = submissionEntries.some((e) => ["U8", "U16", "U32", "U64", "U128", "U256"].includes(e.value_type ?? ""));
111
- if (hasWeightSubmission) {
112
- const indices = submissionEntries
113
- .filter((e) => ["U8", "U16", "U32", "U64", "U128", "U256"].includes(e.value_type ?? ""))
114
- .map((e) => table.indexOf(e));
115
- diagnostics.push({
116
- code: "LE-05",
117
- message: "voting_guard voting weight comes from submitted data (weight forgery risk)",
118
- severity: "error",
119
- source: "lint",
120
- location: { path: indices.map((i) => `/table/${i}`).join(" → ") },
121
- fix: {
122
- description: "Derive arbitrator weights from the Arb object via witness (e.g. 105 TypeArbArbitration) rather than submitting them directly",
123
- auto_fixable: false,
124
- },
125
- });
126
- }
127
- }
128
- if (scene?.id === "gen_passport_guard" || binding_hint?.action === "gen_passport") {
129
- const rootStr = rootToString(root);
130
- if (rootStr.includes("1167") || rootStr.includes("repository.data")) {
131
- const hasQuoteGuard = rootStr.includes("quote_guard");
132
- if (hasQuoteGuard) {
133
- diagnostics.push({
134
- code: "LE-06",
135
- message: "repository.data query with quote_guard: rigid verification requirement — ensure Passport includes quote_guard verification with necessary submissions (e.g., Payment proof)",
136
- severity: "info",
137
- source: "lint",
138
- location: { path: "/root" },
139
- fix: {
140
- description: "Ensure the quote_guard is verified: user submits Payment via Passport, quote_guard verifies Payment fields, repository data query passes",
141
- auto_fixable: false,
142
- },
143
- });
144
- }
145
- }
146
- }
147
- if (binding_hint?.host_object && scene) {
148
- const hostType = binding_hint.host_object;
149
- const circularEntries = table.filter((e) => !e.b_submission && e.value_type === "Address" &&
150
- typeof e.value === "string" && e.value.startsWith("0x") &&
151
- e.object_type === hostType);
152
- if (circularEntries.length > 0) {
153
- const indices = circularEntries.map((e) => table.indexOf(e));
154
- diagnostics.push({
155
- code: "LE-07",
156
- message: `Circular reference uses an address rather than a name (Host Object may not be published yet when the Guard is created)`,
157
- severity: "error",
158
- source: "lint",
159
- location: { path: indices.map((i) => `/table/${i}/value`).join(" → ") },
160
- fix: {
161
- description: `Change value from an address to an object name (e.g. "service1"); the SDK will resolve it to an address after the Host Object is published`,
162
- auto_fixable: false,
163
- },
164
- });
165
- }
166
- }
167
- return diagnostics;
168
- }
169
- function checkSyntaxHints(json) {
170
- const diagnostics = [];
171
- const { table } = json;
172
- if (!json.description || json.description.trim() === "") {
173
- diagnostics.push({
174
- code: "SH-01",
175
- message: "description is missing or empty",
176
- severity: "info",
177
- source: "lint",
178
- location: { path: "/description" },
179
- fix: {
180
- description: "Add a description, e.g. 'Service buy_guard: whitelist validation'",
181
- auto_fixable: true,
182
- },
183
- });
184
- }
185
- for (let i = 0; i < table.length; i++) {
186
- const entry = table[i];
187
- if (!entry.name || entry.name.trim() === "") {
188
- diagnostics.push({
189
- code: "SH-03",
190
- message: `table[${i}] is missing name`,
191
- severity: "warning",
192
- source: "lint",
193
- location: { path: `/table/${i}/name` },
194
- fix: {
195
- description: `Add a name, e.g. "data entry ${entry.identifier}"`,
196
- auto_fixable: true,
197
- },
198
- });
199
- }
200
- }
201
- for (let i = 0; i < table.length; i++) {
202
- const entry = table[i];
203
- if (!entry.value_type) {
204
- diagnostics.push({
205
- code: "SH-05",
206
- message: `table[${i}] is missing value_type`,
207
- severity: "warning",
208
- source: "lint",
209
- location: { path: `/table/${i}/value_type` },
210
- fix: {
211
- description: "Infer value_type from value (e.g. Address/String/U64, etc.)",
212
- auto_fixable: true,
213
- },
214
- });
215
- }
216
- }
217
- if (table.length > MAX_TABLE_SIZE) {
218
- diagnostics.push({
219
- code: "SH-07",
220
- message: `table entry count ${table.length} exceeds the maximum limit ${MAX_TABLE_SIZE}`,
221
- severity: "error",
222
- source: "lint",
223
- location: { path: "/table" },
224
- fix: {
225
- description: "Slim down the table by merging similar entries, or split into multiple Guards + rely",
226
- auto_fixable: false,
227
- },
228
- });
229
- }
230
- for (let i = 0; i < table.length; i++) {
231
- if (table[i].b_submission === undefined) {
232
- diagnostics.push({
233
- code: "SH-10",
234
- message: `table[${i}] b_submission is missing`,
235
- severity: "info",
236
- source: "lint",
237
- location: { path: `/table/${i}/b_submission` },
238
- fix: {
239
- description: "Set to false (constant) or true (submitted data)",
240
- auto_fixable: true,
241
- },
242
- });
243
- }
244
- }
245
- for (let i = 0; i < table.length; i++) {
246
- const entry = table[i];
247
- if (entry.b_submission === true && entry.value !== undefined && entry.value !== null) {
248
- diagnostics.push({
249
- code: "SH-11",
250
- message: `table[${i}] has a redundant value field on b_submission=true entry (the verifier supplies the value at runtime; this value is ignored by BCS encoding and wastes gas)`,
251
- severity: "warning",
252
- source: "lint",
253
- location: { path: `/table/${i}/value` },
254
- fix: {
255
- description: "Remove the value field — it is ignored for b_submission=true entries",
256
- auto_fixable: true,
257
- },
258
- });
259
- }
260
- }
261
- return diagnostics;
262
- }
263
- function checkSuggestions(json) {
264
- const diagnostics = [];
265
- const { root, binding_hint, table } = json;
266
- if (root) {
267
- const rootStr = rootToString(root);
268
- if (rootStr.includes("vec_contains_address") && rootStr.includes("Signer")) {
269
- diagnostics.push({
270
- code: "SG-01",
271
- message: "Matches Pattern P04 (whitelist validation)",
272
- severity: "hint",
273
- source: "lint",
274
- location: { path: "/root" },
275
- fix: { description: "Refer to the P04 Pattern to ensure best practices", auto_fixable: false },
276
- });
277
- }
278
- else if (rootStr.includes("logic_equal") && rootStr.includes("Signer")) {
279
- const hasAddressConst = table.some((e) => !e.b_submission && e.value_type === "Address" && typeof e.value === "string" && e.value.length > 0);
280
- if (hasAddressConst) {
281
- diagnostics.push({
282
- code: "SG-01",
283
- message: "Matches Pattern P04 (whitelist validation — single-address variant)",
284
- severity: "hint",
285
- source: "lint",
286
- location: { path: "/root" },
287
- fix: { description: "P04 single-address form; for multi-address scenarios, consider vec_contains_address", auto_fixable: false },
288
- });
289
- }
290
- }
291
- if (rootStr.includes("logic_as_u256_greater") ||
292
- rootStr.includes("logic_as_u256_lesser")) {
293
- diagnostics.push({
294
- code: "SG-01",
295
- message: "Matches Pattern P02 (numeric threshold validation)",
296
- severity: "hint",
297
- source: "lint",
298
- location: { path: "/root" },
299
- fix: { description: "Suitable for amount/quantity threshold validation scenarios", auto_fixable: false },
300
- });
301
- }
302
- if (rootStr.includes("convert_witness")) {
303
- diagnostics.push({
304
- code: "SG-01",
305
- message: "Matches Pattern P09 (witness-derived validation)",
306
- severity: "hint",
307
- source: "lint",
308
- location: { path: "/root" },
309
- fix: { description: "Suitable for cross-object relationship validation (e.g. Order→Progress)", auto_fixable: false },
310
- });
311
- }
312
- }
313
- if (binding_hint?.action) {
314
- const validActions = ["buy", "forward", "allocate", "claim_reward", "vote", "dispute", "write_repository", "submit_progress", "gen_passport"];
315
- if (validActions.includes(binding_hint.action)) {
316
- const scene = inferSceneFromAction(binding_hint.action);
317
- if (scene) {
318
- const template = suggestTemplateForScene(scene.id);
319
- if (template) {
320
- diagnostics.push({
321
- code: "SG-02",
322
- message: `Recommended scene template: ${template.name}`,
323
- severity: "hint",
324
- source: "lint",
325
- location: { path: "/" },
326
- fix: { description: `Refer to template ${template.id} (${template.example_use_case})`, auto_fixable: false },
327
- });
328
- }
329
- }
330
- }
331
- }
332
- const submissionEntries = getSubmissionEntries(table);
333
- for (const entry of submissionEntries) {
334
- const name = entry.name ?? "";
335
- if (name.length < 10 || /^[a-z_]+$/i.test(name)) {
336
- const idx = table.indexOf(entry);
337
- diagnostics.push({
338
- code: "SG-03",
339
- message: `table[${idx}] submitted data has a vague name description`,
340
- severity: "info",
341
- source: "lint",
342
- location: { path: `/table/${idx}/name` },
343
- fix: { description: "Use a full natural-language description (≥10 characters), e.g. 'user-submitted operation type (return/damage)'", auto_fixable: false },
344
- });
345
- }
346
- }
347
- if (root) {
348
- const rootStr = rootToString(root);
349
- const hasProofSigner = rootStr.includes("proof.signer");
350
- const hasProofTime = rootStr.includes("proof.time");
351
- const hasStringLength = rootStr.includes("calc_string_length");
352
- const hasStringSubmission = submissionEntries.some((e) => e.value_type === "String");
353
- if (hasProofSigner && hasProofTime) {
354
- diagnostics.push({
355
- code: "SG-04",
356
- message: "Strict-mode privacy-delivery guard detected (proof.signer + proof.time). " +
357
- "Recommended three conditions: Signer==proof.signer (submitter accountability), " +
358
- "proof.time>order.time (freshness), order.service==service (project binding). " +
359
- "No content verification — only submission responsibility ('whoever benefits bears the burden of proof').",
360
- severity: "info",
361
- source: "lint",
362
- location: { path: "/root" },
363
- fix: {
364
- description: "Ensure all three conditions are present (logic_and). Refer to template tpl_forward_privacy_delivery_proof. " +
365
- "Query IDs: proof.signer=1958, proof.time=1960, order.time=1574, order.service=1563.",
366
- auto_fixable: false,
367
- },
368
- });
369
- }
370
- else if (hasStringLength && hasStringSubmission) {
371
- diagnostics.push({
372
- code: "SG-04",
373
- message: "Broad-mode privacy-delivery guard detected (String submission + length check, e.g. Merkle Root length == 66). " +
374
- "This trusts the submitter's honesty; the counterparty can dispute by checking their own Messenger conversation. " +
375
- "Suitable as an arbitration basis, not a fund-flow gate.",
376
- severity: "info",
377
- source: "lint",
378
- location: { path: "/root" },
379
- fix: {
380
- description: "For stronger assurance, consider strict mode: submit a Proof object address (from messenger.submitChainProof) + " +
381
- "Order address, then verify proof.signer/proof.time/order.service. See template tpl_forward_privacy_delivery_proof.",
382
- auto_fixable: false,
383
- },
384
- });
385
- }
386
- }
387
- return diagnostics;
388
- }
389
- export function autoFixGuard(json) {
390
- const fixed = deepClone(json);
391
- const actions = [];
392
- if (!fixed.description || fixed.description.trim() === "") {
393
- fixed.description = `Guard (table: ${fixed.table.length} items, root: ${fixed.root?.type ?? "unknown"})`;
394
- actions.push({
395
- diagnostic_code: "SH-01",
396
- description: "Fill in default description",
397
- after: fixed.description,
398
- path: "/description",
399
- });
400
- }
401
- if (fixed.description && fixed.description.length > MAX_DESCRIPTION_LENGTH) {
402
- const before = fixed.description;
403
- fixed.description = fixed.description.substring(0, MAX_DESCRIPTION_LENGTH);
404
- actions.push({
405
- diagnostic_code: "G-001",
406
- description: `Truncate description to ${MAX_DESCRIPTION_LENGTH} characters`,
407
- before: `${before.length} characters`,
408
- after: `${fixed.description.length} characters`,
409
- path: "/description",
410
- });
411
- }
412
- for (let i = 0; i < fixed.table.length; i++) {
413
- const entry = fixed.table[i];
414
- if (!entry.name || entry.name.trim() === "") {
415
- entry.name = `data entry ${entry.identifier}`;
416
- actions.push({
417
- diagnostic_code: "SH-03",
418
- description: `table[${i}] fill in name`,
419
- after: entry.name,
420
- path: `/table/${i}/name`,
421
- });
422
- }
423
- }
424
- for (let i = 0; i < fixed.table.length; i++) {
425
- const entry = fixed.table[i];
426
- if (!entry.value_type && entry.value !== undefined && entry.value !== null) {
427
- const inferred = inferValueType(entry.value);
428
- if (inferred) {
429
- entry.value_type = inferred;
430
- actions.push({
431
- diagnostic_code: "SH-05",
432
- description: `table[${i}] infer value_type`,
433
- after: inferred,
434
- path: `/table/${i}/value_type`,
435
- });
436
- }
437
- }
438
- }
439
- const idMap = new Map();
440
- let nextId = 0;
441
- for (let i = 0; i < fixed.table.length; i++) {
442
- const entry = fixed.table[i];
443
- if (!idMap.has(entry.identifier)) {
444
- idMap.set(entry.identifier, nextId);
445
- if (entry.identifier !== nextId) {
446
- actions.push({
447
- diagnostic_code: "G-007",
448
- description: `table[${i}] identifier ${entry.identifier} → ${nextId}`,
449
- before: String(entry.identifier),
450
- after: String(nextId),
451
- path: `/table/${i}/identifier`,
452
- });
453
- }
454
- entry.identifier = nextId;
455
- nextId++;
456
- }
457
- else {
458
- const oldId = entry.identifier;
459
- entry.identifier = nextId;
460
- idMap.set(oldId, nextId);
461
- actions.push({
462
- diagnostic_code: "G-007",
463
- description: `table[${i}] identifier ${oldId} duplicate → reallocated to ${nextId}`,
464
- before: String(oldId),
465
- after: String(nextId),
466
- path: `/table/${i}/identifier`,
467
- });
468
- nextId++;
469
- }
470
- }
471
- for (let i = 0; i < fixed.table.length; i++) {
472
- const entry = fixed.table[i];
473
- if (entry.b_submission === undefined) {
474
- entry.b_submission = false;
475
- actions.push({
476
- diagnostic_code: "SH-10",
477
- description: `table[${i}] b_submission default set to false`,
478
- after: "false",
479
- path: `/table/${i}/b_submission`,
480
- });
481
- }
482
- }
483
- if (fixed.rely?.guards && fixed.rely.guards.length > 0) {
484
- const unique = [...new Set(fixed.rely.guards)];
485
- if (unique.length !== fixed.rely.guards.length) {
486
- actions.push({
487
- diagnostic_code: "G-009",
488
- description: `rely deduplicate: ${fixed.rely.guards.length} → ${unique.length}`,
489
- before: JSON.stringify(fixed.rely.guards),
490
- after: JSON.stringify(unique),
491
- path: "/rely/guards",
492
- });
493
- fixed.rely.guards = unique;
494
- }
495
- }
496
- for (let i = 0; i < fixed.table.length; i++) {
497
- const entry = fixed.table[i];
498
- if (entry.b_submission === true && entry.value !== undefined && entry.value !== null) {
499
- const before = JSON.stringify(entry.value);
500
- delete entry.value;
501
- actions.push({
502
- diagnostic_code: "SH-11",
503
- description: `table[${i}] remove redundant value on b_submission=true entry`,
504
- before,
505
- after: "(removed)",
506
- path: `/table/${i}/value`,
507
- });
508
- }
509
- }
510
- return { fixed, actions };
511
- }
512
- export async function lintGuard(json, options) {
513
- const doAutoFix = options?.auto_fix ?? true;
514
- const { table, root, rely, binding_hint } = json;
515
- const diagnostics = [];
516
- let risk_assessment;
517
- const sdkDiagnostics = await checkSdkSyntax(json);
518
- diagnostics.push(...sdkDiagnostics);
519
- const semanticDiagnostics = checkSemanticErrors(json);
520
- diagnostics.push(...semanticDiagnostics);
521
- const hintDiagnostics = checkSyntaxHints(json);
522
- diagnostics.push(...hintDiagnostics);
523
- let fixed_json;
524
- let fix_actions = [];
525
- if (doAutoFix) {
526
- const { fixed, actions } = autoFixGuard(json);
527
- if (actions.length > 0) {
528
- fixed_json = fixed;
529
- fix_actions = actions;
530
- }
531
- }
532
- if (table.length > 0 && root) {
533
- const scene = binding_hint
534
- ? findScene(binding_hint.host_object ?? "", binding_hint.binding_field ?? "")
535
- : undefined;
536
- const mappedTable = table.map((e) => ({
537
- identifier: e.identifier,
538
- b_submission: e.b_submission ?? false,
539
- value_type: e.value_type ?? "Address",
540
- value: e.value,
541
- name: e.name,
542
- object_type: e.object_type,
543
- }));
544
- risk_assessment = assessGuardRisks({
545
- table: mappedTable,
546
- root,
547
- rely,
548
- scene,
549
- sharing_recipients: binding_hint?.sharing_recipients,
550
- });
551
- for (const r of risk_assessment.risks) {
552
- const severity = r.level === "critical" || r.level === "high" ? "error" :
553
- r.level === "medium" ? "warning" :
554
- r.level === "low" ? "info" : "hint";
555
- const rawEvidence = r.evidence ?? "";
556
- const path = rawEvidence.startsWith("/") ? rawEvidence : "/";
557
- diagnostics.push({
558
- code: r.id,
559
- message: `[${r.level}] ${r.title}`,
560
- severity,
561
- source: "risk",
562
- location: { path },
563
- fix: {
564
- description: r.mitigation,
565
- auto_fixable: false,
566
- },
567
- });
568
- }
569
- }
570
- const suggestionDiagnostics = checkSuggestions(json);
571
- diagnostics.push(...suggestionDiagnostics);
572
- const errors = diagnostics.filter((d) => d.severity === "error").length;
573
- const warnings = diagnostics.filter((d) => d.severity === "warning").length;
574
- const infos = diagnostics.filter((d) => d.severity === "info" || d.severity === "hint").length;
575
- const ready = errors === 0;
576
- let next_step;
577
- if (errors > 0) {
578
- next_step = `Fix ${errors} error(s) and re-run lint`;
579
- }
580
- else if (warnings > 0) {
581
- next_step = `Consider addressing ${warnings} warning(s), then submit to SDK newGuard() for final syntax validation`;
582
- }
583
- else {
584
- next_step = "lint passed (no errors); submit to SDK newGuard() for final syntax validation before going on-chain";
585
- }
586
- return {
587
- json_summary: {
588
- table_count: table.length,
589
- root_type: root?.type ?? "unknown",
590
- has_rely: !!rely?.guards?.length,
591
- rely_count: rely?.guards?.length ?? 0,
592
- has_description: !!json.description,
593
- },
594
- diagnostics,
595
- fixed_json,
596
- fix_actions,
597
- risk_assessment,
598
- summary: {
599
- errors,
600
- warnings,
601
- infos,
602
- auto_fixes_applied: fix_actions.length,
603
- ready,
604
- next_step,
605
- },
606
- };
607
- }
608
- export async function isGuardReady(json) {
609
- const result = await lintGuard(json, { auto_fix: false });
610
- return result.summary.ready;
611
- }
612
- export async function getGuardErrors(json) {
613
- const result = await lintGuard(json, { auto_fix: false });
614
- return result.diagnostics.filter((d) => d.severity === "error");
615
- }
616
- export function formatLintResult(result) {
617
- const lines = [];
618
- lines.push("=== Guard JSON Lint Report ===");
619
- lines.push("");
620
- lines.push("Summary:");
621
- lines.push(` Errors: ${result.summary.errors}`);
622
- lines.push(` Warnings: ${result.summary.warnings}`);
623
- lines.push(` Infos: ${result.summary.infos}`);
624
- lines.push(` Auto-fixes: ${result.summary.auto_fixes_applied}`);
625
- lines.push(` Ready: ${result.summary.ready ? "YES" : "NO"}`);
626
- lines.push(` Next step: ${result.summary.next_step}`);
627
- lines.push("");
628
- if (result.fix_actions.length > 0) {
629
- lines.push("--- Auto-fix Actions ---");
630
- for (const action of result.fix_actions) {
631
- lines.push(` [${action.diagnostic_code}] ${action.description}`);
632
- lines.push(` Path: ${action.path}`);
633
- if (action.before && action.after) {
634
- lines.push(` ${action.before} -> ${action.after}`);
635
- }
636
- }
637
- lines.push("");
638
- }
639
- const errors = result.diagnostics.filter((d) => d.severity === "error");
640
- const warnings = result.diagnostics.filter((d) => d.severity === "warning");
641
- const infos = result.diagnostics.filter((d) => d.severity === "info" || d.severity === "hint");
642
- if (errors.length > 0) {
643
- lines.push("--- Errors (must fix) ---");
644
- for (const d of errors) {
645
- lines.push(` [${d.code}] (${d.source}) ${d.message}`);
646
- lines.push(` Path: ${d.location.path}`);
647
- if (d.fix)
648
- lines.push(` Fix: ${d.fix.description}`);
649
- }
650
- lines.push("");
651
- }
652
- if (warnings.length > 0) {
653
- lines.push("--- Warnings (consider fixing) ---");
654
- for (const d of warnings) {
655
- lines.push(` [${d.code}] (${d.source}) ${d.message}`);
656
- lines.push(` Path: ${d.location.path}`);
657
- if (d.fix)
658
- lines.push(` Fix: ${d.fix.description}`);
659
- }
660
- lines.push("");
661
- }
662
- if (infos.length > 0) {
663
- lines.push("--- Info & Hints ---");
664
- for (const d of infos) {
665
- lines.push(` [${d.code}] (${d.source}) ${d.message}`);
666
- lines.push(` Path: ${d.location.path}`);
667
- }
668
- }
669
- return lines.join("\n");
670
- }
1
+ import{validateGuardData,MAX_DESCRIPTION_LENGTH,MAX_TABLE_SIZE}from'@wowok/wowok';import{assessGuardRisks}from'./guard-risk.js';import{findScene,inferSceneFromAction}from'./guard-ledger.js';import{suggestTemplateForScene}from'./guard-templates.js';function deepClone(a){return JSON['parse'](JSON['stringify'](a));}function rootToString(a){return JSON['stringify'](a);}function hasSignerContext(a){const b=rootToString(a);return b['includes']('\x22Signer\x22')||b['includes']('\x22context\x22:\x22Signer\x22')||b['includes']('\x22context\x22:\x20\x22Signer\x22');}function getSubmissionEntries(a){return a['filter'](b=>b['b_submission']===!![]);}function inferValueType(a){if(typeof a==='string'){if(a['startsWith']('0x')&&a['length']>=0x3)return'Address';return'String';}if(typeof a==='number'){if(Number['isInteger'](a)){if(a>=0x0&&a<=0xff)return'U8';if(a>=0x0&&a<=0xffff)return'U16';return'U64';}return'U256';}if(typeof a==='boolean')return'Bool';if(Array['isArray'](a)){if(a['length']>0x0){const b=inferValueType(a[0x0]);if(b==='Address')return'Vec<Address>';if(b==='String')return'Vec<String>';if(b==='Bool')return'Vec<Bool>';}return'Vec<Address>';}return undefined;}function sdkIssueToDiagnostic(a){return{'code':a['code'],'message':a['message'],'severity':a['severity'],'source':'sdk','location':{'path':a['path']},'fix':{'description':'SDK\x20validation\x20failed\x20('+(a['sdk_error']??'InvalidParam')+');\x20manual\x20fix\x20required','auto_fixable':![]}};}async function checkSdkSyntax(a){const b=a['table']['map'](d=>({'identifier':d['identifier'],'b_submission':d['b_submission']??![],'value_type':d['value_type']??'Address','value':d['value'],'name':d['name']??''})),c=await validateGuardData({'description':a['description'],'table':b,'root':a['root'],'rely':a['rely']});return c['map'](sdkIssueToDiagnostic);}function checkSemanticErrors(a){const b=[],{table:c,root:d,binding_hint:e}=a,f=e?findScene(e['host_object']??'',e['binding_field']??''):undefined,g=getSubmissionEntries(c);if(g['length']>0x0&&d&&!hasSignerContext(d)){const h=g['some'](j=>j['value_type']==='Address'),i=f?.['id']==='service_order_allocators_guard'&&e?.['sharing_recipients']!==undefined&&e['sharing_recipients']['length']>0x0&&!e['sharing_recipients']['includes']('Signer');if(h&&!i){const j=g['filter'](k=>k['value_type']==='Address')['map'](k=>c['indexOf'](k));b['push']({'code':'LE-04','message':'Submitted\x20data\x20has\x20no\x20Signer\x20binding\x20(submission\x20forgery\x20risk)','severity':'error','source':'lint','location':{'path':j['map'](k=>'/table/'+k)['join']('\x20→\x20')},'fix':{'description':'Add\x20logic_equal(context(Signer),\x20identifier[N])\x20in\x20root\x20to\x20bind\x20the\x20submitter\x20identity','auto_fixable':![]}});}}if(f?.['id']==='arbitration_voting_guard'){const k=g['some'](l=>['U8','U16','U32','U64','U128','U256']['includes'](l['value_type']??''));if(k){const l=g['filter'](m=>['U8','U16','U32','U64','U128','U256']['includes'](m['value_type']??''))['map'](m=>c['indexOf'](m));b['push']({'code':'LE-05','message':'voting_guard\x20voting\x20weight\x20comes\x20from\x20submitted\x20data\x20(weight\x20forgery\x20risk)','severity':'error','source':'lint','location':{'path':l['map'](m=>'/table/'+m)['join']('\x20→\x20')},'fix':{'description':'Derive\x20arbitrator\x20weights\x20from\x20the\x20Arb\x20object\x20via\x20witness\x20(e.g.\x20105\x20TypeArbArbitration)\x20rather\x20than\x20submitting\x20them\x20directly','auto_fixable':![]}});}}if(f?.['id']==='gen_passport_guard'||e?.['action']==='gen_passport'){const m=rootToString(d);if(m['includes']('1167')||m['includes']('repository.data')){const n=m['includes']('quote_guard');n&&b['push']({'code':'LE-06','message':'repository.data\x20query\x20with\x20quote_guard:\x20rigid\x20verification\x20requirement\x20—\x20ensure\x20Passport\x20includes\x20quote_guard\x20verification\x20with\x20necessary\x20submissions\x20(e.g.,\x20Payment\x20proof)','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'Ensure\x20the\x20quote_guard\x20is\x20verified:\x20user\x20submits\x20Payment\x20via\x20Passport,\x20quote_guard\x20verifies\x20Payment\x20fields,\x20repository\x20data\x20query\x20passes','auto_fixable':![]}});}}if(e?.['host_object']&&f){const o=e['host_object'],p=c['filter'](q=>!q['b_submission']&&q['value_type']==='Address'&&typeof q['value']==='string'&&q['value']['startsWith']('0x')&&q['object_type']===o);if(p['length']>0x0){const q=p['map'](r=>c['indexOf'](r));b['push']({'code':'LE-07','message':'Circular\x20reference\x20uses\x20an\x20address\x20rather\x20than\x20a\x20name\x20(Host\x20Object\x20may\x20not\x20be\x20published\x20yet\x20when\x20the\x20Guard\x20is\x20created)','severity':'error','source':'lint','location':{'path':q['map'](r=>'/table/'+r+'/value')['join']('\x20→\x20')},'fix':{'description':'Change\x20value\x20from\x20an\x20address\x20to\x20an\x20object\x20name\x20(e.g.\x20\x22service1\x22);\x20the\x20SDK\x20will\x20resolve\x20it\x20to\x20an\x20address\x20after\x20the\x20Host\x20Object\x20is\x20published','auto_fixable':![]}});}}return b;}function checkSyntaxHints(a){const b=[],{table:c}=a;(!a['description']||a['description']['trim']()==='')&&b['push']({'code':'SH-01','message':'description\x20is\x20missing\x20or\x20empty','severity':'info','source':'lint','location':{'path':'/description'},'fix':{'description':'Add\x20a\x20description,\x20e.g.\x20\x27Service\x20buy_guard:\x20whitelist\x20validation\x27','auto_fixable':!![]}});for(let d=0x0;d<c['length'];d++){const e=c[d];(!e['name']||e['name']['trim']()==='')&&b['push']({'code':'SH-03','message':'table['+d+']\x20is\x20missing\x20name','severity':'warning','source':'lint','location':{'path':'/table/'+d+'/name'},'fix':{'description':'Add\x20a\x20name,\x20e.g.\x20\x22data\x20entry\x20'+e['identifier']+'\x22','auto_fixable':!![]}});}for(let f=0x0;f<c['length'];f++){const g=c[f];!g['value_type']&&b['push']({'code':'SH-05','message':'table['+f+']\x20is\x20missing\x20value_type','severity':'warning','source':'lint','location':{'path':'/table/'+f+'/value_type'},'fix':{'description':'Infer\x20value_type\x20from\x20value\x20(e.g.\x20Address/String/U64,\x20etc.)','auto_fixable':!![]}});}c['length']>MAX_TABLE_SIZE&&b['push']({'code':'SH-07','message':'table\x20entry\x20count\x20'+c['length']+'\x20exceeds\x20the\x20maximum\x20limit\x20'+MAX_TABLE_SIZE,'severity':'error','source':'lint','location':{'path':'/table'},'fix':{'description':'Slim\x20down\x20the\x20table\x20by\x20merging\x20similar\x20entries,\x20or\x20split\x20into\x20multiple\x20Guards\x20+\x20rely','auto_fixable':![]}});for(let h=0x0;h<c['length'];h++){c[h]['b_submission']===undefined&&b['push']({'code':'SH-10','message':'table['+h+']\x20b_submission\x20is\x20missing','severity':'info','source':'lint','location':{'path':'/table/'+h+'/b_submission'},'fix':{'description':'Set\x20to\x20false\x20(constant)\x20or\x20true\x20(submitted\x20data)','auto_fixable':!![]}});}for(let j=0x0;j<c['length'];j++){const k=c[j];k['b_submission']===!![]&&k['value']!==undefined&&k['value']!==null&&b['push']({'code':'SH-11','message':'table['+j+']\x20has\x20a\x20redundant\x20value\x20field\x20on\x20b_submission=true\x20entry\x20(the\x20verifier\x20supplies\x20the\x20value\x20at\x20runtime;\x20this\x20value\x20is\x20ignored\x20by\x20BCS\x20encoding\x20and\x20wastes\x20gas)','severity':'warning','source':'lint','location':{'path':'/table/'+j+'/value'},'fix':{'description':'Remove\x20the\x20value\x20field\x20—\x20it\x20is\x20ignored\x20for\x20b_submission=true\x20entries','auto_fixable':!![]}});}return b;}function checkSuggestions(a){const b=[],{root:c,binding_hint:d,table:e}=a;if(c){const g=rootToString(c);if(g['includes']('vec_contains_address')&&g['includes']('Signer'))b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P04\x20(whitelist\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Refer\x20to\x20the\x20P04\x20Pattern\x20to\x20ensure\x20best\x20practices','auto_fixable':![]}});else{if(g['includes']('logic_equal')&&g['includes']('Signer')){const h=e['some'](i=>!i['b_submission']&&i['value_type']==='Address'&&typeof i['value']==='string'&&i['value']['length']>0x0);h&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P04\x20(whitelist\x20validation\x20—\x20single-address\x20variant)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'P04\x20single-address\x20form;\x20for\x20multi-address\x20scenarios,\x20consider\x20vec_contains_address','auto_fixable':![]}});}}(g['includes']('logic_as_u256_greater')||g['includes']('logic_as_u256_lesser'))&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P02\x20(numeric\x20threshold\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Suitable\x20for\x20amount/quantity\x20threshold\x20validation\x20scenarios','auto_fixable':![]}}),g['includes']('convert_witness')&&b['push']({'code':'SG-01','message':'Matches\x20Pattern\x20P09\x20(witness-derived\x20validation)','severity':'hint','source':'lint','location':{'path':'/root'},'fix':{'description':'Suitable\x20for\x20cross-object\x20relationship\x20validation\x20(e.g.\x20Order→Progress)','auto_fixable':![]}});}if(d?.['action']){const i=['buy','forward','allocate','claim_reward','vote','dispute','write_repository','submit_progress','gen_passport'];if(i['includes'](d['action'])){const j=inferSceneFromAction(d['action']);if(j){const k=suggestTemplateForScene(j['id']);k&&b['push']({'code':'SG-02','message':'Recommended\x20scene\x20template:\x20'+k['name'],'severity':'hint','source':'lint','location':{'path':'/'},'fix':{'description':'Refer\x20to\x20template\x20'+k['id']+'\x20('+k['example_use_case']+')','auto_fixable':![]}});}}}const f=getSubmissionEntries(e);for(const l of f){const m=l['name']??'';if(m['length']<0xa||/^[a-z_]+$/i['test'](m)){const n=e['indexOf'](l);b['push']({'code':'SG-03','message':'table['+n+']\x20submitted\x20data\x20has\x20a\x20vague\x20name\x20description','severity':'info','source':'lint','location':{'path':'/table/'+n+'/name'},'fix':{'description':'Use\x20a\x20full\x20natural-language\x20description\x20(≥10\x20characters),\x20e.g.\x20\x27user-submitted\x20operation\x20type\x20(return/damage)\x27','auto_fixable':![]}});}}if(c){const o=rootToString(c),p=o['includes']('proof.signer'),q=o['includes']('proof.time'),r=o['includes']('calc_string_length'),s=f['some'](t=>t['value_type']==='String');if(p&&q)b['push']({'code':'SG-04','message':'Strict-mode\x20privacy-delivery\x20guard\x20detected\x20(proof.signer\x20+\x20proof.time).\x20'+'Recommended\x20three\x20conditions:\x20Signer==proof.signer\x20(submitter\x20accountability),\x20'+'proof.time>order.time\x20(freshness),\x20order.service==service\x20(project\x20binding).\x20'+'No\x20content\x20verification\x20—\x20only\x20submission\x20responsibility\x20(\x27whoever\x20benefits\x20bears\x20the\x20burden\x20of\x20proof\x27).','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'Ensure\x20all\x20three\x20conditions\x20are\x20present\x20(logic_and).\x20Refer\x20to\x20template\x20tpl_forward_privacy_delivery_proof.\x20'+'Query\x20IDs:\x20proof.signer=1958,\x20proof.time=1960,\x20order.time=1574,\x20order.service=1563.','auto_fixable':![]}});else r&&s&&b['push']({'code':'SG-04','message':'Broad-mode\x20privacy-delivery\x20guard\x20detected\x20(String\x20submission\x20+\x20length\x20check,\x20e.g.\x20Merkle\x20Root\x20length\x20==\x2066).\x20'+'This\x20trusts\x20the\x20submitter\x27s\x20honesty;\x20the\x20counterparty\x20can\x20dispute\x20by\x20checking\x20their\x20own\x20Messenger\x20conversation.\x20'+'Suitable\x20as\x20an\x20arbitration\x20basis,\x20not\x20a\x20fund-flow\x20gate.','severity':'info','source':'lint','location':{'path':'/root'},'fix':{'description':'For\x20stronger\x20assurance,\x20consider\x20strict\x20mode:\x20submit\x20a\x20Proof\x20object\x20address\x20(from\x20messenger.submitChainProof)\x20+\x20'+'Order\x20address,\x20then\x20verify\x20proof.signer/proof.time/order.service.\x20See\x20template\x20tpl_forward_privacy_delivery_proof.','auto_fixable':![]}});}return b;}export function autoFixGuard(a){const b=deepClone(a),c=[];(!b['description']||b['description']['trim']()==='')&&(b['description']='Guard\x20(table:\x20'+b['table']['length']+'\x20items,\x20root:\x20'+(b['root']?.['type']??'unknown')+')',c['push']({'diagnostic_code':'SH-01','description':'Fill\x20in\x20default\x20description','after':b['description'],'path':'/description'}));if(b['description']&&b['description']['length']>MAX_DESCRIPTION_LENGTH){const f=b['description'];b['description']=b['description']['substring'](0x0,MAX_DESCRIPTION_LENGTH),c['push']({'diagnostic_code':'G-001','description':'Truncate\x20description\x20to\x20'+MAX_DESCRIPTION_LENGTH+'\x20characters','before':f['length']+'\x20characters','after':b['description']['length']+'\x20characters','path':'/description'});}for(let g=0x0;g<b['table']['length'];g++){const h=b['table'][g];(!h['name']||h['name']['trim']()==='')&&(h['name']='data\x20entry\x20'+h['identifier'],c['push']({'diagnostic_code':'SH-03','description':'table['+g+']\x20fill\x20in\x20name','after':h['name'],'path':'/table/'+g+'/name'}));}for(let j=0x0;j<b['table']['length'];j++){const k=b['table'][j];if(!k['value_type']&&k['value']!==undefined&&k['value']!==null){const l=inferValueType(k['value']);l&&(k['value_type']=l,c['push']({'diagnostic_code':'SH-05','description':'table['+j+']\x20infer\x20value_type','after':l,'path':'/table/'+j+'/value_type'}));}}const d=new Map();let e=0x0;for(let m=0x0;m<b['table']['length'];m++){const n=b['table'][m];if(!d['has'](n['identifier']))d['set'](n['identifier'],e),n['identifier']!==e&&c['push']({'diagnostic_code':'G-007','description':'table['+m+']\x20identifier\x20'+n['identifier']+'\x20→\x20'+e,'before':String(n['identifier']),'after':String(e),'path':'/table/'+m+'/identifier'}),n['identifier']=e,e++;else{const o=n['identifier'];n['identifier']=e,d['set'](o,e),c['push']({'diagnostic_code':'G-007','description':'table['+m+']\x20identifier\x20'+o+'\x20duplicate\x20→\x20reallocated\x20to\x20'+e,'before':String(o),'after':String(e),'path':'/table/'+m+'/identifier'}),e++;}}for(let p=0x0;p<b['table']['length'];p++){const q=b['table'][p];q['b_submission']===undefined&&(q['b_submission']=![],c['push']({'diagnostic_code':'SH-10','description':'table['+p+']\x20b_submission\x20default\x20set\x20to\x20false','after':'false','path':'/table/'+p+'/b_submission'}));}if(b['rely']?.['guards']&&b['rely']['guards']['length']>0x0){const r=[...new Set(b['rely']['guards'])];r['length']!==b['rely']['guards']['length']&&(c['push']({'diagnostic_code':'G-009','description':'rely\x20deduplicate:\x20'+b['rely']['guards']['length']+'\x20→\x20'+r['length'],'before':JSON['stringify'](b['rely']['guards']),'after':JSON['stringify'](r),'path':'/rely/guards'}),b['rely']['guards']=r);}for(let s=0x0;s<b['table']['length'];s++){const t=b['table'][s];if(t['b_submission']===!![]&&t['value']!==undefined&&t['value']!==null){const u=JSON['stringify'](t['value']);delete t['value'],c['push']({'diagnostic_code':'SH-11','description':'table['+s+']\x20remove\x20redundant\x20value\x20on\x20b_submission=true\x20entry','before':u,'after':'(removed)','path':'/table/'+s+'/value'});}}return{'fixed':b,'actions':c};}export async function lintGuard(a,b){const c=b?.['auto_fix']??!![],{table:d,root:e,rely:f,binding_hint:g}=a,h=[];let i;const j=await checkSdkSyntax(a);h['push'](...j);const k=checkSemanticErrors(a);h['push'](...k);const l=checkSyntaxHints(a);h['push'](...l);let m,n=[];if(c){const {fixed:v,actions:w}=autoFixGuard(a);w['length']>0x0&&(m=v,n=w);}if(d['length']>0x0&&e){const x=g?findScene(g['host_object']??'',g['binding_field']??''):undefined,y=d['map'](z=>({'identifier':z['identifier'],'b_submission':z['b_submission']??![],'value_type':z['value_type']??'Address','value':z['value'],'name':z['name'],'object_type':z['object_type']}));i=assessGuardRisks({'table':y,'root':e,'rely':f,'scene':x,'sharing_recipients':g?.['sharing_recipients']});for(const z of i['risks']){const A=z['level']==='critical'||z['level']==='high'?'error':z['level']==='medium'?'warning':z['level']==='low'?'info':'hint',B=z['evidence']??'',C=B['startsWith']('/')?B:'/';h['push']({'code':z['id'],'message':'['+z['level']+']\x20'+z['title'],'severity':A,'source':'risk','location':{'path':C},'fix':{'description':z['mitigation'],'auto_fixable':![]}});}}const o=checkSuggestions(a);h['push'](...o);const p=h['filter'](D=>D['severity']==='error')['length'],q=h['filter'](D=>D['severity']==='warning')['length'],s=h['filter'](D=>D['severity']==='info'||D['severity']==='hint')['length'],t=p===0x0;let u;if(p>0x0)u='Fix\x20'+p+'\x20error(s)\x20and\x20re-run\x20lint';else q>0x0?u='Consider\x20addressing\x20'+q+'\x20warning(s),\x20then\x20submit\x20to\x20SDK\x20newGuard()\x20for\x20final\x20syntax\x20validation':u='lint\x20passed\x20(no\x20errors);\x20submit\x20to\x20SDK\x20newGuard()\x20for\x20final\x20syntax\x20validation\x20before\x20going\x20on-chain';return{'json_summary':{'table_count':d['length'],'root_type':e?.['type']??'unknown','has_rely':!!f?.['guards']?.['length'],'rely_count':f?.['guards']?.['length']??0x0,'has_description':!!a['description']},'diagnostics':h,'fixed_json':m,'fix_actions':n,'risk_assessment':i,'summary':{'errors':p,'warnings':q,'infos':s,'auto_fixes_applied':n['length'],'ready':t,'next_step':u}};}export async function isGuardReady(a){const b=await lintGuard(a,{'auto_fix':![]});return b['summary']['ready'];}export async function getGuardErrors(a){const b=await lintGuard(a,{'auto_fix':![]});return b['diagnostics']['filter'](c=>c['severity']==='error');}export function formatLintResult(a){const b=[];b['push']('===\x20Guard\x20JSON\x20Lint\x20Report\x20==='),b['push'](''),b['push']('Summary:'),b['push']('\x20\x20Errors:\x20\x20\x20\x20\x20'+a['summary']['errors']),b['push']('\x20\x20Warnings:\x20\x20\x20'+a['summary']['warnings']),b['push']('\x20\x20Infos:\x20\x20\x20\x20\x20\x20'+a['summary']['infos']),b['push']('\x20\x20Auto-fixes:\x20'+a['summary']['auto_fixes_applied']),b['push']('\x20\x20Ready:\x20\x20\x20\x20\x20\x20'+(a['summary']['ready']?'YES':'NO')),b['push']('\x20\x20Next\x20step:\x20\x20'+a['summary']['next_step']),b['push']('');if(a['fix_actions']['length']>0x0){b['push']('---\x20Auto-fix\x20Actions\x20---');for(const g of a['fix_actions']){b['push']('\x20\x20['+g['diagnostic_code']+']\x20'+g['description']),b['push']('\x20\x20\x20\x20Path:\x20'+g['path']),g['before']&&g['after']&&b['push']('\x20\x20\x20\x20'+g['before']+'\x20->\x20'+g['after']);}b['push']('');}const c=a['diagnostics']['filter'](h=>h['severity']==='error'),e=a['diagnostics']['filter'](h=>h['severity']==='warning'),f=a['diagnostics']['filter'](h=>h['severity']==='info'||h['severity']==='hint');if(c['length']>0x0){b['push']('---\x20Errors\x20(must\x20fix)\x20---');for(const h of c){b['push']('\x20\x20['+h['code']+']\x20('+h['source']+')\x20'+h['message']),b['push']('\x20\x20\x20\x20Path:\x20'+h['location']['path']);if(h['fix'])b['push']('\x20\x20\x20\x20Fix:\x20\x20'+h['fix']['description']);}b['push']('');}if(e['length']>0x0){b['push']('---\x20Warnings\x20(consider\x20fixing)\x20---');for(const i of e){b['push']('\x20\x20['+i['code']+']\x20('+i['source']+')\x20'+i['message']),b['push']('\x20\x20\x20\x20Path:\x20'+i['location']['path']);if(i['fix'])b['push']('\x20\x20\x20\x20Fix:\x20\x20'+i['fix']['description']);}b['push']('');}if(f['length']>0x0){b['push']('---\x20Info\x20&\x20Hints\x20---');for(const j of f){b['push']('\x20\x20['+j['code']+']\x20('+j['source']+')\x20'+j['message']),b['push']('\x20\x20\x20\x20Path:\x20'+j['location']['path']);}}return b['join']('\x0a');}