@wowok/agent-mcp 2.7.1 → 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 (375) 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.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,777 +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 ALL_TOOLS = [
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
- { name: 'query_task_status', input_schema_export: 'QueryTaskStatusInputSchema', output_schema_export: 'QueryTaskStatusOutputSchema' },
29
- { name: 'evaluation_operation', input_schema_export: 'EvaluationOperationInputSchema', output_schema_export: 'EvaluationOperationOutputSchema' },
30
- { name: 'persona_operation', input_schema_export: 'PersonaOperationInputSchema', output_schema_export: 'PersonaOperationOutputSchema' },
31
- { name: 'intent_radar', input_schema_export: 'IntentRadarInputSchema', output_schema_export: 'IntentRadarOutputSchema' },
32
- ];
33
- export function loadLayer4Deployed(toolName) {
34
- const filePath = path.join(DEPLOYED_TOOLS_DIR, `${toolName}.json`);
35
- const fallback = {
36
- tool_descriptor_file: filePath,
37
- file_exists: false,
38
- is_stub: true,
39
- properties_count: 0,
40
- required_count: 0,
41
- has_schema_hint: false,
42
- has_additional_properties_false: false,
43
- has_dollar_schema: false,
44
- has_oneof: false,
45
- has_anyof: false,
46
- has_allof: false,
47
- union_count: 0,
48
- };
49
- if (!fs.existsSync(filePath))
50
- return fallback;
51
- try {
52
- const raw = fs.readFileSync(filePath, 'utf-8');
53
- const data = JSON.parse(raw);
54
- const args = data.arguments ?? {};
55
- const props = args.properties ?? {};
56
- const required = args.required ?? [];
57
- const propKeys = Object.keys(props);
58
- const oneOfArr = args.oneOf ?? [];
59
- const anyOfArr = args.anyOf ?? [];
60
- const allOfArr = args.allOf ?? [];
61
- const hasOneOf = oneOfArr.length > 0;
62
- const hasAnyOf = anyOfArr.length > 0;
63
- const hasAllOf = allOfArr.length > 0;
64
- const unionCount = oneOfArr.length + anyOfArr.length + allOfArr.length;
65
- const isStub = propKeys.length === 0 && unionCount === 0;
66
- const description = data.description ?? '';
67
- const hasSchemaHint = description.includes('schema_query');
68
- return {
69
- tool_descriptor_file: filePath,
70
- file_exists: true,
71
- is_stub: isStub,
72
- properties_count: propKeys.length,
73
- required_count: required.length,
74
- has_schema_hint: hasSchemaHint,
75
- has_additional_properties_false: args.additionalProperties === false,
76
- has_dollar_schema: !!args.$schema,
77
- has_oneof: hasOneOf,
78
- has_anyof: hasAnyOf,
79
- has_allof: hasAllOf,
80
- union_count: unionCount,
81
- };
82
- }
83
- catch {
84
- return fallback;
85
- }
86
- }
87
- export function loadLayer3Generated(toolName) {
88
- const inputPath = path.join(GENERATED_SCHEMAS_DIR, `${toolName}.schema.json`);
89
- const outputPath = path.join(GENERATED_SCHEMAS_DIR, `${toolName}.output.json`);
90
- const inputExists = fs.existsSync(inputPath);
91
- const outputExists = fs.existsSync(outputPath);
92
- const inputSize = inputExists ? fs.statSync(inputPath).size : 0;
93
- const outputSize = outputExists ? fs.statSync(outputPath).size : 0;
94
- return {
95
- input_schema_file: inputPath,
96
- output_schema_file: outputPath,
97
- input_exists: inputExists,
98
- output_exists: outputExists,
99
- input_size_bytes: inputSize,
100
- output_size_bytes: outputSize,
101
- };
102
- }
103
- export function analyzeLayerCensus() {
104
- const census = [];
105
- for (const tool of ALL_TOOLS) {
106
- census.push({
107
- name: tool.name,
108
- layer2_zod: {
109
- input_schema_export: tool.input_schema_export,
110
- output_schema_export: tool.output_schema_export,
111
- schema_dir: MCP_SRC_SCHEMA_DIR,
112
- },
113
- layer3_generated: loadLayer3Generated(tool.name),
114
- layer4_deployed: loadLayer4Deployed(tool.name) ?? {},
115
- });
116
- }
117
- return census;
118
- }
119
- export function analyzeDeployedStubInconsistency(census) {
120
- const findings = [];
121
- const stubs = [];
122
- const fullSchemas = [];
123
- for (const c of census) {
124
- if (!c.layer4_deployed.file_exists) {
125
- findings.push({
126
- rule_id: 'MCP-DEPLOY-001',
127
- severity: 'critical',
128
- category: 'stub_inconsistency',
129
- tool_name: c.name,
130
- description: `Layer 4 deployed file does not exist: ${c.layer4_deployed.tool_descriptor_file}`,
131
- location: c.layer4_deployed.tool_descriptor_file,
132
- fix: `Create ${c.name}.json in DEPLOYED_TOOLS_DIR matching the Layer 3 generated schema.`,
133
- });
134
- continue;
135
- }
136
- if (c.layer4_deployed.is_stub) {
137
- stubs.push(c);
138
- }
139
- else {
140
- fullSchemas.push(c);
141
- }
142
- }
143
- for (const c of stubs) {
144
- findings.push({
145
- rule_id: 'MCP-STUB-001',
146
- severity: 'high',
147
- category: 'stub_inconsistency',
148
- tool_name: c.name,
149
- 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.`,
150
- location: c.layer4_deployed.tool_descriptor_file,
151
- fix: `Regenerate ${c.name}.json from dist/schemas/${c.name}.schema.json (resolve $ref, inline definitions, wrap as {name, description, arguments}).`,
152
- });
153
- if (!c.layer4_deployed.has_schema_hint) {
154
- findings.push({
155
- rule_id: 'MCP-STUB-003',
156
- severity: 'high',
157
- category: 'stub_inconsistency',
158
- tool_name: c.name,
159
- 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}').`,
160
- location: c.layer4_deployed.tool_descriptor_file,
161
- 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.`,
162
- });
163
- }
164
- }
165
- if (stubs.length > 0 && fullSchemas.length > 0) {
166
- findings.push({
167
- rule_id: 'MCP-STUB-002',
168
- severity: 'info',
169
- category: 'stub_inconsistency',
170
- tool_name: '(all)',
171
- 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(', ')}.`,
172
- 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).`,
173
- });
174
- }
175
- return findings;
176
- }
177
- export function analyzeLayerParity(census) {
178
- const findings = [];
179
- for (const c of census) {
180
- if (!c.layer4_deployed.file_exists || c.layer4_deployed.is_stub)
181
- continue;
182
- if (!c.layer3_generated.input_exists) {
183
- findings.push({
184
- rule_id: 'MCP-PARITY-001',
185
- severity: 'critical',
186
- category: 'layer_parity',
187
- tool_name: c.name,
188
- description: `Layer 4 has full schema but Layer 3 generated file is missing: ${c.layer3_generated.input_schema_file}`,
189
- fix: `Run pnpm generate:schemas to regenerate Layer 3 from Zod source.`,
190
- });
191
- continue;
192
- }
193
- const l4 = readLayer4Arguments(c.name);
194
- const l3 = readLayer3ResolvedSchema(c.name);
195
- if (!l4 || !l3)
196
- continue;
197
- const l4Props = new Set(Object.keys(l4.properties ?? {}));
198
- const l3Props = new Set(Object.keys(l3.properties ?? {}));
199
- const missingInL4 = [...l3Props].filter(p => !l4Props.has(p));
200
- const extraInL4 = [...l4Props].filter(p => !l3Props.has(p));
201
- if (missingInL4.length > 0) {
202
- findings.push({
203
- rule_id: 'MCP-PARITY-002',
204
- severity: 'high',
205
- category: 'layer_parity',
206
- tool_name: c.name,
207
- description: `Layer 4 deployed schema is missing ${missingInL4.length} properties present in Layer 3 generated schema: ${missingInL4.join(', ')}`,
208
- location: c.layer4_deployed.tool_descriptor_file,
209
- fix: `Regenerate ${c.name}.json from dist/schemas/${c.name}.schema.json.`,
210
- });
211
- }
212
- if (extraInL4.length > 0) {
213
- findings.push({
214
- rule_id: 'MCP-PARITY-003',
215
- severity: 'medium',
216
- category: 'layer_parity',
217
- tool_name: c.name,
218
- description: `Layer 4 deployed schema has ${extraInL4.length} extra properties not in Layer 3: ${extraInL4.join(', ')}`,
219
- location: c.layer4_deployed.tool_descriptor_file,
220
- fix: `Regenerate ${c.name}.json from dist/schemas/${c.name}.schema.json.`,
221
- });
222
- }
223
- const l4Req = new Set(l4.required ?? []);
224
- const l3Req = new Set(l3.required ?? []);
225
- const reqMissing = [...l3Req].filter(r => !l4Req.has(r));
226
- const reqExtra = [...l4Req].filter(r => !l3Req.has(r));
227
- if (reqMissing.length > 0 || reqExtra.length > 0) {
228
- findings.push({
229
- rule_id: 'MCP-PARITY-004',
230
- severity: 'high',
231
- category: 'layer_parity',
232
- tool_name: c.name,
233
- description: `Layer 4 'required' array differs from Layer 3. Missing in L4: [${reqMissing.join(', ')}]. Extra in L4: [${reqExtra.join(', ')}].`,
234
- location: c.layer4_deployed.tool_descriptor_file,
235
- fix: `Sync 'required' array from Layer 3 to Layer 4.`,
236
- });
237
- }
238
- const l4AP = l4.additionalProperties;
239
- const l3AP = l3.additionalProperties;
240
- if (l4AP !== l3AP) {
241
- findings.push({
242
- rule_id: 'MCP-PARITY-005',
243
- severity: 'medium',
244
- category: 'layer_parity',
245
- tool_name: c.name,
246
- description: `Layer 4 'additionalProperties' (${JSON.stringify(l4AP)}) differs from Layer 3 (${JSON.stringify(l3AP)}).`,
247
- location: c.layer4_deployed.tool_descriptor_file,
248
- fix: `Sync 'additionalProperties' value.`,
249
- });
250
- }
251
- }
252
- return findings;
253
- }
254
- function readLayer4Arguments(toolName) {
255
- const filePath = path.join(DEPLOYED_TOOLS_DIR, `${toolName}.json`);
256
- try {
257
- const raw = fs.readFileSync(filePath, 'utf-8');
258
- const data = JSON.parse(raw);
259
- return data.arguments ?? null;
260
- }
261
- catch {
262
- return null;
263
- }
264
- }
265
- function readLayer3ResolvedSchema(toolName) {
266
- const filePath = path.join(GENERATED_SCHEMAS_DIR, `${toolName}.schema.json`);
267
- try {
268
- const raw = fs.readFileSync(filePath, 'utf-8');
269
- const data = JSON.parse(raw);
270
- if (data.$ref && data.$ref.startsWith('#/definitions/')) {
271
- const defName = data.$ref.slice('#/definitions/'.length);
272
- const def = data.definitions?.[defName];
273
- if (def && typeof def === 'object') {
274
- return def;
275
- }
276
- }
277
- return data;
278
- }
279
- catch {
280
- return null;
281
- }
282
- }
283
- export function analyzeAnyUnknownCensus() {
284
- const instances = [];
285
- const scanDirs = [MCP_SRC_SCHEMA_DIR, MCP_SRC_TOOLS_DIR];
286
- for (const dir of scanDirs) {
287
- const files = listTypeScriptFiles(dir);
288
- for (const file of files) {
289
- const lines = fs.readFileSync(file, 'utf-8').split('\n');
290
- for (let i = 0; i < lines.length; i++) {
291
- const line = lines[i];
292
- const trimmed = line.trim();
293
- if (trimmed.startsWith('//') || trimmed.startsWith('*'))
294
- continue;
295
- const patterns = [
296
- { regex: /z\.any\(\)/g, pattern: 'z.any()' },
297
- { regex: /z\.unknown\(\)/g, pattern: 'z.unknown()' },
298
- { regex: /args\s*:\s*any\b/g, pattern: 'args: any' },
299
- { regex: /Promise\s*<\s*any\s*>/g, pattern: 'Promise<any>' },
300
- { regex: /Record\s*<\s*string\s*,\s*any\s*>/g, pattern: 'Record<string, any>' },
301
- { regex: /\bas\s+any\b/g, pattern: 'as any' },
302
- ];
303
- for (const { regex, pattern } of patterns) {
304
- regex.lastIndex = 0;
305
- let m;
306
- while ((m = regex.exec(line)) !== null) {
307
- const category = categorizeAnyInstance(file, i + 1, line, pattern);
308
- instances.push({
309
- file,
310
- line: i + 1,
311
- code: trimmed.length > 120 ? trimmed.slice(0, 117) + '...' : trimmed,
312
- pattern,
313
- category: category.category,
314
- reason: category.reason,
315
- fix_suggestion: category.fix,
316
- });
317
- }
318
- }
319
- }
320
- }
321
- }
322
- return instances;
323
- }
324
- function listTypeScriptFiles(dir) {
325
- const result = [];
326
- if (!fs.existsSync(dir))
327
- return result;
328
- const entries = fs.readdirSync(dir, { withFileTypes: true });
329
- for (const entry of entries) {
330
- const fullPath = path.join(dir, entry.name);
331
- if (entry.isDirectory()) {
332
- if (entry.name === '__tests__' || entry.name === 'node_modules')
333
- continue;
334
- result.push(...listTypeScriptFiles(fullPath));
335
- }
336
- else if (entry.isFile() && entry.name.endsWith('.ts')) {
337
- result.push(fullPath);
338
- }
339
- }
340
- return result;
341
- }
342
- function categorizeAnyInstance(file, lineNum, line, pattern) {
343
- const fileName = path.basename(file);
344
- const trimmed = line.trim();
345
- if (pattern === 'z.any()' && /SemanticSummarySchema\s*=\s*z\.any\(\)/.test(trimmed)) {
346
- return {
347
- category: 'fixable',
348
- reason: 'Circular-dependency workaround for SemanticSummarySchema — can use z.lazy() or refactor to break the cycle.',
349
- fix: 'Define SemanticSummarySchema with z.lazy(() => SemanticSummarySchemaReal) or restructure imports to break the cycle.',
350
- };
351
- }
352
- if (pattern === 'z.any()' && /result\s*:\s*z\.any\(\)/.test(trimmed) && /[\\/]config[\\/]|[\\/]project[\\/]/.test(file)) {
353
- return {
354
- category: 'fixable',
355
- reason: `Result shape depends on action — can use z.discriminatedUnion('action', [...]) to type each action's result.`,
356
- fix: `Define discriminated union: z.discriminatedUnion('action', [z.object({action: z.literal('list'), result: ...}), ...]).`,
357
- };
358
- }
359
- if (pattern === 'z.unknown()' && /result\s*:\s*z\.unknown\(\)/.test(trimmed) && /index\.ts/.test(fileName)) {
360
- return {
361
- category: 'fixable',
362
- reason: 'query_toolkit output result depends on query_type — can use z.discriminatedUnion(\'query_type\', [...]).',
363
- fix: 'Define discriminated union: z.discriminatedUnion(\'query_type\', [z.object({query_type: z.literal(\'local_mark_list\'), result: z.array(MarkDataSchema)}), ...]).',
364
- };
365
- }
366
- if (pattern === 'z.any()' && /data\s*:\s*z\.any\(\)/.test(trimmed) && /[\\/]schema-query[\\/]/.test(file)) {
367
- return {
368
- category: 'fixable',
369
- reason: 'SchemaQuery output data depends on action — can use discriminated union by action.',
370
- fix: 'Define discriminated union: action=\'get\' returns JSON Schema, action=\'list\' returns array of items.',
371
- };
372
- }
373
- if (pattern === 'args: any' && /handlers[\\/]/.test(file)) {
374
- return {
375
- category: 'fixable',
376
- reason: 'Handler args can use `unknown` (forces runtime validation) or a typed input schema.',
377
- fix: 'Replace `args: any` with `args: unknown` and use strictParse(schema, args) at the top of the handler.',
378
- };
379
- }
380
- if (pattern === 'args: any' && /tools[\\/]index\.ts/.test(file)) {
381
- return {
382
- category: 'fixable',
383
- reason: 'dispatchToolCall args is `any` — can be `unknown` since each tool parses with its own schema.',
384
- fix: 'Change `args: any` to `args: unknown` in dispatchToolCall signature.',
385
- };
386
- }
387
- if (pattern === 'args: any' && /types\.ts/.test(fileName) && /handler/.test(trimmed)) {
388
- return {
389
- category: 'fixable',
390
- reason: 'ToolEntry.handler args is `any` — can be `unknown` (each handler parses with its own schema).',
391
- fix: 'Change `handler: (args: any) => ...` to `handler: (args: unknown) => ...`.',
392
- };
393
- }
394
- if (pattern === 'z.any()' && /claimReceipt|ethReceipt|wowReceipt/.test(trimmed)) {
395
- return {
396
- category: 'legitimate',
397
- reason: 'EVM transaction receipts have an externally-defined shape from viem/ethers — z.any() is acceptable (receipt is informational, not validated).',
398
- };
399
- }
400
- if (pattern === 'z.any()' && /content_raw/.test(trimmed)) {
401
- return {
402
- category: 'legitimate',
403
- reason: 'content_raw holds raw content for unknown object types — by definition untyped. z.any() is acceptable here.',
404
- };
405
- }
406
- if ((pattern === 'z.unknown()' || pattern === 'z.any()') && /parsedJson/.test(trimmed)) {
407
- return {
408
- category: 'legitimate',
409
- reason: 'Event parsedJson is arbitrary on-chain event data — z.record(z.string(), z.unknown()) is appropriate.',
410
- };
411
- }
412
- if (pattern === 'z.any()' && /key_value/.test(trimmed)) {
413
- return {
414
- category: 'fixable',
415
- reason: 'Repository key_value depends on key_type — could use discriminated union by key_type (string→z.string(), u64→z.bigint()/number, etc.).',
416
- fix: 'Define z.discriminatedUnion(\'key_type\', [...]) with each variant typed.',
417
- };
418
- }
419
- if (pattern === 'z.unknown()' && /data\s*:\s*z\.unknown\(\)/.test(trimmed) && /[\\/]bridge/.test(file)) {
420
- return {
421
- category: 'legitimate',
422
- reason: 'Bridge operation result data varies by operation_type — currently 9 different shapes. Discriminated union would be ideal but high refactor cost.',
423
- };
424
- }
425
- if (pattern === 'z.unknown()' && /adjusted_params/.test(trimmed)) {
426
- return {
427
- category: 'legitimate',
428
- reason: 'adjusted_params are free-form key-value pairs suggested by AI — z.record(z.string(), z.unknown()) is appropriate.',
429
- };
430
- }
431
- if (pattern === 'z.any()' && /object\s*:\s*z\.union.*z\.record\(z\.any\(\)/.test(trimmed)) {
432
- return {
433
- category: 'fixable',
434
- reason: 'Creation vs reference object union — z.record(z.any()) should be replaced with NamedObjectSchema (structured creation input).',
435
- fix: 'Replace z.record(z.any()) with NamedObjectSchema (already defined in base.ts).',
436
- };
437
- }
438
- if (pattern === 'z.any()' && /result\s*:\s*z\.any\(\)\.optional\(\)/.test(trimmed) && /[\\/]bridge/.test(file)) {
439
- return {
440
- category: 'legitimate',
441
- reason: 'Bridge result is operation-specific (manage_evm_rpc has different result per operation) — z.any().optional() is acceptable here.',
442
- };
443
- }
444
- if (pattern === 'Promise<any>' && /[\\/](wrap|shared)\.ts/.test(file)) {
445
- return {
446
- category: 'fixable',
447
- reason: 'Generic wrappers in wrap.ts/shared.ts use Promise<any> — could be made generic <T>.',
448
- fix: 'Replace `Promise<any>` with `Promise<ToolDispatchResult>` (the actual return shape).',
449
- };
450
- }
451
- if (pattern === 'Record<string, any>' && /types\.ts/.test(fileName) && /_meta|structuredContent/.test(trimmed)) {
452
- return {
453
- category: 'fixable',
454
- reason: 'ToolConfig._meta and ToolDispatchResult.structuredContent could use structured types.',
455
- fix: 'Define ToolMeta interface (category, tags) and replace structuredContent: any with structured type.',
456
- };
457
- }
458
- if (pattern === 'as any') {
459
- return {
460
- category: 'legitimate',
461
- reason: '`as any` cast — usually for third-party type mismatches (MCP SDK). Acceptable if isolated.',
462
- };
463
- }
464
- return {
465
- category: 'legitimate',
466
- reason: 'Unclassified any/unknown usage — review manually. Defaulting to legitimate (no auto-fix).',
467
- };
468
- }
469
- export function analyzeHandlerTypeSafety(instances) {
470
- const findings = [];
471
- for (const inst of instances) {
472
- if (inst.pattern !== 'args: any')
473
- continue;
474
- if (!/tools[\\/]/.test(inst.file))
475
- continue;
476
- findings.push({
477
- rule_id: 'MCP-HANDLER-001',
478
- severity: 'medium',
479
- category: 'handler_types',
480
- tool_name: path.basename(inst.file, '.ts'),
481
- description: `Handler uses \`args: any\` — bypasses TypeScript type checking. ${inst.reason}`,
482
- location: `${inst.file}:${inst.line}`,
483
- fix: inst.fix_suggestion,
484
- });
485
- }
486
- return findings;
487
- }
488
- export function analyzeOutputSchemaCoverage(census) {
489
- const findings = [];
490
- for (const c of census) {
491
- if (!c.layer3_generated.output_exists && c.name !== "onchain_operations") {
492
- findings.push({
493
- rule_id: 'MCP-OUTPUT-001',
494
- severity: 'high',
495
- category: 'output_coverage',
496
- tool_name: c.name,
497
- description: `Layer 3 output schema file does not exist: ${c.layer3_generated.output_schema_file}`,
498
- fix: `Add outputSchema to ${c.name}'s tool definition and regenerate schemas.`,
499
- });
500
- }
501
- if (c.layer2_zod.output_schema_export === null) {
502
- findings.push({
503
- rule_id: 'MCP-OUTPUT-002',
504
- severity: 'medium',
505
- category: 'output_coverage',
506
- tool_name: c.name,
507
- description: `Layer 2 outputSchema is defined inline (not exported with a stable name). This makes it harder to reference from tests.`,
508
- fix: `Export the outputSchema with a stable name (e.g., ${c.name}OutputSchema).`,
509
- });
510
- }
511
- }
512
- return findings;
513
- }
514
- export function analyzeGenerationScriptSync() {
515
- const findings = [];
516
- if (!fs.existsSync(GENERATION_SCRIPT)) {
517
- findings.push({
518
- rule_id: 'MCP-GENSYNC-001',
519
- severity: 'critical',
520
- category: 'generation_sync',
521
- tool_name: '(all)',
522
- description: `Generation script not found: ${GENERATION_SCRIPT}`,
523
- });
524
- return findings;
525
- }
526
- const src = fs.readFileSync(GENERATION_SCRIPT, 'utf-8');
527
- const nameRegex = /name:\s*["']([^"']+)["']/g;
528
- const scriptNames = new Set();
529
- let m;
530
- while ((m = nameRegex.exec(src)) !== null) {
531
- if (ALL_TOOLS.some(t => t.name === m[1])) {
532
- scriptNames.add(m[1]);
533
- }
534
- }
535
- for (const tool of ALL_TOOLS) {
536
- if (!scriptNames.has(tool.name)) {
537
- findings.push({
538
- rule_id: 'MCP-GENSYNC-002',
539
- severity: 'high',
540
- category: 'generation_sync',
541
- tool_name: tool.name,
542
- description: `Tool "${tool.name}" is in TOOL_REGISTRY but missing from generate-json-schemas.ts. Layer 3 schemas will not be generated.`,
543
- location: GENERATION_SCRIPT,
544
- fix: `Add a get${toPascalCase(tool.name)}Tool() function and add it to the tools array.`,
545
- });
546
- }
547
- }
548
- return findings;
549
- }
550
- function toPascalCase(s) {
551
- return s.split('_').map(p => p.charAt(0).toUpperCase() + p.slice(1).toLowerCase()).join('');
552
- }
553
- export function analyzeSchemaQueryReflection(census) {
554
- const findings = [];
555
- for (const c of census) {
556
- if (!c.layer3_generated.input_exists) {
557
- findings.push({
558
- rule_id: 'MCP-REFLECT-001',
559
- severity: 'high',
560
- category: 'reflection',
561
- tool_name: c.name,
562
- description: `schema_query(action='get', name='${c.name}') would fail — Layer 3 input schema missing.`,
563
- fix: `Run pnpm generate:schemas.`,
564
- });
565
- }
566
- if (!c.layer3_generated.output_exists && c.name !== "onchain_operations") {
567
- findings.push({
568
- rule_id: 'MCP-REFLECT-002',
569
- severity: 'medium',
570
- category: 'reflection',
571
- tool_name: c.name,
572
- description: `schema_query(action='get_output', name='${c.name}') would fail — Layer 3 output schema missing.`,
573
- fix: `Run pnpm generate:schemas.`,
574
- });
575
- }
576
- }
577
- const onchainOps = [
578
- 'permission', 'service', 'machine', 'progress', 'guard',
579
- 'arbitration', 'repository', 'contact', 'treasury', 'reward',
580
- 'allocation', 'personal', 'payment', 'demand', 'order', 'gen_passport',
581
- 'proof', 'gen_proof',
582
- ];
583
- for (const op of onchainOps) {
584
- const opFile = path.join(GENERATED_SCHEMAS_DIR, `onchain_operations_${op}.schema.json`);
585
- if (!fs.existsSync(opFile)) {
586
- findings.push({
587
- rule_id: 'MCP-REFLECT-003',
588
- severity: 'medium',
589
- category: 'reflection',
590
- tool_name: `onchain_operations_${op}`,
591
- description: `Individual operation schema missing: ${opFile}. schema_query(action='get', name='onchain_operations_${op}') would fail.`,
592
- fix: `Run pnpm generate:schemas.`,
593
- });
594
- }
595
- }
596
- return findings;
597
- }
598
- export function scanAllMcpSchemas() {
599
- const census = analyzeLayerCensus();
600
- const anyInstances = analyzeAnyUnknownCensus();
601
- const findings = [
602
- ...analyzeDeployedStubInconsistency(census),
603
- ...analyzeLayerParity(census),
604
- ...analyzeHandlerTypeSafety(anyInstances),
605
- ...analyzeOutputSchemaCoverage(census),
606
- ...analyzeGenerationScriptSync(),
607
- ...analyzeSchemaQueryReflection(census),
608
- ];
609
- const bySev = new Map();
610
- const byCat = new Map();
611
- for (const f of findings) {
612
- if (!bySev.has(f.severity))
613
- bySev.set(f.severity, []);
614
- bySev.get(f.severity).push(f);
615
- if (!byCat.has(f.category))
616
- byCat.set(f.category, []);
617
- byCat.get(f.category).push(f);
618
- }
619
- const fixable = anyInstances.filter(i => i.category === 'fixable').length;
620
- const legit = anyInstances.filter(i => i.category === 'legitimate').length;
621
- const external = anyInstances.filter(i => i.category === 'external').length;
622
- const stubCount = census.filter(c => c.layer4_deployed.is_stub).length;
623
- const fullCount = census.filter(c => !c.layer4_deployed.is_stub && c.layer4_deployed.file_exists).length;
624
- return {
625
- census,
626
- findings,
627
- any_unknown_instances: anyInstances,
628
- findings_by_severity: bySev,
629
- findings_by_category: byCat,
630
- total_findings: findings.length,
631
- fixable_any_count: fixable,
632
- legitimate_any_count: legit,
633
- external_any_count: external,
634
- stub_count: stubCount,
635
- full_schema_count: fullCount,
636
- };
637
- }
638
- export function formatAuditReport(result) {
639
- const lines = [];
640
- lines.push(`# MCP Schema Audit Report — 17 WoWok Tools`);
641
- lines.push('');
642
- lines.push(`> Auto-generated by \`mcp-schema-audit.ts\` v${MCP_SCHEMA_AUDIT_VERSION} — comprehensive`);
643
- lines.push(`> 4-layer audit of schema consistency, any/unknown usage, and I/O coverage.`);
644
- lines.push('');
645
- lines.push(`## Summary`);
646
- lines.push('');
647
- lines.push(`- **Tools audited**: ${result.census.length}`);
648
- lines.push(`- **Total findings**: ${result.total_findings}`);
649
- lines.push(`- **Stub files**: ${result.stub_count} / ${result.census.length}`);
650
- lines.push(`- **Full schema files**: ${result.full_schema_count} / ${result.census.length}`);
651
- lines.push(`- **any/unknown instances**: ${result.any_unknown_instances.length} total`);
652
- lines.push(` - Fixable: ${result.fixable_any_count}`);
653
- lines.push(` - Legitimate: ${result.legitimate_any_count}`);
654
- lines.push(` - External: ${result.external_any_count}`);
655
- lines.push('');
656
- lines.push(`### Findings by Severity`);
657
- lines.push('');
658
- lines.push(`| Severity | Count |`);
659
- lines.push(`|----------|-------|`);
660
- for (const sev of ['critical', 'high', 'medium', 'low', 'info']) {
661
- const arr = result.findings_by_severity.get(sev) ?? [];
662
- lines.push(`| ${sev} | ${arr.length} |`);
663
- }
664
- lines.push('');
665
- lines.push(`### Findings by Category`);
666
- lines.push('');
667
- lines.push(`| Category | Count |`);
668
- lines.push(`|----------|-------|`);
669
- for (const cat of ['stub_inconsistency', 'layer_parity', 'handler_types', 'output_coverage', 'generation_sync', 'reflection']) {
670
- const arr = result.findings_by_category.get(cat) ?? [];
671
- lines.push(`| ${cat} | ${arr.length} |`);
672
- }
673
- lines.push('');
674
- lines.push(`## Layer Census — All 17 Tools`);
675
- lines.push('');
676
- lines.push(`| Tool | L3 Input | L3 Output | L4 Status | L4 Properties | L4 Required |`);
677
- lines.push(`|------|----------|-----------|-----------|---------------|-------------|`);
678
- for (const c of result.census) {
679
- const l3i = c.layer3_generated.input_exists ? `✓ ${(c.layer3_generated.input_size_bytes / 1024).toFixed(1)}KB` : '✗ MISSING';
680
- const l3o = c.layer3_generated.output_exists ? `✓ ${(c.layer3_generated.output_size_bytes / 1024).toFixed(1)}KB` : '✗ MISSING';
681
- const l4s = !c.layer4_deployed.file_exists ? '✗ MISSING' : c.layer4_deployed.is_stub ? '⚠ STUB' : '✓ FULL';
682
- const l4p = c.layer4_deployed.properties_count;
683
- const l4r = c.layer4_deployed.required_count;
684
- lines.push(`| ${c.name} | ${l3i} | ${l3o} | ${l4s} | ${l4p} | ${l4r} |`);
685
- }
686
- lines.push('');
687
- lines.push(`## Findings Detail`);
688
- lines.push('');
689
- const orderedSeverities = ['critical', 'high', 'medium', 'low', 'info'];
690
- for (const sev of orderedSeverities) {
691
- const sevFindings = result.findings_by_severity.get(sev) ?? [];
692
- if (sevFindings.length === 0)
693
- continue;
694
- const title = sev.toUpperCase();
695
- lines.push(`### ${title} (${sevFindings.length})`);
696
- lines.push('');
697
- for (const f of sevFindings) {
698
- lines.push(`- **[${f.rule_id}] ${f.description}`);
699
- if (f.location)
700
- lines.push(` - Location: \`${f.location}\``);
701
- if (f.fix)
702
- lines.push(` - Fix: ${f.fix}`);
703
- lines.push('');
704
- }
705
- }
706
- lines.push(`## any/unknown Census Detail`);
707
- lines.push('');
708
- lines.push(`Total instances: ${result.any_unknown_instances.length}`);
709
- lines.push('');
710
- lines.push(`### By Pattern`);
711
- lines.push('');
712
- lines.push(`| Pattern | Total | Fixable | Legitimate | External |`);
713
- lines.push(`|---------|-------|---------|------------|----------|`);
714
- const patternGroups = new Map();
715
- for (const inst of result.any_unknown_instances) {
716
- if (!patternGroups.has(inst.pattern))
717
- patternGroups.set(inst.pattern, []);
718
- patternGroups.get(inst.pattern).push(inst);
719
- }
720
- for (const [pattern, arr] of [...patternGroups.entries()].sort((a, b) => b[1].length - a[1].length)) {
721
- const fixable = arr.filter(i => i.category === 'fixable').length;
722
- const legit = arr.filter(i => i.category === 'legitimate').length;
723
- const ext = arr.filter(i => i.category === 'external').length;
724
- lines.push(`| \`${pattern}\` | ${arr.length} | ${fixable} | ${legit} | ${ext} |`);
725
- }
726
- lines.push('');
727
- const fixable = result.any_unknown_instances.filter(i => i.category === 'fixable');
728
- if (fixable.length > 0) {
729
- lines.push(`### Fixable Instances (Priority List)`);
730
- lines.push('');
731
- for (const inst of fixable) {
732
- lines.push(`- **${path.basename(inst.file)}:${inst.line}** [\`${inst.pattern}\`]`);
733
- lines.push(` - Code: \`${inst.code}\``);
734
- lines.push(` - Reason: ${inst.reason}`);
735
- if (inst.fix_suggestion)
736
- lines.push(` - Fix: ${inst.fix_suggestion}`);
737
- lines.push('');
738
- }
739
- }
740
- lines.push(`## Recommended Action Plan`);
741
- lines.push('');
742
- lines.push(`### Phase 1: Fix Layer 4 Stub Inconsistency (CRITICAL UX)`);
743
- lines.push('');
744
- 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:`);
745
- lines.push('');
746
- lines.push(`\`\`\`bash`);
747
- lines.push(`# 1. Generate Layer 3 schemas from Zod source`);
748
- lines.push(`cd d:/wowok/agent/mcp && pnpm generate:schemas`);
749
- lines.push('');
750
- lines.push(`# 2. Generate Layer 4 deployed files from Layer 3`);
751
- lines.push(`# (Run the new sync-deployed-tools.ts script — see E2.4)`);
752
- lines.push(`npx tsx scripts/sync-deployed-tools.ts`);
753
- lines.push(`\`\`\``);
754
- lines.push('');
755
- lines.push(`### Phase 2: Type the ${result.fixable_any_count} fixable any/unknown instances`);
756
- lines.push('');
757
- lines.push(`Priority order:`);
758
- lines.push('');
759
- lines.push(`1. **SemanticSummarySchema** (src/schema/local/index.ts:6) — use \`z.lazy()\``);
760
- lines.push(`2. **ConfigOperationOutputSchema.result** (src/schema/config/index.ts:17) — discriminated union by action`);
761
- lines.push(`3. **ProjectOperationOutputSchema.result** (src/schema/project/index.ts:34) — discriminated union by action`);
762
- lines.push(`4. **query_toolkit output result** (src/tools/index.ts:250) — discriminated union by query_type`);
763
- lines.push(`5. **SchemaQueryOutputSchema.data** (src/schema/schema-query/index.ts:34) — discriminated union by action`);
764
- lines.push(`6. **RepositoryKeyValueSchema.key_value** (src/schema/operations.ts:331) — discriminated union by key_type`);
765
- lines.push(`7. **Handler args: any** — replace with \`unknown\` (forces strictParse at top of handler)`);
766
- lines.push(`8. **dispatchToolCall(name, args: any)** — replace with \`unknown\``);
767
- lines.push('');
768
- lines.push(`### Phase 3: Verify I/O Schema Match`);
769
- lines.push('');
770
- lines.push(`For each tool, write a parity test that:`);
771
- lines.push(`1. Calls the handler with a minimal valid input`);
772
- lines.push(`2. Captures the structuredContent`);
773
- lines.push(`3. Validates structuredContent against outputSchema`);
774
- lines.push(`4. Reports any mismatch`);
775
- lines.push('');
776
- return lines.join('\n');
777
- }
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');}