@wowok/agent-mcp 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/account-events.d.ts +32 -0
  4. package/dist/customer/account-events.js +1 -0
  5. package/dist/customer/customer-advice.d.ts +1 -0
  6. package/dist/customer/customer-advice.js +1 -130
  7. package/dist/customer/index.js +1 -11
  8. package/dist/customer/industry-risks.js +1 -438
  9. package/dist/customer/info-puzzle.js +1 -681
  10. package/dist/customer/order-monitor.js +1 -328
  11. package/dist/customer/order-strategy.d.ts +1 -1
  12. package/dist/customer/order-strategy.js +1 -373
  13. package/dist/customer/post-purchase.js +1 -351
  14. package/dist/customer/preorder-compare.js +1 -34
  15. package/dist/customer/reminder-system.d.ts +2 -0
  16. package/dist/customer/reminder-system.js +1 -316
  17. package/dist/customer/risk-assessment.d.ts +1 -0
  18. package/dist/customer/risk-assessment.js +1 -397
  19. package/dist/customer/types.d.ts +2 -0
  20. package/dist/customer/types.js +1 -13
  21. package/dist/customer/user-preferences.js +1 -460
  22. package/dist/evaluation/arbitration-game.d.ts +9 -2
  23. package/dist/evaluation/arbitration-game.js +1 -48
  24. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  25. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  26. package/dist/evaluation/builtins/demand-match.js +1 -153
  27. package/dist/evaluation/builtins/index.d.ts +1 -0
  28. package/dist/evaluation/builtins/index.js +1 -10
  29. package/dist/evaluation/builtins/service-risk.js +1 -55
  30. package/dist/evaluation/capability.js +1 -13
  31. package/dist/evaluation/category-match-rules.d.ts +30 -0
  32. package/dist/evaluation/category-match-rules.js +1 -0
  33. package/dist/evaluation/composer.js +1 -40
  34. package/dist/evaluation/engine.js +1 -175
  35. package/dist/evaluation/extract.js +1 -115
  36. package/dist/evaluation/game-strategy.d.ts +27 -0
  37. package/dist/evaluation/game-strategy.js +1 -0
  38. package/dist/evaluation/gap.js +1 -100
  39. package/dist/evaluation/index.d.ts +2 -0
  40. package/dist/evaluation/index.js +1 -11
  41. package/dist/evaluation/location-match.d.ts +42 -0
  42. package/dist/evaluation/location-match.js +1 -0
  43. package/dist/evaluation/node-game.d.ts +31 -3
  44. package/dist/evaluation/node-game.js +1 -57
  45. package/dist/evaluation/path-reasoning.d.ts +35 -0
  46. package/dist/evaluation/path-reasoning.js +1 -0
  47. package/dist/evaluation/region.d.ts +6 -0
  48. package/dist/evaluation/region.js +1 -36
  49. package/dist/evaluation/types.d.ts +18 -0
  50. package/dist/evaluation/types.js +1 -1
  51. package/dist/evaluation/user-injection.js +1 -27
  52. package/dist/experience/experience-reuse.js +1 -103
  53. package/dist/experience/index.js +1 -5
  54. package/dist/experience/intent-distill.js +1 -83
  55. package/dist/experience/realtime-feedback.js +1 -94
  56. package/dist/experience/types.js +1 -1
  57. package/dist/experience/user-profile.d.ts +1 -1
  58. package/dist/experience/user-profile.js +1 -171
  59. package/dist/extensions/business-modules.js +1 -287
  60. package/dist/extensions/capability-manifest.js +1 -781
  61. package/dist/extensions/constraint-registry.js +1 -198
  62. package/dist/extensions/index.d.ts +6 -0
  63. package/dist/extensions/index.js +1 -6
  64. package/dist/extensions/industry-layers.d.ts +75 -0
  65. package/dist/extensions/industry-layers.js +1 -0
  66. package/dist/extensions/industry-pack.d.ts +105 -0
  67. package/dist/extensions/industry-pack.js +1 -0
  68. package/dist/extensions/metric-registry.js +1 -257
  69. package/dist/extensions/mode-evaluator.d.ts +1 -1
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.d.ts +1 -0
  73. package/dist/extensions/registry.js +1 -717
  74. package/dist/extensions/types.js +1 -1
  75. package/dist/graph/base.d.ts +8 -0
  76. package/dist/graph/base.js +1 -0
  77. package/dist/harness/auto-escalation.js +1 -68
  78. package/dist/harness/checkpoint.js +1 -129
  79. package/dist/harness/index.d.ts +1 -0
  80. package/dist/harness/index.js +1 -78
  81. package/dist/harness/plan.d.ts +2 -0
  82. package/dist/harness/plan.js +1 -315
  83. package/dist/harness/recover.d.ts +1 -1
  84. package/dist/harness/recover.js +1 -139
  85. package/dist/harness/types.d.ts +2 -3
  86. package/dist/harness/types.js +1 -1
  87. package/dist/harness/verify.js +1 -237
  88. package/dist/index.js +1 -273
  89. package/dist/intent/enrich.js +1 -67
  90. package/dist/intent/index.js +1 -60
  91. package/dist/intent/matcher.js +1 -81
  92. package/dist/intent/store.js +1 -55
  93. package/dist/intent/types.js +1 -10
  94. package/dist/knowledge/acquisition-flywheel.js +1 -192
  95. package/dist/knowledge/allocation-confirm.js +1 -534
  96. package/dist/knowledge/allocation-context.js +1 -249
  97. package/dist/knowledge/allocation-ledger.js +1 -463
  98. package/dist/knowledge/allocation-puzzle.js +1 -298
  99. package/dist/knowledge/allocation-risk.js +1 -568
  100. package/dist/knowledge/allocation-templates.js +1 -970
  101. package/dist/knowledge/allocation-translation.js +1 -585
  102. package/dist/knowledge/anti-cheat.d.ts +37 -0
  103. package/dist/knowledge/anti-cheat.js +1 -0
  104. package/dist/knowledge/arb-confirm.d.ts +28 -0
  105. package/dist/knowledge/arb-confirm.js +1 -0
  106. package/dist/knowledge/arb-risk.js +1 -210
  107. package/dist/knowledge/arb-translation.d.ts +48 -0
  108. package/dist/knowledge/arb-translation.js +1 -0
  109. package/dist/knowledge/arbitration-confirm.js +1 -559
  110. package/dist/knowledge/arbitration-context.js +1 -505
  111. package/dist/knowledge/arbitration-ledger.js +1 -521
  112. package/dist/knowledge/arbitration-puzzle.js +1 -304
  113. package/dist/knowledge/arbitration-risk.js +1 -423
  114. package/dist/knowledge/arbitration-templates.js +1 -276
  115. package/dist/knowledge/arbitration-translation.js +1 -487
  116. package/dist/knowledge/audit-rules.js +1 -141
  117. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  118. package/dist/knowledge/bridge-confirm.js +1 -0
  119. package/dist/knowledge/bridge-risk.js +1 -263
  120. package/dist/knowledge/bridge-translation.d.ts +37 -0
  121. package/dist/knowledge/bridge-translation.js +1 -0
  122. package/dist/knowledge/contact-confirm.d.ts +27 -0
  123. package/dist/knowledge/contact-confirm.js +1 -0
  124. package/dist/knowledge/contact-risk.js +1 -200
  125. package/dist/knowledge/contact-templates.js +1 -60
  126. package/dist/knowledge/contact-translation.d.ts +39 -0
  127. package/dist/knowledge/contact-translation.js +1 -0
  128. package/dist/knowledge/demand-confirm.js +1 -206
  129. package/dist/knowledge/demand-context.d.ts +17 -0
  130. package/dist/knowledge/demand-context.js +1 -0
  131. package/dist/knowledge/demand-ledger.d.ts +26 -0
  132. package/dist/knowledge/demand-ledger.js +1 -0
  133. package/dist/knowledge/demand-matching.js +1 -132
  134. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  135. package/dist/knowledge/demand-puzzle.js +1 -0
  136. package/dist/knowledge/demand-risk.js +1 -240
  137. package/dist/knowledge/demand-templates.d.ts +12 -0
  138. package/dist/knowledge/demand-templates.js +1 -0
  139. package/dist/knowledge/demand-translation.js +1 -354
  140. package/dist/knowledge/deployment-scanner.js +1 -823
  141. package/dist/knowledge/dynamic-pricing.js +1 -87
  142. package/dist/knowledge/evidence-review.d.ts +12 -0
  143. package/dist/knowledge/evidence-review.js +1 -0
  144. package/dist/knowledge/examples-scanner-cli.js +1 -26
  145. package/dist/knowledge/examples-scanner.js +1 -843
  146. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  147. package/dist/knowledge/flywheel-loop.js +1 -404
  148. package/dist/knowledge/fund-layer.js +1 -973
  149. package/dist/knowledge/glossary.js +1 -211
  150. package/dist/knowledge/guard-confirm.js +1 -406
  151. package/dist/knowledge/guard-context.js +1 -287
  152. package/dist/knowledge/guard-design-patterns.js +1 -360
  153. package/dist/knowledge/guard-ledger.js +1 -260
  154. package/dist/knowledge/guard-lint.js +1 -670
  155. package/dist/knowledge/guard-migration.d.ts +1 -1
  156. package/dist/knowledge/guard-migration.js +1 -228
  157. package/dist/knowledge/guard-puzzle.js +1 -805
  158. package/dist/knowledge/guard-render.js +1 -700
  159. package/dist/knowledge/guard-risk.js +1 -1879
  160. package/dist/knowledge/guard-submission-prompt.js +1 -171
  161. package/dist/knowledge/guard-templates.js +1 -1105
  162. package/dist/knowledge/guard-translation.js +1 -1119
  163. package/dist/knowledge/index.d.ts +71 -3
  164. package/dist/knowledge/index.js +1 -436
  165. package/dist/knowledge/industry-evolution.js +1 -323
  166. package/dist/knowledge/industry-generalizer.js +1 -381
  167. package/dist/knowledge/industry-registry.js +1 -174
  168. package/dist/knowledge/intent-metrics.d.ts +4 -3
  169. package/dist/knowledge/intent-metrics.js +1 -566
  170. package/dist/knowledge/machine-confirm.js +1 -559
  171. package/dist/knowledge/machine-context.js +1 -833
  172. package/dist/knowledge/machine-ledger.js +1 -338
  173. package/dist/knowledge/machine-puzzle.js +1 -494
  174. package/dist/knowledge/machine-render.js +1 -565
  175. package/dist/knowledge/machine-risk.js +1 -669
  176. package/dist/knowledge/machine-templates.js +1 -1597
  177. package/dist/knowledge/machine-topology.js +1 -234
  178. package/dist/knowledge/machine-translation.js +1 -513
  179. package/dist/knowledge/market-metrics.d.ts +12 -0
  180. package/dist/knowledge/market-metrics.js +1 -0
  181. package/dist/knowledge/market-operations.d.ts +46 -0
  182. package/dist/knowledge/market-operations.js +1 -0
  183. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  184. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  185. package/dist/knowledge/mcp-schema-audit.js +1 -777
  186. package/dist/knowledge/onchain-constants.js +1 -35
  187. package/dist/knowledge/order-confirm.js +1 -573
  188. package/dist/knowledge/order-context.js +1 -390
  189. package/dist/knowledge/order-ledger.js +1 -341
  190. package/dist/knowledge/order-puzzle.js +1 -255
  191. package/dist/knowledge/order-risk.js +1 -653
  192. package/dist/knowledge/order-templates.js +1 -368
  193. package/dist/knowledge/order-translation.js +1 -550
  194. package/dist/knowledge/overrides-loader.js +1 -65
  195. package/dist/knowledge/passport-confirm.js +1 -531
  196. package/dist/knowledge/passport-context.js +1 -306
  197. package/dist/knowledge/passport-ledger.js +1 -282
  198. package/dist/knowledge/passport-puzzle.js +1 -333
  199. package/dist/knowledge/passport-risk.js +1 -450
  200. package/dist/knowledge/passport-templates.js +1 -568
  201. package/dist/knowledge/passport-translation.js +1 -516
  202. package/dist/knowledge/payment-confirm.d.ts +26 -0
  203. package/dist/knowledge/payment-confirm.js +1 -0
  204. package/dist/knowledge/payment-risk.js +1 -249
  205. package/dist/knowledge/payment-translation.d.ts +37 -0
  206. package/dist/knowledge/payment-translation.js +1 -0
  207. package/dist/knowledge/permission-confirm.js +1 -426
  208. package/dist/knowledge/permission-context.js +1 -224
  209. package/dist/knowledge/permission-ledger.d.ts +11 -0
  210. package/dist/knowledge/permission-ledger.js +1 -403
  211. package/dist/knowledge/permission-puzzle.js +1 -173
  212. package/dist/knowledge/permission-risk.js +1 -411
  213. package/dist/knowledge/permission-templates.js +1 -234
  214. package/dist/knowledge/permission-translation.js +1 -350
  215. package/dist/knowledge/personal-confirm.d.ts +29 -0
  216. package/dist/knowledge/personal-confirm.js +1 -0
  217. package/dist/knowledge/personal-risk.js +1 -212
  218. package/dist/knowledge/personal-translation.d.ts +37 -0
  219. package/dist/knowledge/personal-translation.js +1 -0
  220. package/dist/knowledge/process-model.d.ts +1 -11
  221. package/dist/knowledge/process-model.js +1 -160
  222. package/dist/knowledge/progress-confirm.js +1 -456
  223. package/dist/knowledge/progress-context.js +1 -452
  224. package/dist/knowledge/progress-ledger.js +1 -330
  225. package/dist/knowledge/progress-puzzle.js +1 -219
  226. package/dist/knowledge/progress-risk.js +1 -461
  227. package/dist/knowledge/progress-templates.js +1 -228
  228. package/dist/knowledge/progress-translation.js +1 -405
  229. package/dist/knowledge/proof-confirm.js +1 -187
  230. package/dist/knowledge/proof-context.d.ts +17 -0
  231. package/dist/knowledge/proof-context.js +1 -0
  232. package/dist/knowledge/proof-ledger.d.ts +34 -0
  233. package/dist/knowledge/proof-ledger.js +1 -0
  234. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  235. package/dist/knowledge/proof-puzzle.js +1 -0
  236. package/dist/knowledge/proof-risk.js +1 -207
  237. package/dist/knowledge/proof-templates.d.ts +22 -0
  238. package/dist/knowledge/proof-templates.js +1 -0
  239. package/dist/knowledge/proof-translation.js +1 -283
  240. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  241. package/dist/knowledge/registrar-confirm.js +1 -0
  242. package/dist/knowledge/registrar-risk.js +1 -217
  243. package/dist/knowledge/registrar-translation.d.ts +37 -0
  244. package/dist/knowledge/registrar-translation.js +1 -0
  245. package/dist/knowledge/repository-confirm.js +1 -286
  246. package/dist/knowledge/repository-context.d.ts +12 -0
  247. package/dist/knowledge/repository-context.js +1 -0
  248. package/dist/knowledge/repository-ledger.d.ts +25 -0
  249. package/dist/knowledge/repository-ledger.js +1 -0
  250. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  251. package/dist/knowledge/repository-puzzle.js +1 -0
  252. package/dist/knowledge/repository-risk.js +1 -373
  253. package/dist/knowledge/repository-templates.d.ts +14 -0
  254. package/dist/knowledge/repository-templates.js +1 -0
  255. package/dist/knowledge/repository-translation.js +1 -445
  256. package/dist/knowledge/reputation-rules.js +1 -99
  257. package/dist/knowledge/resource-confirm.d.ts +25 -0
  258. package/dist/knowledge/resource-confirm.js +1 -0
  259. package/dist/knowledge/resource-risk.js +1 -157
  260. package/dist/knowledge/resource-translation.d.ts +37 -0
  261. package/dist/knowledge/resource-translation.js +1 -0
  262. package/dist/knowledge/reward-confirm.js +1 -526
  263. package/dist/knowledge/reward-context.d.ts +2 -2
  264. package/dist/knowledge/reward-context.js +1 -504
  265. package/dist/knowledge/reward-ledger.js +1 -502
  266. package/dist/knowledge/reward-puzzle.js +1 -300
  267. package/dist/knowledge/reward-risk.js +1 -627
  268. package/dist/knowledge/reward-templates.js +1 -197
  269. package/dist/knowledge/reward-translation.js +1 -501
  270. package/dist/knowledge/safety-rules.d.ts +1 -0
  271. package/dist/knowledge/safety-rules.js +1 -404
  272. package/dist/knowledge/scenario-modes.js +1 -321
  273. package/dist/knowledge/service-confirm.js +1 -807
  274. package/dist/knowledge/service-context.js +1 -403
  275. package/dist/knowledge/service-ledger.js +1 -609
  276. package/dist/knowledge/service-puzzle.js +1 -236
  277. package/dist/knowledge/service-risk.d.ts +1 -1
  278. package/dist/knowledge/service-risk.js +1 -651
  279. package/dist/knowledge/service-templates.js +1 -456
  280. package/dist/knowledge/service-translation.js +1 -622
  281. package/dist/knowledge/template-registry.js +1 -353
  282. package/dist/knowledge/tool-constraints.js +1 -195
  283. package/dist/knowledge/tools-reference.js +1 -178
  284. package/dist/knowledge/treasury-confirm.js +1 -512
  285. package/dist/knowledge/treasury-context.js +1 -363
  286. package/dist/knowledge/treasury-ledger.js +1 -300
  287. package/dist/knowledge/treasury-puzzle.js +1 -216
  288. package/dist/knowledge/treasury-risk.js +1 -440
  289. package/dist/knowledge/treasury-templates.js +1 -358
  290. package/dist/knowledge/treasury-translation.js +1 -498
  291. package/dist/knowledge/trust-metrics.js +1 -198
  292. package/dist/knowledge/universal-template.d.ts +22 -0
  293. package/dist/knowledge/universal-template.js +1 -0
  294. package/dist/knowledge/util-confirm.d.ts +24 -0
  295. package/dist/knowledge/util-confirm.js +1 -0
  296. package/dist/knowledge/util-risk.js +1 -135
  297. package/dist/knowledge/util-translation.d.ts +38 -0
  298. package/dist/knowledge/util-translation.js +1 -0
  299. package/dist/knowledge/workflow-guidance.d.ts +116 -0
  300. package/dist/knowledge/workflow-guidance.js +1 -0
  301. package/dist/loop-engineering/aggregate.js +1 -132
  302. package/dist/loop-engineering/context-collect.js +1 -83
  303. package/dist/loop-engineering/diagnose.js +1 -273
  304. package/dist/loop-engineering/improve.js +1 -405
  305. package/dist/loop-engineering/index.js +1 -4
  306. package/dist/loop-engineering/pipeline.js +1 -56
  307. package/dist/mode-market/index.js +1 -3
  308. package/dist/mode-market/registry.js +1 -124
  309. package/dist/mode-market/review.js +1 -214
  310. package/dist/mode-market/submission.js +1 -85
  311. package/dist/participation/collaborator-interest.d.ts +23 -0
  312. package/dist/participation/collaborator-interest.js +1 -0
  313. package/dist/participation/customer-interest.d.ts +25 -0
  314. package/dist/participation/customer-interest.js +1 -0
  315. package/dist/participation/employee-kpi.d.ts +25 -0
  316. package/dist/participation/employee-kpi.js +1 -0
  317. package/dist/participation/employee-store.d.ts +16 -0
  318. package/dist/participation/employee-store.js +1 -0
  319. package/dist/participation/index.d.ts +2 -0
  320. package/dist/participation/index.js +1 -0
  321. package/dist/participation/merchant-interest.js +1 -100
  322. package/dist/participation/radar-core.d.ts +13 -3
  323. package/dist/participation/radar-core.js +1 -269
  324. package/dist/participation/supplier-interest.d.ts +25 -0
  325. package/dist/participation/supplier-interest.js +1 -0
  326. package/dist/persona/analyzer.js +1 -66
  327. package/dist/persona/bridge.js +1 -86
  328. package/dist/persona/defaults.js +1 -195
  329. package/dist/persona/experience-bridge.js +1 -23
  330. package/dist/persona/index.d.ts +9 -2
  331. package/dist/persona/index.js +1 -71
  332. package/dist/persona/local-region.d.ts +20 -0
  333. package/dist/persona/local-region.js +1 -0
  334. package/dist/persona/model.js +1 -111
  335. package/dist/persona/overrides.d.ts +10 -0
  336. package/dist/persona/overrides.js +1 -0
  337. package/dist/persona/pack-personae.d.ts +11 -0
  338. package/dist/persona/pack-personae.js +1 -0
  339. package/dist/persona/store.js +1 -62
  340. package/dist/persona/strategy-intent.d.ts +20 -0
  341. package/dist/persona/strategy-intent.js +1 -0
  342. package/dist/persona/types.d.ts +6 -2
  343. package/dist/persona/types.js +1 -5
  344. package/dist/project/business-puzzle.d.ts +1 -1
  345. package/dist/project/business-puzzle.js +1 -383
  346. package/dist/project/context-assembly.js +1 -254
  347. package/dist/project/deployment-bridge.js +1 -120
  348. package/dist/project/deployment-doc.js +1 -1126
  349. package/dist/project/edit-planner.js +1 -1342
  350. package/dist/project/evaluation.d.ts +37 -1
  351. package/dist/project/evaluation.js +1 -2011
  352. package/dist/project/game-theory.js +1 -177
  353. package/dist/project/graph-builder.js +1 -656
  354. package/dist/project/graph.d.ts +3 -6
  355. package/dist/project/graph.js +1 -340
  356. package/dist/project/handlers.d.ts +33 -2
  357. package/dist/project/handlers.js +1 -1784
  358. package/dist/project/index.d.ts +2 -0
  359. package/dist/project/index.js +1 -301
  360. package/dist/project/intent-analyzer.js +1 -149
  361. package/dist/project/machine-nodes.js +1 -36
  362. package/dist/project/merchant-guide.d.ts +19 -0
  363. package/dist/project/merchant-guide.js +1 -264
  364. package/dist/project/migration.js +1 -125
  365. package/dist/project/mode-actions.js +1 -309
  366. package/dist/project/namespace.js +1 -206
  367. package/dist/project/participation-radar.js +1 -428
  368. package/dist/project/pipeline-actions.js +1 -109
  369. package/dist/project/project-store.js +1 -422
  370. package/dist/project/query.js +1 -153
  371. package/dist/project/reverse-mapping.d.ts +34 -0
  372. package/dist/project/reverse-mapping.js +1 -0
  373. package/dist/project/risk-aggregator.js +1 -295
  374. package/dist/project/rollback-policy.js +1 -290
  375. package/dist/project/semantic-assembler.js +1 -345
  376. package/dist/project/semantic-graph.d.ts +3 -5
  377. package/dist/project/semantic-graph.js +1 -292
  378. package/dist/project/stage-gate.js +1 -369
  379. package/dist/project/substep-trace.js +1 -332
  380. package/dist/project/task-tracker.js +1 -78
  381. package/dist/project/workflow-design-assessment.d.ts +24 -0
  382. package/dist/project/workflow-design-assessment.js +1 -0
  383. package/dist/role/derivation.d.ts +18 -0
  384. package/dist/role/derivation.js +1 -0
  385. package/dist/role/index.d.ts +5 -0
  386. package/dist/role/index.js +1 -0
  387. package/dist/role/model.d.ts +8 -0
  388. package/dist/role/model.js +1 -0
  389. package/dist/role/resolution.d.ts +11 -0
  390. package/dist/role/resolution.js +1 -0
  391. package/dist/role/types.d.ts +11 -0
  392. package/dist/role/types.js +1 -0
  393. package/dist/rules.js +1 -52
  394. package/dist/safety/confirm-gate.d.ts +1 -1
  395. package/dist/safety/confirm-gate.js +1 -88
  396. package/dist/safety/index.js +1 -3
  397. package/dist/safety/preview.js +1 -52
  398. package/dist/schema/call/allocation.d.ts +186 -1385
  399. package/dist/schema/call/allocation.js +1 -34
  400. package/dist/schema/call/arbitration.d.ts +272 -1871
  401. package/dist/schema/call/arbitration.js +1 -113
  402. package/dist/schema/call/base.d.ts +1831 -9076
  403. package/dist/schema/call/base.js +1 -370
  404. package/dist/schema/call/bridge.d.ts +911 -3171
  405. package/dist/schema/call/bridge.js +1 -458
  406. package/dist/schema/call/contact.d.ts +135 -931
  407. package/dist/schema/call/contact.js +1 -37
  408. package/dist/schema/call/demand.d.ts +164 -1194
  409. package/dist/schema/call/demand.js +1 -47
  410. package/dist/schema/call/guard.d.ts +298 -1140
  411. package/dist/schema/call/guard.js +1 -161
  412. package/dist/schema/call/handler.js +1 -322
  413. package/dist/schema/call/index.js +1 -20
  414. package/dist/schema/call/machine.d.ts +459 -5403
  415. package/dist/schema/call/machine.js +1 -193
  416. package/dist/schema/call/order.d.ts +137 -844
  417. package/dist/schema/call/order.js +1 -35
  418. package/dist/schema/call/payment.d.ts +74 -561
  419. package/dist/schema/call/payment.js +1 -37
  420. package/dist/schema/call/permission-handler.js +1 -54
  421. package/dist/schema/call/permission.d.ts +335 -2791
  422. package/dist/schema/call/permission.js +1 -105
  423. package/dist/schema/call/personal.d.ts +227 -1814
  424. package/dist/schema/call/personal.js +1 -78
  425. package/dist/schema/call/progress.d.ts +140 -843
  426. package/dist/schema/call/progress.js +1 -47
  427. package/dist/schema/call/proof.d.ts +42 -258
  428. package/dist/schema/call/proof.js +1 -33
  429. package/dist/schema/call/repository.d.ts +324 -2222
  430. package/dist/schema/call/repository.js +1 -77
  431. package/dist/schema/call/reward.d.ts +153 -1183
  432. package/dist/schema/call/reward.js +1 -30
  433. package/dist/schema/call/semantic.js +1 -1679
  434. package/dist/schema/call/service.d.ts +376 -3431
  435. package/dist/schema/call/service.js +1 -184
  436. package/dist/schema/call/treasury.d.ts +252 -2158
  437. package/dist/schema/call/treasury.js +1 -71
  438. package/dist/schema/common/index.d.ts +222 -697
  439. package/dist/schema/common/index.js +1 -407
  440. package/dist/schema/config/index.d.ts +18 -161
  441. package/dist/schema/config/index.js +1 -68
  442. package/dist/schema/employee/index.d.ts +99 -0
  443. package/dist/schema/employee/index.js +1 -0
  444. package/dist/schema/evaluation/index.d.ts +1062 -3748
  445. package/dist/schema/evaluation/index.js +1 -356
  446. package/dist/schema/index.d.ts +3 -0
  447. package/dist/schema/index.js +1 -17
  448. package/dist/schema/industry-pack/index.d.ts +132 -0
  449. package/dist/schema/industry-pack/index.js +1 -0
  450. package/dist/schema/intent-radar/index.d.ts +92 -245
  451. package/dist/schema/intent-radar/index.js +1 -89
  452. package/dist/schema/local/index.d.ts +2045 -18080
  453. package/dist/schema/local/index.js +1 -927
  454. package/dist/schema/local/wip.d.ts +61 -651
  455. package/dist/schema/local/wip.js +1 -187
  456. package/dist/schema/messenger/index.d.ts +949 -5557
  457. package/dist/schema/messenger/index.js +1 -475
  458. package/dist/schema/operations.d.ts +2969 -26518
  459. package/dist/schema/operations.js +1 -520
  460. package/dist/schema/persona/index.d.ts +469 -1820
  461. package/dist/schema/persona/index.js +1 -148
  462. package/dist/schema/project/index.d.ts +1027 -8408
  463. package/dist/schema/project/index.js +1 -2057
  464. package/dist/schema/query/index.d.ts +12041 -75261
  465. package/dist/schema/query/index.js +1 -1646
  466. package/dist/schema/schema-query/index.d.ts +35 -98
  467. package/dist/schema/schema-query/index.js +1 -104
  468. package/dist/schema/schema-version.js +1 -76
  469. package/dist/schema/task-status.d.ts +26 -132
  470. package/dist/schema/task-status.js +1 -36
  471. package/dist/schema/trust/index.d.ts +194 -1290
  472. package/dist/schema/trust/index.js +1 -314
  473. package/dist/schema/utils/guard-parser.js +1 -419
  474. package/dist/schema/utils/guard-query-utils.js +1 -46
  475. package/dist/schema/utils/node-parser.js +1 -369
  476. package/dist/schema/utils/object-type-utils.js +1 -35
  477. package/dist/schema/utils/permission-index-utils.js +1 -7
  478. package/dist/schema/utils/permission-machine-check.js +1 -121
  479. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  480. package/dist/schema/utils/skills-recommendation.js +1 -77
  481. package/dist/schema/workspace/index.d.ts +69 -0
  482. package/dist/schema/workspace/index.js +1 -0
  483. package/dist/schema-query-impl/index.js +1 -0
  484. package/dist/schemas/account_operation.output.json +3147 -1652
  485. package/dist/schemas/account_operation.schema.json +225 -218
  486. package/dist/schemas/bridge_operation.output.json +1168 -650
  487. package/dist/schemas/bridge_operation.schema.json +736 -504
  488. package/dist/schemas/config_operation.output.json +185 -179
  489. package/dist/schemas/config_operation.schema.json +21 -26
  490. package/dist/schemas/employee_operation.output.json +207 -0
  491. package/dist/schemas/employee_operation.schema.json +176 -0
  492. package/dist/schemas/evaluation_operation.output.json +2329 -557
  493. package/dist/schemas/evaluation_operation.schema.json +2939 -720
  494. package/dist/schemas/guard2file.output.json +58 -64
  495. package/dist/schemas/guard2file.schema.json +79 -81
  496. package/dist/schemas/index.json +29 -11
  497. package/dist/schemas/industry_pack_operation.output.json +594 -0
  498. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  499. package/dist/schemas/intent_radar.output.json +275 -200
  500. package/dist/schemas/intent_radar.schema.json +124 -123
  501. package/dist/schemas/local_info_operation.output.json +1174 -657
  502. package/dist/schemas/local_info_operation.schema.json +119 -125
  503. package/dist/schemas/local_mark_operation.output.json +1239 -689
  504. package/dist/schemas/local_mark_operation.schema.json +91 -96
  505. package/dist/schemas/machineNode2file.output.json +63 -69
  506. package/dist/schemas/machineNode2file.schema.json +79 -81
  507. package/dist/schemas/messenger_operation.output.json +2722 -1528
  508. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  509. package/dist/schemas/onchain_events.output.json +2590 -975
  510. package/dist/schemas/onchain_events.schema.json +117 -99
  511. package/dist/schemas/onchain_operations.output.json +3957 -2309
  512. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  513. package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
  514. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  515. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  516. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  517. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  518. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  519. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  520. package/dist/schemas/onchain_operations_machine.schema.json +537 -164
  521. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  522. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  523. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  524. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  525. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  526. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  527. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  528. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  529. package/dist/schemas/onchain_operations_service.schema.json +679 -221
  530. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  531. package/dist/schemas/onchain_table_data.output.json +6018 -2430
  532. package/dist/schemas/onchain_table_data.schema.json +544 -430
  533. package/dist/schemas/persona_operation.output.json +1568 -265
  534. package/dist/schemas/persona_operation.schema.json +346 -202
  535. package/dist/schemas/project_operation.output.json +6957 -5147
  536. package/dist/schemas/project_operation.schema.json +1050 -1020
  537. package/dist/schemas/query_task_status.output.json +195 -99
  538. package/dist/schemas/query_task_status.schema.json +12 -18
  539. package/dist/schemas/query_toolkit.output.json +18870 -14566
  540. package/dist/schemas/query_toolkit.schema.json +614 -522
  541. package/dist/schemas/schema_query.output.json +127 -129
  542. package/dist/schemas/schema_query.schema.json +64 -69
  543. package/dist/schemas/trust_score.output.json +678 -587
  544. package/dist/schemas/trust_score.schema.json +289 -277
  545. package/dist/schemas/wip_file.output.json +116 -124
  546. package/dist/schemas/wip_file.schema.json +142 -143
  547. package/dist/schemas/workspace_operation.output.json +277 -0
  548. package/dist/schemas/workspace_operation.schema.json +45 -0
  549. package/dist/schemas/wowok_buildin_info.output.json +1693 -723
  550. package/dist/schemas/wowok_buildin_info.schema.json +576 -512
  551. package/dist/telemetry/index.js +1 -112
  552. package/dist/telemetry/redact.js +1 -23
  553. package/dist/telemetry/storage.js +1 -80
  554. package/dist/tools/handlers/bridge.d.ts +8 -1
  555. package/dist/tools/handlers/bridge.js +1 -1
  556. package/dist/tools/handlers/config.js +1 -74
  557. package/dist/tools/handlers/employee.d.ts +2 -0
  558. package/dist/tools/handlers/employee.js +1 -0
  559. package/dist/tools/handlers/evaluation.js +1 -123
  560. package/dist/tools/handlers/file-export.js +1 -90
  561. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  562. package/dist/tools/handlers/industry-pack.js +1 -0
  563. package/dist/tools/handlers/intent-radar.js +1 -76
  564. package/dist/tools/handlers/local.js +1 -53
  565. package/dist/tools/handlers/messenger.js +1 -188
  566. package/dist/tools/handlers/onchain.js +1 -1180
  567. package/dist/tools/handlers/persona.js +1 -89
  568. package/dist/tools/handlers/project.js +1 -211
  569. package/dist/tools/handlers/query.js +1 -434
  570. package/dist/tools/handlers/schema-query.js +1 -176
  571. package/dist/tools/handlers/task-status.js +1 -26
  572. package/dist/tools/handlers/trust.js +1 -380
  573. package/dist/tools/handlers/wip.js +1 -90
  574. package/dist/tools/handlers/workspace.d.ts +2 -0
  575. package/dist/tools/handlers/workspace.js +1 -0
  576. package/dist/tools/index.d.ts +2 -1
  577. package/dist/tools/index.js +1 -1382
  578. package/dist/tools/retry.js +1 -85
  579. package/dist/tools/rules-hook.d.ts +1 -1
  580. package/dist/tools/rules-hook.js +1 -23
  581. package/dist/tools/shared.d.ts +1 -1
  582. package/dist/tools/shared.js +1 -130
  583. package/dist/tools/types.d.ts +2 -1
  584. package/dist/tools/types.js +1 -1
  585. package/dist/tools/upgrade-check.d.ts +19 -0
  586. package/dist/tools/upgrade-check.js +1 -0
  587. package/dist/tools/wip-deploy-assist.js +1 -306
  588. package/dist/tools/wrap.js +1 -500
  589. package/package.json +7 -6
  590. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  591. package/dist/knowledge/arbitration-trust.js +0 -117
  592. package/dist/schema/call/bridge-handler.d.ts +0 -8
  593. package/dist/schema/call/bridge-handler.js +0 -265
  594. package/dist/schema/sync-layer4.d.ts +0 -21
  595. package/dist/schema/sync-layer4.js +0 -286
  596. package/dist/schema-query/index.js +0 -810
  597. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -1,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');}