@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,773 +1 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- export const DEPLOYED_TOOLS_DIR = 'c:\\Users\\zhou\\.trae-cn\\mcps\\s_wowok-7838e181\\solo_agent\\mcp_wagent\\tools';
4
- export const GENERATED_SCHEMAS_DIR = 'd:\\wowok\\agent\\mcp\\dist\\schemas';
5
- export const MCP_SRC_SCHEMA_DIR = 'd:\\wowok\\agent\\mcp\\src\\schema';
6
- export const MCP_SRC_TOOLS_DIR = 'd:\\wowok\\agent\\mcp\\src\\tools';
7
- export const GENERATION_SCRIPT = 'd:\\wowok\\agent\\mcp\\scripts\\generate-json-schemas.ts';
8
- export const TOOLS_INDEX_FILE = 'd:\\wowok\\agent\\mcp\\src\\tools\\index.ts';
9
- export const MCP_SCHEMA_AUDIT_VERSION = '1.0.0';
10
- export const TOOLS_17 = [
11
- { name: 'onchain_operations', input_schema_export: 'OnchainOperationsSchema', output_schema_export: 'CallOutputSchema' },
12
- { name: 'account_operation', input_schema_export: 'AccountOperationSchema', output_schema_export: 'AccountOperationOutputWrappedSchema' },
13
- { name: 'local_mark_operation', input_schema_export: 'LocalMarkOperationSchema', output_schema_export: 'LocalMarkOperationOutputWrappedSchema' },
14
- { name: 'local_info_operation', input_schema_export: 'LocalInfoOperationSchema', output_schema_export: 'LocalInfoOperationOutputWrappedSchema' },
15
- { name: 'wip_file', input_schema_export: 'WipOperationsSchema', output_schema_export: 'WipOperationOutputSchema' },
16
- { name: 'messenger_operation', input_schema_export: 'MessengerOperationInputSchema', output_schema_export: 'MessengerOperationOutputSchema' },
17
- { name: 'guard2file', input_schema_export: 'Guard2File_InputSchema', output_schema_export: 'Guard2File_OutputWrappedSchema' },
18
- { name: 'machineNode2file', input_schema_export: 'MachineNode2File_InputSchema', output_schema_export: 'MachineNode2File_OutputWrappedSchema' },
19
- { name: 'query_toolkit', input_schema_export: 'WatchQueryOperationsSchema', output_schema_export: 'WatchQueryOperationsResultSchema' },
20
- { name: 'onchain_table_data', input_schema_export: 'OnchainTableDataSchema', output_schema_export: 'OnchainTableDataResultSchema' },
21
- { name: 'onchain_events', input_schema_export: 'OnchainEventsInputSchema', output_schema_export: 'OnchainEventsResultSchema' },
22
- { name: 'wowok_buildin_info', input_schema_export: 'ProtocolInfoQuerySchema', output_schema_export: 'ProtocolInfoResultSchema' },
23
- { name: 'schema_query', input_schema_export: 'SchemaQueryInputSchema', output_schema_export: 'SchemaQueryOutputSchema' },
24
- { name: 'bridge_operation', input_schema_export: 'BridgeOperationsSchema', output_schema_export: 'BridgeCallOutputSchema' },
25
- { name: 'project_operation', input_schema_export: 'ProjectOperationInputSchema', output_schema_export: 'ProjectOperationOutputSchema' },
26
- { name: 'config_operation', input_schema_export: 'ConfigOperationInputSchema', output_schema_export: 'ConfigOperationOutputSchema' },
27
- { name: 'trust_score', input_schema_export: 'TrustScoreInputSchema', output_schema_export: 'TrustScoreOutputSchema' },
28
- ];
29
- export function loadLayer4Deployed(toolName) {
30
- const filePath = path.join(DEPLOYED_TOOLS_DIR, `${toolName}.json`);
31
- const fallback = {
32
- tool_descriptor_file: filePath,
33
- file_exists: false,
34
- is_stub: true,
35
- properties_count: 0,
36
- required_count: 0,
37
- has_schema_hint: false,
38
- has_additional_properties_false: false,
39
- has_dollar_schema: false,
40
- has_oneof: false,
41
- has_anyof: false,
42
- has_allof: false,
43
- union_count: 0,
44
- };
45
- if (!fs.existsSync(filePath))
46
- return fallback;
47
- try {
48
- const raw = fs.readFileSync(filePath, 'utf-8');
49
- const data = JSON.parse(raw);
50
- const args = data.arguments ?? {};
51
- const props = args.properties ?? {};
52
- const required = args.required ?? [];
53
- const propKeys = Object.keys(props);
54
- const oneOfArr = args.oneOf ?? [];
55
- const anyOfArr = args.anyOf ?? [];
56
- const allOfArr = args.allOf ?? [];
57
- const hasOneOf = oneOfArr.length > 0;
58
- const hasAnyOf = anyOfArr.length > 0;
59
- const hasAllOf = allOfArr.length > 0;
60
- const unionCount = oneOfArr.length + anyOfArr.length + allOfArr.length;
61
- const isStub = propKeys.length === 0 && unionCount === 0;
62
- const description = data.description ?? '';
63
- const hasSchemaHint = description.includes('schema_query');
64
- return {
65
- tool_descriptor_file: filePath,
66
- file_exists: true,
67
- is_stub: isStub,
68
- properties_count: propKeys.length,
69
- required_count: required.length,
70
- has_schema_hint: hasSchemaHint,
71
- has_additional_properties_false: args.additionalProperties === false,
72
- has_dollar_schema: !!args.$schema,
73
- has_oneof: hasOneOf,
74
- has_anyof: hasAnyOf,
75
- has_allof: hasAllOf,
76
- union_count: unionCount,
77
- };
78
- }
79
- catch {
80
- return fallback;
81
- }
82
- }
83
- export function loadLayer3Generated(toolName) {
84
- const inputPath = path.join(GENERATED_SCHEMAS_DIR, `${toolName}.schema.json`);
85
- const outputPath = path.join(GENERATED_SCHEMAS_DIR, `${toolName}.output.json`);
86
- const inputExists = fs.existsSync(inputPath);
87
- const outputExists = fs.existsSync(outputPath);
88
- const inputSize = inputExists ? fs.statSync(inputPath).size : 0;
89
- const outputSize = outputExists ? fs.statSync(outputPath).size : 0;
90
- return {
91
- input_schema_file: inputPath,
92
- output_schema_file: outputPath,
93
- input_exists: inputExists,
94
- output_exists: outputExists,
95
- input_size_bytes: inputSize,
96
- output_size_bytes: outputSize,
97
- };
98
- }
99
- export function analyzeLayerCensus() {
100
- const census = [];
101
- for (const tool of TOOLS_17) {
102
- census.push({
103
- name: tool.name,
104
- layer2_zod: {
105
- input_schema_export: tool.input_schema_export,
106
- output_schema_export: tool.output_schema_export,
107
- schema_dir: MCP_SRC_SCHEMA_DIR,
108
- },
109
- layer3_generated: loadLayer3Generated(tool.name),
110
- layer4_deployed: loadLayer4Deployed(tool.name) ?? {},
111
- });
112
- }
113
- return census;
114
- }
115
- export function analyzeDeployedStubInconsistency(census) {
116
- const findings = [];
117
- const stubs = [];
118
- const fullSchemas = [];
119
- for (const c of census) {
120
- if (!c.layer4_deployed.file_exists) {
121
- findings.push({
122
- rule_id: 'MCP-DEPLOY-001',
123
- severity: 'critical',
124
- category: 'stub_inconsistency',
125
- tool_name: c.name,
126
- description: `Layer 4 deployed file does not exist: ${c.layer4_deployed.tool_descriptor_file}`,
127
- location: c.layer4_deployed.tool_descriptor_file,
128
- fix: `Create ${c.name}.json in DEPLOYED_TOOLS_DIR matching the Layer 3 generated schema.`,
129
- });
130
- continue;
131
- }
132
- if (c.layer4_deployed.is_stub) {
133
- stubs.push(c);
134
- }
135
- else {
136
- fullSchemas.push(c);
137
- }
138
- }
139
- for (const c of stubs) {
140
- findings.push({
141
- rule_id: 'MCP-STUB-001',
142
- severity: 'high',
143
- category: 'stub_inconsistency',
144
- tool_name: c.name,
145
- description: `Layer 4 deployed file is a STUB (empty properties:{}) — LLM must call schema_query(action='get', name='${c.name}') to learn the parameter structure. This is inconsistent with the ${fullSchemas.length} tools that embed full schemas.`,
146
- location: c.layer4_deployed.tool_descriptor_file,
147
- fix: `Regenerate ${c.name}.json from dist/schemas/${c.name}.schema.json (resolve $ref, inline definitions, wrap as {name, description, arguments}).`,
148
- });
149
- if (!c.layer4_deployed.has_schema_hint) {
150
- findings.push({
151
- rule_id: 'MCP-STUB-003',
152
- severity: 'high',
153
- category: 'stub_inconsistency',
154
- tool_name: c.name,
155
- description: `Stub file is missing schema_query hint in description — the LLM has no way to discover the parameter structure. Description should mention schema_query(action='get', name='${c.name}').`,
156
- location: c.layer4_deployed.tool_descriptor_file,
157
- fix: `Add "💡 Schema hint: Use schema_query with action='get' and name='${c.name}' to retrieve the exact parameter schema before calling." to the description.`,
158
- });
159
- }
160
- }
161
- if (stubs.length > 0 && fullSchemas.length > 0) {
162
- findings.push({
163
- rule_id: 'MCP-STUB-002',
164
- severity: 'info',
165
- category: 'stub_inconsistency',
166
- tool_name: '(all)',
167
- description: `Layer 4 deployed files are INCONSISTENT: ${stubs.length} stubs + ${fullSchemas.length} full schemas. Stubs: ${stubs.map(s => s.name).join(', ')}. Full: ${fullSchemas.map(s => s.name).join(', ')}.`,
168
- fix: `Make all 17 files consistent — either (a) embed full schemas in all 17 (RECOMMENDED — gives LLM immediate access), or (b) keep all stubs and rely on schema_query (increases token cost + latency).`,
169
- });
170
- }
171
- return findings;
172
- }
173
- export function analyzeLayerParity(census) {
174
- const findings = [];
175
- for (const c of census) {
176
- if (!c.layer4_deployed.file_exists || c.layer4_deployed.is_stub)
177
- continue;
178
- if (!c.layer3_generated.input_exists) {
179
- findings.push({
180
- rule_id: 'MCP-PARITY-001',
181
- severity: 'critical',
182
- category: 'layer_parity',
183
- tool_name: c.name,
184
- description: `Layer 4 has full schema but Layer 3 generated file is missing: ${c.layer3_generated.input_schema_file}`,
185
- fix: `Run pnpm generate:schemas to regenerate Layer 3 from Zod source.`,
186
- });
187
- continue;
188
- }
189
- const l4 = readLayer4Arguments(c.name);
190
- const l3 = readLayer3ResolvedSchema(c.name);
191
- if (!l4 || !l3)
192
- continue;
193
- const l4Props = new Set(Object.keys(l4.properties ?? {}));
194
- const l3Props = new Set(Object.keys(l3.properties ?? {}));
195
- const missingInL4 = [...l3Props].filter(p => !l4Props.has(p));
196
- const extraInL4 = [...l4Props].filter(p => !l3Props.has(p));
197
- if (missingInL4.length > 0) {
198
- findings.push({
199
- rule_id: 'MCP-PARITY-002',
200
- severity: 'high',
201
- category: 'layer_parity',
202
- tool_name: c.name,
203
- description: `Layer 4 deployed schema is missing ${missingInL4.length} properties present in Layer 3 generated schema: ${missingInL4.join(', ')}`,
204
- location: c.layer4_deployed.tool_descriptor_file,
205
- fix: `Regenerate ${c.name}.json from dist/schemas/${c.name}.schema.json.`,
206
- });
207
- }
208
- if (extraInL4.length > 0) {
209
- findings.push({
210
- rule_id: 'MCP-PARITY-003',
211
- severity: 'medium',
212
- category: 'layer_parity',
213
- tool_name: c.name,
214
- description: `Layer 4 deployed schema has ${extraInL4.length} extra properties not in Layer 3: ${extraInL4.join(', ')}`,
215
- location: c.layer4_deployed.tool_descriptor_file,
216
- fix: `Regenerate ${c.name}.json from dist/schemas/${c.name}.schema.json.`,
217
- });
218
- }
219
- const l4Req = new Set(l4.required ?? []);
220
- const l3Req = new Set(l3.required ?? []);
221
- const reqMissing = [...l3Req].filter(r => !l4Req.has(r));
222
- const reqExtra = [...l4Req].filter(r => !l3Req.has(r));
223
- if (reqMissing.length > 0 || reqExtra.length > 0) {
224
- findings.push({
225
- rule_id: 'MCP-PARITY-004',
226
- severity: 'high',
227
- category: 'layer_parity',
228
- tool_name: c.name,
229
- description: `Layer 4 'required' array differs from Layer 3. Missing in L4: [${reqMissing.join(', ')}]. Extra in L4: [${reqExtra.join(', ')}].`,
230
- location: c.layer4_deployed.tool_descriptor_file,
231
- fix: `Sync 'required' array from Layer 3 to Layer 4.`,
232
- });
233
- }
234
- const l4AP = l4.additionalProperties;
235
- const l3AP = l3.additionalProperties;
236
- if (l4AP !== l3AP) {
237
- findings.push({
238
- rule_id: 'MCP-PARITY-005',
239
- severity: 'medium',
240
- category: 'layer_parity',
241
- tool_name: c.name,
242
- description: `Layer 4 'additionalProperties' (${JSON.stringify(l4AP)}) differs from Layer 3 (${JSON.stringify(l3AP)}).`,
243
- location: c.layer4_deployed.tool_descriptor_file,
244
- fix: `Sync 'additionalProperties' value.`,
245
- });
246
- }
247
- }
248
- return findings;
249
- }
250
- function readLayer4Arguments(toolName) {
251
- const filePath = path.join(DEPLOYED_TOOLS_DIR, `${toolName}.json`);
252
- try {
253
- const raw = fs.readFileSync(filePath, 'utf-8');
254
- const data = JSON.parse(raw);
255
- return data.arguments ?? null;
256
- }
257
- catch {
258
- return null;
259
- }
260
- }
261
- function readLayer3ResolvedSchema(toolName) {
262
- const filePath = path.join(GENERATED_SCHEMAS_DIR, `${toolName}.schema.json`);
263
- try {
264
- const raw = fs.readFileSync(filePath, 'utf-8');
265
- const data = JSON.parse(raw);
266
- if (data.$ref && data.$ref.startsWith('#/definitions/')) {
267
- const defName = data.$ref.slice('#/definitions/'.length);
268
- const def = data.definitions?.[defName];
269
- if (def && typeof def === 'object') {
270
- return def;
271
- }
272
- }
273
- return data;
274
- }
275
- catch {
276
- return null;
277
- }
278
- }
279
- export function analyzeAnyUnknownCensus() {
280
- const instances = [];
281
- const scanDirs = [MCP_SRC_SCHEMA_DIR, MCP_SRC_TOOLS_DIR];
282
- for (const dir of scanDirs) {
283
- const files = listTypeScriptFiles(dir);
284
- for (const file of files) {
285
- const lines = fs.readFileSync(file, 'utf-8').split('\n');
286
- for (let i = 0; i < lines.length; i++) {
287
- const line = lines[i];
288
- const trimmed = line.trim();
289
- if (trimmed.startsWith('//') || trimmed.startsWith('*'))
290
- continue;
291
- const patterns = [
292
- { regex: /z\.any\(\)/g, pattern: 'z.any()' },
293
- { regex: /z\.unknown\(\)/g, pattern: 'z.unknown()' },
294
- { regex: /args\s*:\s*any\b/g, pattern: 'args: any' },
295
- { regex: /Promise\s*<\s*any\s*>/g, pattern: 'Promise<any>' },
296
- { regex: /Record\s*<\s*string\s*,\s*any\s*>/g, pattern: 'Record<string, any>' },
297
- { regex: /\bas\s+any\b/g, pattern: 'as any' },
298
- ];
299
- for (const { regex, pattern } of patterns) {
300
- regex.lastIndex = 0;
301
- let m;
302
- while ((m = regex.exec(line)) !== null) {
303
- const category = categorizeAnyInstance(file, i + 1, line, pattern);
304
- instances.push({
305
- file,
306
- line: i + 1,
307
- code: trimmed.length > 120 ? trimmed.slice(0, 117) + '...' : trimmed,
308
- pattern,
309
- category: category.category,
310
- reason: category.reason,
311
- fix_suggestion: category.fix,
312
- });
313
- }
314
- }
315
- }
316
- }
317
- }
318
- return instances;
319
- }
320
- function listTypeScriptFiles(dir) {
321
- const result = [];
322
- if (!fs.existsSync(dir))
323
- return result;
324
- const entries = fs.readdirSync(dir, { withFileTypes: true });
325
- for (const entry of entries) {
326
- const fullPath = path.join(dir, entry.name);
327
- if (entry.isDirectory()) {
328
- if (entry.name === '__tests__' || entry.name === 'node_modules')
329
- continue;
330
- result.push(...listTypeScriptFiles(fullPath));
331
- }
332
- else if (entry.isFile() && entry.name.endsWith('.ts')) {
333
- result.push(fullPath);
334
- }
335
- }
336
- return result;
337
- }
338
- function categorizeAnyInstance(file, lineNum, line, pattern) {
339
- const fileName = path.basename(file);
340
- const trimmed = line.trim();
341
- if (pattern === 'z.any()' && /SemanticSummarySchema\s*=\s*z\.any\(\)/.test(trimmed)) {
342
- return {
343
- category: 'fixable',
344
- reason: 'Circular-dependency workaround for SemanticSummarySchema — can use z.lazy() or refactor to break the cycle.',
345
- fix: 'Define SemanticSummarySchema with z.lazy(() => SemanticSummarySchemaReal) or restructure imports to break the cycle.',
346
- };
347
- }
348
- if (pattern === 'z.any()' && /result\s*:\s*z\.any\(\)/.test(trimmed) && /[\\/]config[\\/]|[\\/]project[\\/]/.test(file)) {
349
- return {
350
- category: 'fixable',
351
- reason: `Result shape depends on action — can use z.discriminatedUnion('action', [...]) to type each action's result.`,
352
- fix: `Define discriminated union: z.discriminatedUnion('action', [z.object({action: z.literal('list'), result: ...}), ...]).`,
353
- };
354
- }
355
- if (pattern === 'z.unknown()' && /result\s*:\s*z\.unknown\(\)/.test(trimmed) && /index\.ts/.test(fileName)) {
356
- return {
357
- category: 'fixable',
358
- reason: 'query_toolkit output result depends on query_type — can use z.discriminatedUnion(\'query_type\', [...]).',
359
- fix: 'Define discriminated union: z.discriminatedUnion(\'query_type\', [z.object({query_type: z.literal(\'local_mark_list\'), result: z.array(MarkDataSchema)}), ...]).',
360
- };
361
- }
362
- if (pattern === 'z.any()' && /data\s*:\s*z\.any\(\)/.test(trimmed) && /[\\/]schema-query[\\/]/.test(file)) {
363
- return {
364
- category: 'fixable',
365
- reason: 'SchemaQuery output data depends on action — can use discriminated union by action.',
366
- fix: 'Define discriminated union: action=\'get\' returns JSON Schema, action=\'list\' returns array of items.',
367
- };
368
- }
369
- if (pattern === 'args: any' && /handlers[\\/]/.test(file)) {
370
- return {
371
- category: 'fixable',
372
- reason: 'Handler args can use `unknown` (forces runtime validation) or a typed input schema.',
373
- fix: 'Replace `args: any` with `args: unknown` and use strictParse(schema, args) at the top of the handler.',
374
- };
375
- }
376
- if (pattern === 'args: any' && /tools[\\/]index\.ts/.test(file)) {
377
- return {
378
- category: 'fixable',
379
- reason: 'dispatchToolCall args is `any` — can be `unknown` since each tool parses with its own schema.',
380
- fix: 'Change `args: any` to `args: unknown` in dispatchToolCall signature.',
381
- };
382
- }
383
- if (pattern === 'args: any' && /types\.ts/.test(fileName) && /handler/.test(trimmed)) {
384
- return {
385
- category: 'fixable',
386
- reason: 'ToolEntry.handler args is `any` — can be `unknown` (each handler parses with its own schema).',
387
- fix: 'Change `handler: (args: any) => ...` to `handler: (args: unknown) => ...`.',
388
- };
389
- }
390
- if (pattern === 'z.any()' && /claimReceipt|ethReceipt|wowReceipt/.test(trimmed)) {
391
- return {
392
- category: 'legitimate',
393
- reason: 'EVM transaction receipts have an externally-defined shape from viem/ethers — z.any() is acceptable (receipt is informational, not validated).',
394
- };
395
- }
396
- if (pattern === 'z.any()' && /content_raw/.test(trimmed)) {
397
- return {
398
- category: 'legitimate',
399
- reason: 'content_raw holds raw content for unknown object types — by definition untyped. z.any() is acceptable here.',
400
- };
401
- }
402
- if ((pattern === 'z.unknown()' || pattern === 'z.any()') && /parsedJson/.test(trimmed)) {
403
- return {
404
- category: 'legitimate',
405
- reason: 'Event parsedJson is arbitrary on-chain event data — z.record(z.string(), z.unknown()) is appropriate.',
406
- };
407
- }
408
- if (pattern === 'z.any()' && /key_value/.test(trimmed)) {
409
- return {
410
- category: 'fixable',
411
- reason: 'Repository key_value depends on key_type — could use discriminated union by key_type (string→z.string(), u64→z.bigint()/number, etc.).',
412
- fix: 'Define z.discriminatedUnion(\'key_type\', [...]) with each variant typed.',
413
- };
414
- }
415
- if (pattern === 'z.unknown()' && /data\s*:\s*z\.unknown\(\)/.test(trimmed) && /[\\/]bridge/.test(file)) {
416
- return {
417
- category: 'legitimate',
418
- reason: 'Bridge operation result data varies by operation_type — currently 9 different shapes. Discriminated union would be ideal but high refactor cost.',
419
- };
420
- }
421
- if (pattern === 'z.unknown()' && /adjusted_params/.test(trimmed)) {
422
- return {
423
- category: 'legitimate',
424
- reason: 'adjusted_params are free-form key-value pairs suggested by AI — z.record(z.string(), z.unknown()) is appropriate.',
425
- };
426
- }
427
- if (pattern === 'z.any()' && /object\s*:\s*z\.union.*z\.record\(z\.any\(\)/.test(trimmed)) {
428
- return {
429
- category: 'fixable',
430
- reason: 'Creation vs reference object union — z.record(z.any()) should be replaced with NamedObjectSchema (structured creation input).',
431
- fix: 'Replace z.record(z.any()) with NamedObjectSchema (already defined in base.ts).',
432
- };
433
- }
434
- if (pattern === 'z.any()' && /result\s*:\s*z\.any\(\)\.optional\(\)/.test(trimmed) && /[\\/]bridge/.test(file)) {
435
- return {
436
- category: 'legitimate',
437
- reason: 'Bridge result is operation-specific (manage_evm_rpc has different result per operation) — z.any().optional() is acceptable here.',
438
- };
439
- }
440
- if (pattern === 'Promise<any>' && /[\\/](wrap|shared)\.ts/.test(file)) {
441
- return {
442
- category: 'fixable',
443
- reason: 'Generic wrappers in wrap.ts/shared.ts use Promise<any> — could be made generic <T>.',
444
- fix: 'Replace `Promise<any>` with `Promise<ToolDispatchResult>` (the actual return shape).',
445
- };
446
- }
447
- if (pattern === 'Record<string, any>' && /types\.ts/.test(fileName) && /_meta|structuredContent/.test(trimmed)) {
448
- return {
449
- category: 'fixable',
450
- reason: 'ToolConfig._meta and ToolDispatchResult.structuredContent could use structured types.',
451
- fix: 'Define ToolMeta interface (category, tags) and replace structuredContent: any with structured type.',
452
- };
453
- }
454
- if (pattern === 'as any') {
455
- return {
456
- category: 'legitimate',
457
- reason: '`as any` cast — usually for third-party type mismatches (MCP SDK). Acceptable if isolated.',
458
- };
459
- }
460
- return {
461
- category: 'legitimate',
462
- reason: 'Unclassified any/unknown usage — review manually. Defaulting to legitimate (no auto-fix).',
463
- };
464
- }
465
- export function analyzeHandlerTypeSafety(instances) {
466
- const findings = [];
467
- for (const inst of instances) {
468
- if (inst.pattern !== 'args: any')
469
- continue;
470
- if (!/tools[\\/]/.test(inst.file))
471
- continue;
472
- findings.push({
473
- rule_id: 'MCP-HANDLER-001',
474
- severity: 'medium',
475
- category: 'handler_types',
476
- tool_name: path.basename(inst.file, '.ts'),
477
- description: `Handler uses \`args: any\` — bypasses TypeScript type checking. ${inst.reason}`,
478
- location: `${inst.file}:${inst.line}`,
479
- fix: inst.fix_suggestion,
480
- });
481
- }
482
- return findings;
483
- }
484
- export function analyzeOutputSchemaCoverage(census) {
485
- const findings = [];
486
- for (const c of census) {
487
- if (!c.layer3_generated.output_exists && c.name !== "onchain_operations") {
488
- findings.push({
489
- rule_id: 'MCP-OUTPUT-001',
490
- severity: 'high',
491
- category: 'output_coverage',
492
- tool_name: c.name,
493
- description: `Layer 3 output schema file does not exist: ${c.layer3_generated.output_schema_file}`,
494
- fix: `Add outputSchema to ${c.name}'s tool definition and regenerate schemas.`,
495
- });
496
- }
497
- if (c.layer2_zod.output_schema_export === null) {
498
- findings.push({
499
- rule_id: 'MCP-OUTPUT-002',
500
- severity: 'medium',
501
- category: 'output_coverage',
502
- tool_name: c.name,
503
- description: `Layer 2 outputSchema is defined inline (not exported with a stable name). This makes it harder to reference from tests.`,
504
- fix: `Export the outputSchema with a stable name (e.g., ${c.name}OutputSchema).`,
505
- });
506
- }
507
- }
508
- return findings;
509
- }
510
- export function analyzeGenerationScriptSync() {
511
- const findings = [];
512
- if (!fs.existsSync(GENERATION_SCRIPT)) {
513
- findings.push({
514
- rule_id: 'MCP-GENSYNC-001',
515
- severity: 'critical',
516
- category: 'generation_sync',
517
- tool_name: '(all)',
518
- description: `Generation script not found: ${GENERATION_SCRIPT}`,
519
- });
520
- return findings;
521
- }
522
- const src = fs.readFileSync(GENERATION_SCRIPT, 'utf-8');
523
- const nameRegex = /name:\s*["']([^"']+)["']/g;
524
- const scriptNames = new Set();
525
- let m;
526
- while ((m = nameRegex.exec(src)) !== null) {
527
- if (TOOLS_17.some(t => t.name === m[1])) {
528
- scriptNames.add(m[1]);
529
- }
530
- }
531
- for (const tool of TOOLS_17) {
532
- if (!scriptNames.has(tool.name)) {
533
- findings.push({
534
- rule_id: 'MCP-GENSYNC-002',
535
- severity: 'high',
536
- category: 'generation_sync',
537
- tool_name: tool.name,
538
- description: `Tool "${tool.name}" is in TOOL_REGISTRY but missing from generate-json-schemas.ts. Layer 3 schemas will not be generated.`,
539
- location: GENERATION_SCRIPT,
540
- fix: `Add a get${toPascalCase(tool.name)}Tool() function and add it to the tools array.`,
541
- });
542
- }
543
- }
544
- return findings;
545
- }
546
- function toPascalCase(s) {
547
- return s.split('_').map(p => p.charAt(0).toUpperCase() + p.slice(1).toLowerCase()).join('');
548
- }
549
- export function analyzeSchemaQueryReflection(census) {
550
- const findings = [];
551
- for (const c of census) {
552
- if (!c.layer3_generated.input_exists) {
553
- findings.push({
554
- rule_id: 'MCP-REFLECT-001',
555
- severity: 'high',
556
- category: 'reflection',
557
- tool_name: c.name,
558
- description: `schema_query(action='get', name='${c.name}') would fail — Layer 3 input schema missing.`,
559
- fix: `Run pnpm generate:schemas.`,
560
- });
561
- }
562
- if (!c.layer3_generated.output_exists && c.name !== "onchain_operations") {
563
- findings.push({
564
- rule_id: 'MCP-REFLECT-002',
565
- severity: 'medium',
566
- category: 'reflection',
567
- tool_name: c.name,
568
- description: `schema_query(action='get_output', name='${c.name}') would fail — Layer 3 output schema missing.`,
569
- fix: `Run pnpm generate:schemas.`,
570
- });
571
- }
572
- }
573
- const onchainOps = [
574
- 'permission', 'service', 'machine', 'progress', 'guard',
575
- 'arbitration', 'repository', 'contact', 'treasury', 'reward',
576
- 'allocation', 'personal', 'payment', 'demand', 'order', 'gen_passport',
577
- 'proof', 'gen_proof',
578
- ];
579
- for (const op of onchainOps) {
580
- const opFile = path.join(GENERATED_SCHEMAS_DIR, `onchain_operations_${op}.schema.json`);
581
- if (!fs.existsSync(opFile)) {
582
- findings.push({
583
- rule_id: 'MCP-REFLECT-003',
584
- severity: 'medium',
585
- category: 'reflection',
586
- tool_name: `onchain_operations_${op}`,
587
- description: `Individual operation schema missing: ${opFile}. schema_query(action='get', name='onchain_operations_${op}') would fail.`,
588
- fix: `Run pnpm generate:schemas.`,
589
- });
590
- }
591
- }
592
- return findings;
593
- }
594
- export function scanAllMcpSchemas() {
595
- const census = analyzeLayerCensus();
596
- const anyInstances = analyzeAnyUnknownCensus();
597
- const findings = [
598
- ...analyzeDeployedStubInconsistency(census),
599
- ...analyzeLayerParity(census),
600
- ...analyzeHandlerTypeSafety(anyInstances),
601
- ...analyzeOutputSchemaCoverage(census),
602
- ...analyzeGenerationScriptSync(),
603
- ...analyzeSchemaQueryReflection(census),
604
- ];
605
- const bySev = new Map();
606
- const byCat = new Map();
607
- for (const f of findings) {
608
- if (!bySev.has(f.severity))
609
- bySev.set(f.severity, []);
610
- bySev.get(f.severity).push(f);
611
- if (!byCat.has(f.category))
612
- byCat.set(f.category, []);
613
- byCat.get(f.category).push(f);
614
- }
615
- const fixable = anyInstances.filter(i => i.category === 'fixable').length;
616
- const legit = anyInstances.filter(i => i.category === 'legitimate').length;
617
- const external = anyInstances.filter(i => i.category === 'external').length;
618
- const stubCount = census.filter(c => c.layer4_deployed.is_stub).length;
619
- const fullCount = census.filter(c => !c.layer4_deployed.is_stub && c.layer4_deployed.file_exists).length;
620
- return {
621
- census,
622
- findings,
623
- any_unknown_instances: anyInstances,
624
- findings_by_severity: bySev,
625
- findings_by_category: byCat,
626
- total_findings: findings.length,
627
- fixable_any_count: fixable,
628
- legitimate_any_count: legit,
629
- external_any_count: external,
630
- stub_count: stubCount,
631
- full_schema_count: fullCount,
632
- };
633
- }
634
- export function formatAuditReport(result) {
635
- const lines = [];
636
- lines.push(`# MCP Schema Audit Report — 17 WoWok Tools`);
637
- lines.push('');
638
- lines.push(`> Auto-generated by \`mcp-schema-audit.ts\` v${MCP_SCHEMA_AUDIT_VERSION} — comprehensive`);
639
- lines.push(`> 4-layer audit of schema consistency, any/unknown usage, and I/O coverage.`);
640
- lines.push('');
641
- lines.push(`## Summary`);
642
- lines.push('');
643
- lines.push(`- **Tools audited**: ${result.census.length}`);
644
- lines.push(`- **Total findings**: ${result.total_findings}`);
645
- lines.push(`- **Stub files**: ${result.stub_count} / ${result.census.length}`);
646
- lines.push(`- **Full schema files**: ${result.full_schema_count} / ${result.census.length}`);
647
- lines.push(`- **any/unknown instances**: ${result.any_unknown_instances.length} total`);
648
- lines.push(` - Fixable: ${result.fixable_any_count}`);
649
- lines.push(` - Legitimate: ${result.legitimate_any_count}`);
650
- lines.push(` - External: ${result.external_any_count}`);
651
- lines.push('');
652
- lines.push(`### Findings by Severity`);
653
- lines.push('');
654
- lines.push(`| Severity | Count |`);
655
- lines.push(`|----------|-------|`);
656
- for (const sev of ['critical', 'high', 'medium', 'low', 'info']) {
657
- const arr = result.findings_by_severity.get(sev) ?? [];
658
- lines.push(`| ${sev} | ${arr.length} |`);
659
- }
660
- lines.push('');
661
- lines.push(`### Findings by Category`);
662
- lines.push('');
663
- lines.push(`| Category | Count |`);
664
- lines.push(`|----------|-------|`);
665
- for (const cat of ['stub_inconsistency', 'layer_parity', 'handler_types', 'output_coverage', 'generation_sync', 'reflection']) {
666
- const arr = result.findings_by_category.get(cat) ?? [];
667
- lines.push(`| ${cat} | ${arr.length} |`);
668
- }
669
- lines.push('');
670
- lines.push(`## Layer Census — All 17 Tools`);
671
- lines.push('');
672
- lines.push(`| Tool | L3 Input | L3 Output | L4 Status | L4 Properties | L4 Required |`);
673
- lines.push(`|------|----------|-----------|-----------|---------------|-------------|`);
674
- for (const c of result.census) {
675
- const l3i = c.layer3_generated.input_exists ? `✓ ${(c.layer3_generated.input_size_bytes / 1024).toFixed(1)}KB` : '✗ MISSING';
676
- const l3o = c.layer3_generated.output_exists ? `✓ ${(c.layer3_generated.output_size_bytes / 1024).toFixed(1)}KB` : '✗ MISSING';
677
- const l4s = !c.layer4_deployed.file_exists ? '✗ MISSING' : c.layer4_deployed.is_stub ? '⚠ STUB' : '✓ FULL';
678
- const l4p = c.layer4_deployed.properties_count;
679
- const l4r = c.layer4_deployed.required_count;
680
- lines.push(`| ${c.name} | ${l3i} | ${l3o} | ${l4s} | ${l4p} | ${l4r} |`);
681
- }
682
- lines.push('');
683
- lines.push(`## Findings Detail`);
684
- lines.push('');
685
- const orderedSeverities = ['critical', 'high', 'medium', 'low', 'info'];
686
- for (const sev of orderedSeverities) {
687
- const sevFindings = result.findings_by_severity.get(sev) ?? [];
688
- if (sevFindings.length === 0)
689
- continue;
690
- const title = sev.toUpperCase();
691
- lines.push(`### ${title} (${sevFindings.length})`);
692
- lines.push('');
693
- for (const f of sevFindings) {
694
- lines.push(`- **[${f.rule_id}] ${f.description}`);
695
- if (f.location)
696
- lines.push(` - Location: \`${f.location}\``);
697
- if (f.fix)
698
- lines.push(` - Fix: ${f.fix}`);
699
- lines.push('');
700
- }
701
- }
702
- lines.push(`## any/unknown Census Detail`);
703
- lines.push('');
704
- lines.push(`Total instances: ${result.any_unknown_instances.length}`);
705
- lines.push('');
706
- lines.push(`### By Pattern`);
707
- lines.push('');
708
- lines.push(`| Pattern | Total | Fixable | Legitimate | External |`);
709
- lines.push(`|---------|-------|---------|------------|----------|`);
710
- const patternGroups = new Map();
711
- for (const inst of result.any_unknown_instances) {
712
- if (!patternGroups.has(inst.pattern))
713
- patternGroups.set(inst.pattern, []);
714
- patternGroups.get(inst.pattern).push(inst);
715
- }
716
- for (const [pattern, arr] of [...patternGroups.entries()].sort((a, b) => b[1].length - a[1].length)) {
717
- const fixable = arr.filter(i => i.category === 'fixable').length;
718
- const legit = arr.filter(i => i.category === 'legitimate').length;
719
- const ext = arr.filter(i => i.category === 'external').length;
720
- lines.push(`| \`${pattern}\` | ${arr.length} | ${fixable} | ${legit} | ${ext} |`);
721
- }
722
- lines.push('');
723
- const fixable = result.any_unknown_instances.filter(i => i.category === 'fixable');
724
- if (fixable.length > 0) {
725
- lines.push(`### Fixable Instances (Priority List)`);
726
- lines.push('');
727
- for (const inst of fixable) {
728
- lines.push(`- **${path.basename(inst.file)}:${inst.line}** [\`${inst.pattern}\`]`);
729
- lines.push(` - Code: \`${inst.code}\``);
730
- lines.push(` - Reason: ${inst.reason}`);
731
- if (inst.fix_suggestion)
732
- lines.push(` - Fix: ${inst.fix_suggestion}`);
733
- lines.push('');
734
- }
735
- }
736
- lines.push(`## Recommended Action Plan`);
737
- lines.push('');
738
- lines.push(`### Phase 1: Fix Layer 4 Stub Inconsistency (CRITICAL UX)`);
739
- lines.push('');
740
- lines.push(`The ${result.stub_count} stub files force the LLM to call \`schema_query\` first, creating an extra round-trip. Fix by regenerating all 17 Layer 4 files from Layer 3 schemas:`);
741
- lines.push('');
742
- lines.push(`\`\`\`bash`);
743
- lines.push(`# 1. Generate Layer 3 schemas from Zod source`);
744
- lines.push(`cd d:/wowok/agent/mcp && pnpm generate:schemas`);
745
- lines.push('');
746
- lines.push(`# 2. Generate Layer 4 deployed files from Layer 3`);
747
- lines.push(`# (Run the new sync-deployed-tools.ts script — see E2.4)`);
748
- lines.push(`npx tsx scripts/sync-deployed-tools.ts`);
749
- lines.push(`\`\`\``);
750
- lines.push('');
751
- lines.push(`### Phase 2: Type the ${result.fixable_any_count} fixable any/unknown instances`);
752
- lines.push('');
753
- lines.push(`Priority order:`);
754
- lines.push('');
755
- lines.push(`1. **SemanticSummarySchema** (src/schema/local/index.ts:6) — use \`z.lazy()\``);
756
- lines.push(`2. **ConfigOperationOutputSchema.result** (src/schema/config/index.ts:17) — discriminated union by action`);
757
- lines.push(`3. **ProjectOperationOutputSchema.result** (src/schema/project/index.ts:34) — discriminated union by action`);
758
- lines.push(`4. **query_toolkit output result** (src/tools/index.ts:250) — discriminated union by query_type`);
759
- lines.push(`5. **SchemaQueryOutputSchema.data** (src/schema/schema-query/index.ts:34) — discriminated union by action`);
760
- lines.push(`6. **RepositoryKeyValueSchema.key_value** (src/schema/operations.ts:331) — discriminated union by key_type`);
761
- lines.push(`7. **Handler args: any** — replace with \`unknown\` (forces strictParse at top of handler)`);
762
- lines.push(`8. **dispatchToolCall(name, args: any)** — replace with \`unknown\``);
763
- lines.push('');
764
- lines.push(`### Phase 3: Verify I/O Schema Match`);
765
- lines.push('');
766
- lines.push(`For each tool, write a parity test that:`);
767
- lines.push(`1. Calls the handler with a minimal valid input`);
768
- lines.push(`2. Captures the structuredContent`);
769
- lines.push(`3. Validates structuredContent against outputSchema`);
770
- lines.push(`4. Reports any mismatch`);
771
- lines.push('');
772
- return lines.join('\n');
773
- }
1
+ import*as a116a from'fs';import*as a116b from'path';export const DEPLOYED_TOOLS_DIR='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps\x5cs_wowok-7838e181\x5csolo_agent\x5cmcp_wagent\x5ctools';export const GENERATED_SCHEMAS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5cdist\x5cschemas';export const MCP_SRC_SCHEMA_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5cschema';export const MCP_SRC_TOOLS_DIR='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools';export const GENERATION_SCRIPT='d:\x5cwowok\x5cagent\x5cmcp\x5cscripts\x5cgenerate-json-schemas.ts';export const TOOLS_INDEX_FILE='d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cindex.ts';export const MCP_SCHEMA_AUDIT_VERSION='1.0.0';export const ALL_TOOLS=[{'name':'onchain_operations','input_schema_export':'OnchainOperationsSchema','output_schema_export':'CallOutputSchema'},{'name':'account_operation','input_schema_export':'AccountOperationSchema','output_schema_export':'AccountOperationOutputWrappedSchema'},{'name':'local_mark_operation','input_schema_export':'LocalMarkOperationSchema','output_schema_export':'LocalMarkOperationOutputWrappedSchema'},{'name':'local_info_operation','input_schema_export':'LocalInfoOperationSchema','output_schema_export':'LocalInfoOperationOutputWrappedSchema'},{'name':'wip_file','input_schema_export':'WipOperationsSchema','output_schema_export':'WipOperationOutputSchema'},{'name':'messenger_operation','input_schema_export':'MessengerOperationInputSchema','output_schema_export':'MessengerOperationOutputSchema'},{'name':'guard2file','input_schema_export':'Guard2File_InputSchema','output_schema_export':'Guard2File_OutputWrappedSchema'},{'name':'machineNode2file','input_schema_export':'MachineNode2File_InputSchema','output_schema_export':'MachineNode2File_OutputWrappedSchema'},{'name':'query_toolkit','input_schema_export':'WatchQueryOperationsSchema','output_schema_export':'WatchQueryOperationsResultSchema'},{'name':'onchain_table_data','input_schema_export':'OnchainTableDataSchema','output_schema_export':'OnchainTableDataResultSchema'},{'name':'onchain_events','input_schema_export':'OnchainEventsInputSchema','output_schema_export':'OnchainEventsResultSchema'},{'name':'wowok_buildin_info','input_schema_export':'ProtocolInfoQuerySchema','output_schema_export':'ProtocolInfoResultSchema'},{'name':'schema_query','input_schema_export':'SchemaQueryInputSchema','output_schema_export':'SchemaQueryOutputSchema'},{'name':'bridge_operation','input_schema_export':'BridgeOperationsSchema','output_schema_export':'BridgeCallOutputSchema'},{'name':'project_operation','input_schema_export':'ProjectOperationInputSchema','output_schema_export':'ProjectOperationOutputSchema'},{'name':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'name':'query_task_status','input_schema_export':'QueryTaskStatusInputSchema','output_schema_export':'QueryTaskStatusOutputSchema'},{'name':'evaluation_operation','input_schema_export':'EvaluationOperationInputSchema','output_schema_export':'EvaluationOperationOutputSchema'},{'name':'persona_operation','input_schema_export':'PersonaOperationInputSchema','output_schema_export':'PersonaOperationOutputSchema'},{'name':'intent_radar','input_schema_export':'IntentRadarInputSchema','output_schema_export':'IntentRadarOutputSchema'}];export function loadLayer4Deployed(a){const b=a116b['join'](DEPLOYED_TOOLS_DIR,a+'.json'),c={'tool_descriptor_file':b,'file_exists':![],'is_stub':!![],'properties_count':0x0,'required_count':0x0,'has_schema_hint':![],'has_additional_properties_false':![],'has_dollar_schema':![],'has_oneof':![],'has_anyof':![],'has_allof':![],'union_count':0x0};if(!a116a['existsSync'](b))return c;try{const d=a116a['readFileSync'](b,'utf-8'),e=JSON['parse'](d),f=e['arguments']??{},g=f['properties']??{},h=f['required']??[],i=Object['keys'](g),j=f['oneOf']??[],k=f['anyOf']??[],l=f['allOf']??[],m=j['length']>0x0,n=k['length']>0x0,o=l['length']>0x0,p=j['length']+k['length']+l['length'],q=i['length']===0x0&&p===0x0,r=e['description']??'',s=r['includes']('schema_query');return{'tool_descriptor_file':b,'file_exists':!![],'is_stub':q,'properties_count':i['length'],'required_count':h['length'],'has_schema_hint':s,'has_additional_properties_false':f['additionalProperties']===![],'has_dollar_schema':!!f['$schema'],'has_oneof':m,'has_anyof':n,'has_allof':o,'union_count':p};}catch{return c;}}export function loadLayer3Generated(a){const b=a116b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a116b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a116a['existsSync'](b),e=a116a['existsSync'](c),f=d?a116a['statSync'](b)['size']:0x0,g=e?a116a['statSync'](c)['size']:0x0;return{'input_schema_file':b,'output_schema_file':c,'input_exists':d,'output_exists':e,'input_size_bytes':f,'output_size_bytes':g};}export function analyzeLayerCensus(){const a=[];for(const b of ALL_TOOLS){a['push']({'name':b['name'],'layer2_zod':{'input_schema_export':b['input_schema_export'],'output_schema_export':b['output_schema_export'],'schema_dir':MCP_SRC_SCHEMA_DIR},'layer3_generated':loadLayer3Generated(b['name']),'layer4_deployed':loadLayer4Deployed(b['name'])??{}});}return a;}export function analyzeDeployedStubInconsistency(a){const b=[],d=[],e=[];for(const f of a){if(!f['layer4_deployed']['file_exists']){b['push']({'rule_id':'MCP-DEPLOY-001','severity':'critical','category':'stub_inconsistency','tool_name':f['name'],'description':'Layer\x204\x20deployed\x20file\x20does\x20not\x20exist:\x20'+f['layer4_deployed']['tool_descriptor_file'],'location':f['layer4_deployed']['tool_descriptor_file'],'fix':'Create\x20'+f['name']+'.json\x20in\x20DEPLOYED_TOOLS_DIR\x20matching\x20the\x20Layer\x203\x20generated\x20schema.'});continue;}f['layer4_deployed']['is_stub']?d['push'](f):e['push'](f);}for(const g of d){b['push']({'rule_id':'MCP-STUB-001','severity':'high','category':'stub_inconsistency','tool_name':g['name'],'description':'Layer\x204\x20deployed\x20file\x20is\x20a\x20STUB\x20(empty\x20properties:{})\x20—\x20LLM\x20must\x20call\x20schema_query(action=\x27get\x27,\x20name=\x27'+g['name']+'\x27)\x20to\x20learn\x20the\x20parameter\x20structure.\x20This\x20is\x20inconsistent\x20with\x20the\x20'+e['length']+'\x20tools\x20that\x20embed\x20full\x20schemas.','location':g['layer4_deployed']['tool_descriptor_file'],'fix':'Regenerate\x20'+g['name']+'.json\x20from\x20dist/schemas/'+g['name']+'.schema.json\x20(resolve\x20$ref,\x20inline\x20definitions,\x20wrap\x20as\x20{name,\x20description,\x20arguments}).'}),!g['layer4_deployed']['has_schema_hint']&&b['push']({'rule_id':'MCP-STUB-003','severity':'high','category':'stub_inconsistency','tool_name':g['name'],'description':'Stub\x20file\x20is\x20missing\x20schema_query\x20hint\x20in\x20description\x20—\x20the\x20LLM\x20has\x20no\x20way\x20to\x20discover\x20the\x20parameter\x20structure.\x20Description\x20should\x20mention\x20schema_query(action=\x27get\x27,\x20name=\x27'+g['name']+'\x27).','location':g['layer4_deployed']['tool_descriptor_file'],'fix':'Add\x20\x22💡\x20Schema\x20hint:\x20Use\x20schema_query\x20with\x20action=\x27get\x27\x20and\x20name=\x27'+g['name']+'\x27\x20to\x20retrieve\x20the\x20exact\x20parameter\x20schema\x20before\x20calling.\x22\x20to\x20the\x20description.'});}return d['length']>0x0&&e['length']>0x0&&b['push']({'rule_id':'MCP-STUB-002','severity':'info','category':'stub_inconsistency','tool_name':'(all)','description':'Layer\x204\x20deployed\x20files\x20are\x20INCONSISTENT:\x20'+d['length']+'\x20stubs\x20+\x20'+e['length']+'\x20full\x20schemas.\x20Stubs:\x20'+d['map'](h=>h['name'])['join'](',\x20')+'.\x20Full:\x20'+e['map'](h=>h['name'])['join'](',\x20')+'.','fix':'Make\x20all\x2017\x20files\x20consistent\x20—\x20either\x20(a)\x20embed\x20full\x20schemas\x20in\x20all\x2017\x20(RECOMMENDED\x20—\x20gives\x20LLM\x20immediate\x20access),\x20or\x20(b)\x20keep\x20all\x20stubs\x20and\x20rely\x20on\x20schema_query\x20(increases\x20token\x20cost\x20+\x20latency).'}),b;}export function analyzeLayerParity(a){const b=[];for(const d of a){if(!d['layer4_deployed']['file_exists']||d['layer4_deployed']['is_stub'])continue;if(!d['layer3_generated']['input_exists']){b['push']({'rule_id':'MCP-PARITY-001','severity':'critical','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20has\x20full\x20schema\x20but\x20Layer\x203\x20generated\x20file\x20is\x20missing:\x20'+d['layer3_generated']['input_schema_file'],'fix':'Run\x20pnpm\x20generate:schemas\x20to\x20regenerate\x20Layer\x203\x20from\x20Zod\x20source.'});continue;}const e=readLayer4Arguments(d['name']),f=readLayer3ResolvedSchema(d['name']);if(!e||!f)continue;const g=new Set(Object['keys'](e['properties']??{})),h=new Set(Object['keys'](f['properties']??{})),i=[...h]['filter'](q=>!g['has'](q)),j=[...g]['filter'](q=>!h['has'](q));i['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-002','severity':'high','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20deployed\x20schema\x20is\x20missing\x20'+i['length']+'\x20properties\x20present\x20in\x20Layer\x203\x20generated\x20schema:\x20'+i['join'](',\x20'),'location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Regenerate\x20'+d['name']+'.json\x20from\x20dist/schemas/'+d['name']+'.schema.json.'});j['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-003','severity':'medium','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20deployed\x20schema\x20has\x20'+j['length']+'\x20extra\x20properties\x20not\x20in\x20Layer\x203:\x20'+j['join'](',\x20'),'location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Regenerate\x20'+d['name']+'.json\x20from\x20dist/schemas/'+d['name']+'.schema.json.'});const k=new Set(e['required']??[]),l=new Set(f['required']??[]),m=[...l]['filter'](q=>!k['has'](q)),n=[...k]['filter'](q=>!l['has'](q));(m['length']>0x0||n['length']>0x0)&&b['push']({'rule_id':'MCP-PARITY-004','severity':'high','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20\x27required\x27\x20array\x20differs\x20from\x20Layer\x203.\x20Missing\x20in\x20L4:\x20['+m['join'](',\x20')+'].\x20Extra\x20in\x20L4:\x20['+n['join'](',\x20')+'].','location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Sync\x20\x27required\x27\x20array\x20from\x20Layer\x203\x20to\x20Layer\x204.'});const o=e['additionalProperties'],p=f['additionalProperties'];o!==p&&b['push']({'rule_id':'MCP-PARITY-005','severity':'medium','category':'layer_parity','tool_name':d['name'],'description':'Layer\x204\x20\x27additionalProperties\x27\x20('+JSON['stringify'](o)+')\x20differs\x20from\x20Layer\x203\x20('+JSON['stringify'](p)+').','location':d['layer4_deployed']['tool_descriptor_file'],'fix':'Sync\x20\x27additionalProperties\x27\x20value.'});}return b;}function readLayer4Arguments(a){const b=a116b['join'](DEPLOYED_TOOLS_DIR,a+'.json');try{const c=a116a['readFileSync'](b,'utf-8'),d=JSON['parse'](c);return d['arguments']??null;}catch{return null;}}function readLayer3ResolvedSchema(a){const b=a116b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json');try{const c=a116a['readFileSync'](b,'utf-8'),d=JSON['parse'](c);if(d['$ref']&&d['$ref']['startsWith']('#/definitions/')){const e=d['$ref']['slice']('#/definitions/'['length']),f=d['definitions']?.[e];if(f&&typeof f==='object')return f;}return d;}catch{return null;}}export function analyzeAnyUnknownCensus(){const a=[],b=[MCP_SRC_SCHEMA_DIR,MCP_SRC_TOOLS_DIR];for(const c of b){const d=listTypeScriptFiles(c);for(const e of d){const f=a116a['readFileSync'](e,'utf-8')['split']('\x0a');for(let g=0x0;g<f['length'];g++){const h=f[g],j=h['trim']();if(j['startsWith']('//')||j['startsWith']('*'))continue;const k=[{'regex':/z\.any\(\)/g,'pattern':'z.any()'},{'regex':/z\.unknown\(\)/g,'pattern':'z.unknown()'},{'regex':/args\s*:\s*any\b/g,'pattern':'args:\x20any'},{'regex':/Promise\s*<\s*any\s*>/g,'pattern':'Promise<any>'},{'regex':/Record\s*<\s*string\s*,\s*any\s*>/g,'pattern':'Record<string,\x20any>'},{'regex':/\bas\s+any\b/g,'pattern':'as\x20any'}];for(const {regex:l,pattern:n}of k){l['lastIndex']=0x0;let o;while((o=l['exec'](h))!==null){const p=categorizeAnyInstance(e,g+0x1,h,n);a['push']({'file':e,'line':g+0x1,'code':j['length']>0x78?j['slice'](0x0,0x75)+'...':j,'pattern':n,'category':p['category'],'reason':p['reason'],'fix_suggestion':p['fix']});}}}}}return a;}function listTypeScriptFiles(a){const b=[];if(!a116a['existsSync'](a))return b;const c=a116a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a116b['join'](a,d['name']);if(d['isDirectory']()){if(d['name']==='__tests__'||d['name']==='node_modules')continue;b['push'](...listTypeScriptFiles(e));}else d['isFile']()&&d['name']['endsWith']('.ts')&&b['push'](e);}return b;}function categorizeAnyInstance(a,b,c,d){const e=a116b['basename'](a),f=c['trim']();if(d==='z.any()'&&/SemanticSummarySchema\s*=\s*z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Circular-dependency\x20workaround\x20for\x20SemanticSummarySchema\x20—\x20can\x20use\x20z.lazy()\x20or\x20refactor\x20to\x20break\x20the\x20cycle.','fix':'Define\x20SemanticSummarySchema\x20with\x20z.lazy(()\x20=>\x20SemanticSummarySchemaReal)\x20or\x20restructure\x20imports\x20to\x20break\x20the\x20cycle.'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]config[\\/]|[\\/]project[\\/]/['test'](a))return{'category':'fixable','reason':'Result\x20shape\x20depends\x20on\x20action\x20—\x20can\x20use\x20z.discriminatedUnion(\x27action\x27,\x20[...])\x20to\x20type\x20each\x20action\x27s\x20result.','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27action\x27,\x20[z.object({action:\x20z.literal(\x27list\x27),\x20result:\x20...}),\x20...]).'};if(d==='z.unknown()'&&/result\s*:\s*z\.unknown\(\)/['test'](f)&&/index\.ts/['test'](e))return{'category':'fixable','reason':'query_toolkit\x20output\x20result\x20depends\x20on\x20query_type\x20—\x20can\x20use\x20z.discriminatedUnion(\x27query_type\x27,\x20[...]).','fix':'Define\x20discriminated\x20union:\x20z.discriminatedUnion(\x27query_type\x27,\x20[z.object({query_type:\x20z.literal(\x27local_mark_list\x27),\x20result:\x20z.array(MarkDataSchema)}),\x20...]).'};if(d==='z.any()'&&/data\s*:\s*z\.any\(\)/['test'](f)&&/[\\/]schema-query[\\/]/['test'](a))return{'category':'fixable','reason':'SchemaQuery\x20output\x20data\x20depends\x20on\x20action\x20—\x20can\x20use\x20discriminated\x20union\x20by\x20action.','fix':'Define\x20discriminated\x20union:\x20action=\x27get\x27\x20returns\x20JSON\x20Schema,\x20action=\x27list\x27\x20returns\x20array\x20of\x20items.'};if(d==='args:\x20any'&&/handlers[\\/]/['test'](a))return{'category':'fixable','reason':'Handler\x20args\x20can\x20use\x20`unknown`\x20(forces\x20runtime\x20validation)\x20or\x20a\x20typed\x20input\x20schema.','fix':'Replace\x20`args:\x20any`\x20with\x20`args:\x20unknown`\x20and\x20use\x20strictParse(schema,\x20args)\x20at\x20the\x20top\x20of\x20the\x20handler.'};if(d==='args:\x20any'&&/tools[\\/]index\.ts/['test'](a))return{'category':'fixable','reason':'dispatchToolCall\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20since\x20each\x20tool\x20parses\x20with\x20its\x20own\x20schema.','fix':'Change\x20`args:\x20any`\x20to\x20`args:\x20unknown`\x20in\x20dispatchToolCall\x20signature.'};if(d==='args:\x20any'&&/types\.ts/['test'](e)&&/handler/['test'](f))return{'category':'fixable','reason':'ToolEntry.handler\x20args\x20is\x20`any`\x20—\x20can\x20be\x20`unknown`\x20(each\x20handler\x20parses\x20with\x20its\x20own\x20schema).','fix':'Change\x20`handler:\x20(args:\x20any)\x20=>\x20...`\x20to\x20`handler:\x20(args:\x20unknown)\x20=>\x20...`.'};if(d==='z.any()'&&/claimReceipt|ethReceipt|wowReceipt/['test'](f))return{'category':'legitimate','reason':'EVM\x20transaction\x20receipts\x20have\x20an\x20externally-defined\x20shape\x20from\x20viem/ethers\x20—\x20z.any()\x20is\x20acceptable\x20(receipt\x20is\x20informational,\x20not\x20validated).'};if(d==='z.any()'&&/content_raw/['test'](f))return{'category':'legitimate','reason':'content_raw\x20holds\x20raw\x20content\x20for\x20unknown\x20object\x20types\x20—\x20by\x20definition\x20untyped.\x20z.any()\x20is\x20acceptable\x20here.'};if((d==='z.unknown()'||d==='z.any()')&&/parsedJson/['test'](f))return{'category':'legitimate','reason':'Event\x20parsedJson\x20is\x20arbitrary\x20on-chain\x20event\x20data\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/key_value/['test'](f))return{'category':'fixable','reason':'Repository\x20key_value\x20depends\x20on\x20key_type\x20—\x20could\x20use\x20discriminated\x20union\x20by\x20key_type\x20(string→z.string(),\x20u64→z.bigint()/number,\x20etc.).','fix':'Define\x20z.discriminatedUnion(\x27key_type\x27,\x20[...])\x20with\x20each\x20variant\x20typed.'};if(d==='z.unknown()'&&/data\s*:\s*z\.unknown\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20operation\x20result\x20data\x20varies\x20by\x20operation_type\x20—\x20currently\x209\x20different\x20shapes.\x20Discriminated\x20union\x20would\x20be\x20ideal\x20but\x20high\x20refactor\x20cost.'};if(d==='z.unknown()'&&/adjusted_params/['test'](f))return{'category':'legitimate','reason':'adjusted_params\x20are\x20free-form\x20key-value\x20pairs\x20suggested\x20by\x20AI\x20—\x20z.record(z.string(),\x20z.unknown())\x20is\x20appropriate.'};if(d==='z.any()'&&/object\s*:\s*z\.union.*z\.record\(z\.any\(\)/['test'](f))return{'category':'fixable','reason':'Creation\x20vs\x20reference\x20object\x20union\x20—\x20z.record(z.any())\x20should\x20be\x20replaced\x20with\x20NamedObjectSchema\x20(structured\x20creation\x20input).','fix':'Replace\x20z.record(z.any())\x20with\x20NamedObjectSchema\x20(already\x20defined\x20in\x20base.ts).'};if(d==='z.any()'&&/result\s*:\s*z\.any\(\)\.optional\(\)/['test'](f)&&/[\\/]bridge/['test'](a))return{'category':'legitimate','reason':'Bridge\x20result\x20is\x20operation-specific\x20(manage_evm_rpc\x20has\x20different\x20result\x20per\x20operation)\x20—\x20z.any().optional()\x20is\x20acceptable\x20here.'};if(d==='Promise<any>'&&/[\\/](wrap|shared)\.ts/['test'](a))return{'category':'fixable','reason':'Generic\x20wrappers\x20in\x20wrap.ts/shared.ts\x20use\x20Promise<any>\x20—\x20could\x20be\x20made\x20generic\x20<T>.','fix':'Replace\x20`Promise<any>`\x20with\x20`Promise<ToolDispatchResult>`\x20(the\x20actual\x20return\x20shape).'};if(d==='Record<string,\x20any>'&&/types\.ts/['test'](e)&&/_meta|structuredContent/['test'](f))return{'category':'fixable','reason':'ToolConfig._meta\x20and\x20ToolDispatchResult.structuredContent\x20could\x20use\x20structured\x20types.','fix':'Define\x20ToolMeta\x20interface\x20(category,\x20tags)\x20and\x20replace\x20structuredContent:\x20any\x20with\x20structured\x20type.'};if(d==='as\x20any')return{'category':'legitimate','reason':'`as\x20any`\x20cast\x20—\x20usually\x20for\x20third-party\x20type\x20mismatches\x20(MCP\x20SDK).\x20Acceptable\x20if\x20isolated.'};return{'category':'legitimate','reason':'Unclassified\x20any/unknown\x20usage\x20—\x20review\x20manually.\x20Defaulting\x20to\x20legitimate\x20(no\x20auto-fix).'};}export function analyzeHandlerTypeSafety(a){const b=[];for(const c of a){if(c['pattern']!=='args:\x20any')continue;if(!/tools[\\/]/['test'](c['file']))continue;b['push']({'rule_id':'MCP-HANDLER-001','severity':'medium','category':'handler_types','tool_name':a116b['basename'](c['file'],'.ts'),'description':'Handler\x20uses\x20`args:\x20any`\x20—\x20bypasses\x20TypeScript\x20type\x20checking.\x20'+c['reason'],'location':c['file']+':'+c['line'],'fix':c['fix_suggestion']});}return b;}export function analyzeOutputSchemaCoverage(a){const b=[];for(const d of a){!d['layer3_generated']['output_exists']&&d['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-OUTPUT-001','severity':'high','category':'output_coverage','tool_name':d['name'],'description':'Layer\x203\x20output\x20schema\x20file\x20does\x20not\x20exist:\x20'+d['layer3_generated']['output_schema_file'],'fix':'Add\x20outputSchema\x20to\x20'+d['name']+'\x27s\x20tool\x20definition\x20and\x20regenerate\x20schemas.'}),d['layer2_zod']['output_schema_export']===null&&b['push']({'rule_id':'MCP-OUTPUT-002','severity':'medium','category':'output_coverage','tool_name':d['name'],'description':'Layer\x202\x20outputSchema\x20is\x20defined\x20inline\x20(not\x20exported\x20with\x20a\x20stable\x20name).\x20This\x20makes\x20it\x20harder\x20to\x20reference\x20from\x20tests.','fix':'Export\x20the\x20outputSchema\x20with\x20a\x20stable\x20name\x20(e.g.,\x20'+d['name']+'OutputSchema).'});}return b;}export function analyzeGenerationScriptSync(){const a=[];if(!a116a['existsSync'](GENERATION_SCRIPT))return a['push']({'rule_id':'MCP-GENSYNC-001','severity':'critical','category':'generation_sync','tool_name':'(all)','description':'Generation\x20script\x20not\x20found:\x20'+GENERATION_SCRIPT}),a;const b=a116a['readFileSync'](GENERATION_SCRIPT,'utf-8'),c=/name:\s*["']([^"']+)["']/g,d=new Set();let e;while((e=c['exec'](b))!==null){ALL_TOOLS['some'](f=>f['name']===e[0x1])&&d['add'](e[0x1]);}for(const f of ALL_TOOLS){!d['has'](f['name'])&&a['push']({'rule_id':'MCP-GENSYNC-002','severity':'high','category':'generation_sync','tool_name':f['name'],'description':'Tool\x20\x22'+f['name']+'\x22\x20is\x20in\x20TOOL_REGISTRY\x20but\x20missing\x20from\x20generate-json-schemas.ts.\x20Layer\x203\x20schemas\x20will\x20not\x20be\x20generated.','location':GENERATION_SCRIPT,'fix':'Add\x20a\x20get'+toPascalCase(f['name'])+'Tool()\x20function\x20and\x20add\x20it\x20to\x20the\x20tools\x20array.'});}return a;}function toPascalCase(a){return a['split']('_')['map'](b=>b['charAt'](0x0)['toUpperCase']()+b['slice'](0x1)['toLowerCase']())['join']('');}export function analyzeSchemaQueryReflection(a){const b=[];for(const e of a){!e['layer3_generated']['input_exists']&&b['push']({'rule_id':'MCP-REFLECT-001','severity':'high','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20input\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'}),!e['layer3_generated']['output_exists']&&e['name']!=='onchain_operations'&&b['push']({'rule_id':'MCP-REFLECT-002','severity':'medium','category':'reflection','tool_name':e['name'],'description':'schema_query(action=\x27get_output\x27,\x20name=\x27'+e['name']+'\x27)\x20would\x20fail\x20—\x20Layer\x203\x20output\x20schema\x20missing.','fix':'Run\x20pnpm\x20generate:schemas.'});}const d=['permission','service','machine','progress','guard','arbitration','repository','contact','treasury','reward','allocation','personal','payment','demand','order','gen_passport','proof','gen_proof'];for(const f of d){const g=a116b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a116a['existsSync'](g)&&b['push']({'rule_id':'MCP-REFLECT-003','severity':'medium','category':'reflection','tool_name':'onchain_operations_'+f,'description':'Individual\x20operation\x20schema\x20missing:\x20'+g+'.\x20schema_query(action=\x27get\x27,\x20name=\x27onchain_operations_'+f+'\x27)\x20would\x20fail.','fix':'Run\x20pnpm\x20generate:schemas.'});}return b;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=analyzeAnyUnknownCensus(),c=[...analyzeDeployedStubInconsistency(a),...analyzeLayerParity(a),...analyzeHandlerTypeSafety(b),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a)],d=new Map(),e=new Map();for(const l of c){if(!d['has'](l['severity']))d['set'](l['severity'],[]);d['get'](l['severity'])['push'](l);if(!e['has'](l['category']))e['set'](l['category'],[]);e['get'](l['category'])['push'](l);}const g=b['filter'](m=>m['category']==='fixable')['length'],h=b['filter'](m=>m['category']==='legitimate')['length'],i=b['filter'](m=>m['category']==='external')['length'],j=a['filter'](m=>m['layer4_deployed']['is_stub'])['length'],k=a['filter'](m=>!m['layer4_deployed']['is_stub']&&m['layer4_deployed']['file_exists'])['length'];return{'census':a,'findings':c,'any_unknown_instances':b,'findings_by_severity':d,'findings_by_category':e,'total_findings':c['length'],'fixable_any_count':g,'legitimate_any_count':h,'external_any_count':i,'stub_count':j,'full_schema_count':k};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x2017\x20WoWok\x20Tools'),b['push'](''),b['push']('>\x20Auto-generated\x20by\x20`mcp-schema-audit.ts`\x20v'+MCP_SCHEMA_AUDIT_VERSION+'\x20—\x20comprehensive'),b['push']('>\x204-layer\x20audit\x20of\x20schema\x20consistency,\x20any/unknown\x20usage,\x20and\x20I/O\x20coverage.'),b['push'](''),b['push']('##\x20Summary'),b['push'](''),b['push']('-\x20**Tools\x20audited**:\x20'+a['census']['length']),b['push']('-\x20**Total\x20findings**:\x20'+a['total_findings']),b['push']('-\x20**Stub\x20files**:\x20'+a['stub_count']+'\x20/\x20'+a['census']['length']),b['push']('-\x20**Full\x20schema\x20files**:\x20'+a['full_schema_count']+'\x20/\x20'+a['census']['length']),b['push']('-\x20**any/unknown\x20instances**:\x20'+a['any_unknown_instances']['length']+'\x20total'),b['push']('\x20\x20-\x20Fixable:\x20'+a['fixable_any_count']),b['push']('\x20\x20-\x20Legitimate:\x20'+a['legitimate_any_count']),b['push']('\x20\x20-\x20External:\x20'+a['external_any_count']),b['push'](''),b['push']('###\x20Findings\x20by\x20Severity'),b['push'](''),b['push']('|\x20Severity\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const h of['critical','high','medium','low','info']){const i=a['findings_by_severity']['get'](h)??[];b['push']('|\x20'+h+'\x20|\x20'+i['length']+'\x20|');}b['push'](''),b['push']('###\x20Findings\x20by\x20Category'),b['push'](''),b['push']('|\x20Category\x20|\x20Count\x20|'),b['push']('|----------|-------|');for(const j of['stub_inconsistency','layer_parity','handler_types','output_coverage','generation_sync','reflection']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x2017\x20Tools'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\x20|\x20L4\x20Status\x20|\x20L4\x20Properties\x20|\x20L4\x20Required\x20|'),b['push']('|------|----------|-----------|-----------|---------------|-------------|');for(const l of a['census']){const m=l['layer3_generated']['input_exists']?'✓\x20'+(l['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',n=l['layer3_generated']['output_exists']?'✓\x20'+(l['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'✗\x20MISSING',o=!l['layer4_deployed']['file_exists']?'✗\x20MISSING':l['layer4_deployed']['is_stub']?'⚠\x20STUB':'✓\x20FULL',p=l['layer4_deployed']['properties_count'],q=l['layer4_deployed']['required_count'];b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|\x20'+o+'\x20|\x20'+p+'\x20|\x20'+q+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const r of d){const s=a['findings_by_severity']['get'](r)??[];if(s['length']===0x0)continue;const t=r['toUpperCase']();b['push']('###\x20'+t+'\x20('+s['length']+')'),b['push']('');for(const u of s){b['push']('-\x20**['+u['rule_id']+']\x20'+u['description']);if(u['location'])b['push']('\x20\x20-\x20Location:\x20`'+u['location']+'`');if(u['fix'])b['push']('\x20\x20-\x20Fix:\x20'+u['fix']);b['push']('');}}b['push']('##\x20any/unknown\x20Census\x20Detail'),b['push'](''),b['push']('Total\x20instances:\x20'+a['any_unknown_instances']['length']),b['push'](''),b['push']('###\x20By\x20Pattern'),b['push'](''),b['push']('|\x20Pattern\x20|\x20Total\x20|\x20Fixable\x20|\x20Legitimate\x20|\x20External\x20|'),b['push']('|---------|-------|---------|------------|----------|');const e=new Map();for(const v of a['any_unknown_instances']){if(!e['has'](v['pattern']))e['set'](v['pattern'],[]);e['get'](v['pattern'])['push'](v);}for(const [w,x]of[...e['entries']()]['sort']((y,z)=>z[0x1]['length']-y[0x1]['length'])){const y=x['filter'](B=>B['category']==='fixable')['length'],z=x['filter'](B=>B['category']==='legitimate')['length'],A=x['filter'](B=>B['category']==='external')['length'];b['push']('|\x20`'+w+'`\x20|\x20'+x['length']+'\x20|\x20'+y+'\x20|\x20'+z+'\x20|\x20'+A+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](B=>B['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const B of g){b['push']('-\x20**'+a116b['basename'](B['file'])+':'+B['line']+'**\x20[`'+B['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+B['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+B['reason']);if(B['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+B['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Fix\x20Layer\x204\x20Stub\x20Inconsistency\x20(CRITICAL\x20UX)'),b['push'](''),b['push']('The\x20'+a['stub_count']+'\x20stub\x20files\x20force\x20the\x20LLM\x20to\x20call\x20`schema_query`\x20first,\x20creating\x20an\x20extra\x20round-trip.\x20Fix\x20by\x20regenerating\x20all\x2017\x20Layer\x204\x20files\x20from\x20Layer\x203\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('#\x201.\x20Generate\x20Layer\x203\x20schemas\x20from\x20Zod\x20source'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),b['push'](''),b['push']('#\x202.\x20Generate\x20Layer\x204\x20deployed\x20files\x20from\x20Layer\x203'),b['push']('#\x20(Run\x20the\x20new\x20sync-deployed-tools.ts\x20script\x20—\x20see\x20E2.4)'),b['push']('npx\x20tsx\x20scripts/sync-deployed-tools.ts'),b['push']('```'),b['push'](''),b['push']('###\x20Phase\x202:\x20Type\x20the\x20'+a['fixable_any_count']+'\x20fixable\x20any/unknown\x20instances'),b['push'](''),b['push']('Priority\x20order:'),b['push'](''),b['push']('1.\x20**SemanticSummarySchema**\x20(src/schema/local/index.ts:6)\x20—\x20use\x20`z.lazy()`'),b['push']('2.\x20**ConfigOperationOutputSchema.result**\x20(src/schema/config/index.ts:17)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('3.\x20**ProjectOperationOutputSchema.result**\x20(src/schema/project/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('4.\x20**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('5.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('6.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('7.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('8.\x20**dispatchToolCall(name,\x20args:\x20any)**\x20—\x20replace\x20with\x20`unknown`'),b['push'](''),b['push']('###\x20Phase\x203:\x20Verify\x20I/O\x20Schema\x20Match'),b['push'](''),b['push']('For\x20each\x20tool,\x20write\x20a\x20parity\x20test\x20that:'),b['push']('1.\x20Calls\x20the\x20handler\x20with\x20a\x20minimal\x20valid\x20input'),b['push']('2.\x20Captures\x20the\x20structuredContent'),b['push']('3.\x20Validates\x20structuredContent\x20against\x20outputSchema'),b['push']('4.\x20Reports\x20any\x20mismatch'),b['push'](''),b['join']('\x0a');}