@wowok/agent-mcp 3.0.2 → 3.0.4

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 (322) hide show
  1. package/LICENSE +0 -3
  2. package/dist/harness/recover.js +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +1 -1
  5. package/dist/knowledge/account-marks.js +1 -1
  6. package/dist/knowledge/arbitration-risk.js +1 -1
  7. package/dist/knowledge/event-semantics.js +1 -1
  8. package/dist/knowledge/flywheel-loop.d.ts +4 -52
  9. package/dist/knowledge/flywheel-loop.js +1 -1
  10. package/dist/knowledge/guard-lint.js +1 -1
  11. package/dist/knowledge/guard-puzzle.js +1 -1
  12. package/dist/knowledge/index.d.ts +2 -225
  13. package/dist/knowledge/index.js +1 -1
  14. package/dist/knowledge/industry-registry.js +1 -1
  15. package/dist/knowledge/machine-risk.js +1 -1
  16. package/dist/knowledge/machine-translation.js +1 -1
  17. package/dist/knowledge/onchain-constants.js +1 -1
  18. package/dist/knowledge/order-ledger.d.ts +2 -2
  19. package/dist/knowledge/order-ledger.js +1 -1
  20. package/dist/knowledge/order-puzzle.d.ts +4 -4
  21. package/dist/knowledge/order-puzzle.js +1 -1
  22. package/dist/knowledge/order-risk.d.ts +1 -0
  23. package/dist/knowledge/order-risk.js +1 -1
  24. package/dist/knowledge/order-templates.d.ts +1 -1
  25. package/dist/knowledge/order-templates.js +1 -1
  26. package/dist/knowledge/safety-rules.js +1 -1
  27. package/dist/knowledge/service-ledger.js +1 -1
  28. package/dist/knowledge/service-risk.js +1 -1
  29. package/dist/knowledge/template-registry.js +1 -1
  30. package/dist/knowledge/tools-reference.js +1 -1
  31. package/dist/knowledge/workspace-lists.js +1 -1
  32. package/dist/monitor/MonitorLoop.js +1 -1
  33. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  34. package/dist/playbooks/service-build/context-assembly.d.ts +3 -1
  35. package/dist/playbooks/service-build/context-assembly.js +1 -1
  36. package/dist/playbooks/service-build/machine-nodes.d.ts +2 -0
  37. package/dist/playbooks/service-build/machine-nodes.js +1 -1
  38. package/dist/playbooks/service-build/machine-panorama.d.ts +7 -0
  39. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  40. package/dist/review/machine.js +1 -1
  41. package/dist/safety/confirm-gate.js +1 -1
  42. package/dist/schema/call/allocation.d.ts +5 -0
  43. package/dist/schema/call/arbitration.d.ts +5 -0
  44. package/dist/schema/call/base.d.ts +17 -3
  45. package/dist/schema/call/base.js +1 -1
  46. package/dist/schema/call/bridge.d.ts +29 -0
  47. package/dist/schema/call/bridge.js +1 -1
  48. package/dist/schema/call/contact.d.ts +5 -0
  49. package/dist/schema/call/demand.d.ts +5 -0
  50. package/dist/schema/call/error-codes.d.ts +2 -0
  51. package/dist/schema/call/error-codes.js +1 -0
  52. package/dist/schema/call/guard.d.ts +19 -4
  53. package/dist/schema/call/machine.d.ts +10 -0
  54. package/dist/schema/call/order.d.ts +5 -0
  55. package/dist/schema/call/payment.d.ts +5 -0
  56. package/dist/schema/call/permission.d.ts +5 -0
  57. package/dist/schema/call/personal.d.ts +5 -0
  58. package/dist/schema/call/progress.d.ts +5 -0
  59. package/dist/schema/call/proof.d.ts +10 -0
  60. package/dist/schema/call/repository.d.ts +5 -0
  61. package/dist/schema/call/reward.d.ts +5 -0
  62. package/dist/schema/call/semantic.d.ts +9 -1
  63. package/dist/schema/call/semantic.js +1 -1
  64. package/dist/schema/call/service.d.ts +5 -0
  65. package/dist/schema/call/treasury.d.ts +5 -0
  66. package/dist/schema/common/index.js +1 -1
  67. package/dist/schema/goal/index.d.ts +3 -3
  68. package/dist/schema/goal/planning.d.ts +2 -2
  69. package/dist/schema/index.d.ts +1 -0
  70. package/dist/schema/index.js +1 -1
  71. package/dist/schema/industry-pack/index.d.ts +4 -4
  72. package/dist/schema/industry-pack/modes.d.ts +4 -4
  73. package/dist/schema/interaction/index.d.ts +34 -0
  74. package/dist/schema/interaction/index.js +1 -0
  75. package/dist/schema/local/index.d.ts +558 -0
  76. package/dist/schema/local/index.js +1 -1
  77. package/dist/schema/messenger/index.d.ts +31 -25
  78. package/dist/schema/messenger/index.js +1 -1
  79. package/dist/schema/operations.d.ts +91 -1
  80. package/dist/schema/operations.js +1 -1
  81. package/dist/schema/persona/index.d.ts +2 -2
  82. package/dist/schema/query/bi.d.ts +0 -4
  83. package/dist/schema/query/bi.js +1 -1
  84. package/dist/schema/query/index.js +1 -1
  85. package/dist/schema/schema-query/index.d.ts +1 -1
  86. package/dist/schema/schema-version.js +1 -1
  87. package/dist/schema/trust/index.d.ts +3 -3
  88. package/dist/schema/workspace/index.d.ts +1 -1
  89. package/dist/schema-query-impl/index.js +1 -1
  90. package/dist/schemas/account_operation.output.json +4 -0
  91. package/dist/schemas/ask_user.output.json +54 -0
  92. package/dist/schemas/ask_user.schema.json +78 -0
  93. package/dist/schemas/bridge_operation.output.json +4 -0
  94. package/dist/schemas/bridge_operation.schema.json +50 -5
  95. package/dist/schemas/guard2file.schema.json +10 -1
  96. package/dist/schemas/index.json +13 -1
  97. package/dist/schemas/local_history_operation.output.json +1458 -0
  98. package/dist/schemas/local_history_operation.schema.json +105 -0
  99. package/dist/schemas/local_info_operation.output.json +4 -0
  100. package/dist/schemas/local_mark_operation.output.json +4 -0
  101. package/dist/schemas/machineNode2file.schema.json +10 -1
  102. package/dist/schemas/messenger_operation.output.json +8 -0
  103. package/dist/schemas/messenger_operation.schema.json +8 -0
  104. package/dist/schemas/onchain_events.output.json +2 -2
  105. package/dist/schemas/onchain_operations.output.json +4 -1
  106. package/dist/schemas/onchain_operations.schema.json +210 -28
  107. package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
  108. package/dist/schemas/onchain_operations_arbitration.schema.json +10 -1
  109. package/dist/schemas/onchain_operations_contact.schema.json +10 -1
  110. package/dist/schemas/onchain_operations_demand.schema.json +10 -1
  111. package/dist/schemas/onchain_operations_gen_passport.schema.json +10 -1
  112. package/dist/schemas/onchain_operations_gen_proof.schema.json +10 -1
  113. package/dist/schemas/onchain_operations_guard.schema.json +40 -11
  114. package/dist/schemas/onchain_operations_machine.schema.json +10 -1
  115. package/dist/schemas/onchain_operations_order.schema.json +10 -1
  116. package/dist/schemas/onchain_operations_payment.schema.json +10 -1
  117. package/dist/schemas/onchain_operations_permission.schema.json +10 -1
  118. package/dist/schemas/onchain_operations_personal.schema.json +10 -1
  119. package/dist/schemas/onchain_operations_progress.schema.json +10 -1
  120. package/dist/schemas/onchain_operations_proof.schema.json +10 -1
  121. package/dist/schemas/onchain_operations_repository.schema.json +10 -1
  122. package/dist/schemas/onchain_operations_reward.schema.json +10 -1
  123. package/dist/schemas/onchain_operations_service.schema.json +10 -1
  124. package/dist/schemas/onchain_operations_treasury.schema.json +10 -1
  125. package/dist/schemas/query_toolkit.output.json +17 -16
  126. package/dist/schemas/query_toolkit.schema.json +1 -1
  127. package/dist/tools/handlers/ask-user.d.ts +3 -0
  128. package/dist/tools/handlers/ask-user.js +1 -0
  129. package/dist/tools/handlers/config.js +1 -1
  130. package/dist/tools/handlers/local.d.ts +1 -0
  131. package/dist/tools/handlers/local.js +1 -1
  132. package/dist/tools/handlers/messenger.js +1 -1
  133. package/dist/tools/handlers/onchain.js +1 -1
  134. package/dist/tools/index.d.ts +2 -2
  135. package/dist/tools/index.js +1 -1
  136. package/dist/tools/registry/bridge.js +1 -1
  137. package/dist/tools/registry/business.js +1 -1
  138. package/dist/tools/registry/interaction.d.ts +2 -0
  139. package/dist/tools/registry/interaction.js +1 -0
  140. package/dist/tools/registry/local.js +1 -1
  141. package/dist/tools/registry/monitor.js +1 -1
  142. package/dist/tools/registry/onchain.js +1 -1
  143. package/dist/tools/registry/query.js +1 -1
  144. package/dist/tools/shared.js +1 -1
  145. package/dist/tools/types.d.ts +7 -1
  146. package/dist/tools/wrap.d.ts +3 -3
  147. package/dist/tools/wrap.js +1 -1
  148. package/package.json +2 -2
  149. package/dist/knowledge/allocation-confirm.d.ts +0 -115
  150. package/dist/knowledge/allocation-confirm.js +0 -1
  151. package/dist/knowledge/allocation-context.d.ts +0 -58
  152. package/dist/knowledge/allocation-context.js +0 -1
  153. package/dist/knowledge/allocation-translation.d.ts +0 -72
  154. package/dist/knowledge/allocation-translation.js +0 -1
  155. package/dist/knowledge/arb-confirm.d.ts +0 -28
  156. package/dist/knowledge/arb-confirm.js +0 -1
  157. package/dist/knowledge/arb-translation.d.ts +0 -48
  158. package/dist/knowledge/arb-translation.js +0 -1
  159. package/dist/knowledge/arbitration-confirm.d.ts +0 -135
  160. package/dist/knowledge/arbitration-confirm.js +0 -1
  161. package/dist/knowledge/arbitration-context.d.ts +0 -81
  162. package/dist/knowledge/arbitration-context.js +0 -1
  163. package/dist/knowledge/arbitration-translation.d.ts +0 -91
  164. package/dist/knowledge/arbitration-translation.js +0 -1
  165. package/dist/knowledge/bridge-confirm.d.ts +0 -26
  166. package/dist/knowledge/bridge-confirm.js +0 -1
  167. package/dist/knowledge/bridge-translation.d.ts +0 -37
  168. package/dist/knowledge/bridge-translation.js +0 -1
  169. package/dist/knowledge/contact-confirm.d.ts +0 -27
  170. package/dist/knowledge/contact-confirm.js +0 -1
  171. package/dist/knowledge/contact-translation.d.ts +0 -39
  172. package/dist/knowledge/contact-translation.js +0 -1
  173. package/dist/knowledge/demand-confirm.d.ts +0 -32
  174. package/dist/knowledge/demand-confirm.js +0 -1
  175. package/dist/knowledge/demand-context.d.ts +0 -17
  176. package/dist/knowledge/demand-context.js +0 -1
  177. package/dist/knowledge/demand-ledger.d.ts +0 -26
  178. package/dist/knowledge/demand-ledger.js +0 -1
  179. package/dist/knowledge/demand-puzzle.d.ts +0 -29
  180. package/dist/knowledge/demand-puzzle.js +0 -1
  181. package/dist/knowledge/demand-templates.d.ts +0 -12
  182. package/dist/knowledge/demand-templates.js +0 -1
  183. package/dist/knowledge/demand-translation.d.ts +0 -55
  184. package/dist/knowledge/demand-translation.js +0 -1
  185. package/dist/knowledge/examples-scanner-cli.d.ts +0 -1
  186. package/dist/knowledge/examples-scanner-cli.js +0 -1
  187. package/dist/knowledge/examples-scanner.d.ts +0 -121
  188. package/dist/knowledge/examples-scanner.js +0 -1
  189. package/dist/knowledge/glossary.d.ts +0 -18
  190. package/dist/knowledge/glossary.js +0 -1
  191. package/dist/knowledge/guard-bytecode-spec.d.ts +0 -82
  192. package/dist/knowledge/guard-bytecode-spec.js +0 -1
  193. package/dist/knowledge/guard-confirm.d.ts +0 -86
  194. package/dist/knowledge/guard-confirm.js +0 -1
  195. package/dist/knowledge/immutability.d.ts +0 -11
  196. package/dist/knowledge/immutability.js +0 -1
  197. package/dist/knowledge/machine-confirm.d.ts +0 -102
  198. package/dist/knowledge/machine-confirm.js +0 -1
  199. package/dist/knowledge/machine-context.d.ts +0 -160
  200. package/dist/knowledge/machine-context.js +0 -1
  201. package/dist/knowledge/machine-render.d.ts +0 -41
  202. package/dist/knowledge/machine-render.js +0 -1
  203. package/dist/knowledge/mcp-schema-audit-cli.d.ts +0 -1
  204. package/dist/knowledge/mcp-schema-audit-cli.js +0 -1
  205. package/dist/knowledge/mcp-schema-audit.d.ts +0 -91
  206. package/dist/knowledge/mcp-schema-audit.js +0 -1
  207. package/dist/knowledge/messenger-guard-guidance.d.ts +0 -17
  208. package/dist/knowledge/messenger-guard-guidance.js +0 -1
  209. package/dist/knowledge/order-confirm.d.ts +0 -115
  210. package/dist/knowledge/order-confirm.js +0 -1
  211. package/dist/knowledge/order-context.d.ts +0 -66
  212. package/dist/knowledge/order-context.js +0 -1
  213. package/dist/knowledge/order-translation.d.ts +0 -78
  214. package/dist/knowledge/order-translation.js +0 -1
  215. package/dist/knowledge/overrides-loader.d.ts +0 -13
  216. package/dist/knowledge/overrides-loader.js +0 -1
  217. package/dist/knowledge/passport-confirm.d.ts +0 -130
  218. package/dist/knowledge/passport-confirm.js +0 -1
  219. package/dist/knowledge/passport-context.d.ts +0 -59
  220. package/dist/knowledge/passport-context.js +0 -1
  221. package/dist/knowledge/passport-puzzle.d.ts +0 -108
  222. package/dist/knowledge/passport-puzzle.js +0 -1
  223. package/dist/knowledge/passport-risk.d.ts +0 -70
  224. package/dist/knowledge/passport-risk.js +0 -1
  225. package/dist/knowledge/passport-translation.d.ts +0 -68
  226. package/dist/knowledge/passport-translation.js +0 -1
  227. package/dist/knowledge/payment-confirm.d.ts +0 -26
  228. package/dist/knowledge/payment-confirm.js +0 -1
  229. package/dist/knowledge/payment-translation.d.ts +0 -37
  230. package/dist/knowledge/payment-translation.js +0 -1
  231. package/dist/knowledge/permission-confirm.d.ts +0 -110
  232. package/dist/knowledge/permission-confirm.js +0 -1
  233. package/dist/knowledge/permission-context.d.ts +0 -69
  234. package/dist/knowledge/permission-context.js +0 -1
  235. package/dist/knowledge/permission-translation.d.ts +0 -57
  236. package/dist/knowledge/permission-translation.js +0 -1
  237. package/dist/knowledge/personal-confirm.d.ts +0 -29
  238. package/dist/knowledge/personal-confirm.js +0 -1
  239. package/dist/knowledge/personal-translation.d.ts +0 -37
  240. package/dist/knowledge/personal-translation.js +0 -1
  241. package/dist/knowledge/process-model.d.ts +0 -14
  242. package/dist/knowledge/process-model.js +0 -1
  243. package/dist/knowledge/progress-confirm.d.ts +0 -108
  244. package/dist/knowledge/progress-confirm.js +0 -1
  245. package/dist/knowledge/progress-context.d.ts +0 -123
  246. package/dist/knowledge/progress-context.js +0 -1
  247. package/dist/knowledge/progress-translation.d.ts +0 -52
  248. package/dist/knowledge/progress-translation.js +0 -1
  249. package/dist/knowledge/proof-confirm.d.ts +0 -31
  250. package/dist/knowledge/proof-confirm.js +0 -1
  251. package/dist/knowledge/proof-context.d.ts +0 -17
  252. package/dist/knowledge/proof-context.js +0 -1
  253. package/dist/knowledge/proof-ledger.d.ts +0 -34
  254. package/dist/knowledge/proof-ledger.js +0 -1
  255. package/dist/knowledge/proof-puzzle.d.ts +0 -35
  256. package/dist/knowledge/proof-puzzle.js +0 -1
  257. package/dist/knowledge/proof-templates.d.ts +0 -22
  258. package/dist/knowledge/proof-templates.js +0 -1
  259. package/dist/knowledge/proof-translation.d.ts +0 -52
  260. package/dist/knowledge/proof-translation.js +0 -1
  261. package/dist/knowledge/registrar-confirm.d.ts +0 -26
  262. package/dist/knowledge/registrar-confirm.js +0 -1
  263. package/dist/knowledge/registrar-translation.d.ts +0 -37
  264. package/dist/knowledge/registrar-translation.js +0 -1
  265. package/dist/knowledge/repository-confirm.d.ts +0 -40
  266. package/dist/knowledge/repository-confirm.js +0 -1
  267. package/dist/knowledge/repository-context.d.ts +0 -12
  268. package/dist/knowledge/repository-context.js +0 -1
  269. package/dist/knowledge/repository-ledger.d.ts +0 -25
  270. package/dist/knowledge/repository-ledger.js +0 -1
  271. package/dist/knowledge/repository-puzzle.d.ts +0 -30
  272. package/dist/knowledge/repository-puzzle.js +0 -1
  273. package/dist/knowledge/repository-templates.d.ts +0 -14
  274. package/dist/knowledge/repository-templates.js +0 -1
  275. package/dist/knowledge/repository-translation.d.ts +0 -58
  276. package/dist/knowledge/repository-translation.js +0 -1
  277. package/dist/knowledge/resource-confirm.d.ts +0 -25
  278. package/dist/knowledge/resource-confirm.js +0 -1
  279. package/dist/knowledge/resource-translation.d.ts +0 -37
  280. package/dist/knowledge/resource-translation.js +0 -1
  281. package/dist/knowledge/reward-confirm.d.ts +0 -116
  282. package/dist/knowledge/reward-confirm.js +0 -1
  283. package/dist/knowledge/reward-context.d.ts +0 -127
  284. package/dist/knowledge/reward-context.js +0 -1
  285. package/dist/knowledge/reward-translation.d.ts +0 -58
  286. package/dist/knowledge/reward-translation.js +0 -1
  287. package/dist/knowledge/service-confirm.d.ts +0 -161
  288. package/dist/knowledge/service-confirm.js +0 -1
  289. package/dist/knowledge/service-context.d.ts +0 -66
  290. package/dist/knowledge/service-context.js +0 -1
  291. package/dist/knowledge/service-translation.d.ts +0 -103
  292. package/dist/knowledge/service-translation.js +0 -1
  293. package/dist/knowledge/treasury-confirm.d.ts +0 -133
  294. package/dist/knowledge/treasury-confirm.js +0 -1
  295. package/dist/knowledge/treasury-context.d.ts +0 -64
  296. package/dist/knowledge/treasury-context.js +0 -1
  297. package/dist/knowledge/treasury-translation.d.ts +0 -78
  298. package/dist/knowledge/treasury-translation.js +0 -1
  299. package/dist/knowledge/util-confirm.d.ts +0 -24
  300. package/dist/knowledge/util-confirm.js +0 -1
  301. package/dist/knowledge/util-translation.d.ts +0 -39
  302. package/dist/knowledge/util-translation.js +0 -1
  303. package/dist/loop-engineering/aggregate.d.ts +0 -50
  304. package/dist/loop-engineering/aggregate.js +0 -1
  305. package/dist/loop-engineering/context-collect.d.ts +0 -7
  306. package/dist/loop-engineering/context-collect.js +0 -1
  307. package/dist/loop-engineering/diagnose.d.ts +0 -22
  308. package/dist/loop-engineering/diagnose.js +0 -1
  309. package/dist/loop-engineering/improve.d.ts +0 -55
  310. package/dist/loop-engineering/improve.js +0 -1
  311. package/dist/loop-engineering/index.d.ts +0 -4
  312. package/dist/loop-engineering/index.js +0 -1
  313. package/dist/loop-engineering/pipeline.d.ts +0 -17
  314. package/dist/loop-engineering/pipeline.js +0 -1
  315. package/dist/schema/utils/object-type-utils.d.ts +0 -12
  316. package/dist/schema/utils/object-type-utils.js +0 -1
  317. package/dist/telemetry/index.d.ts +0 -19
  318. package/dist/telemetry/index.js +0 -1
  319. package/dist/telemetry/redact.d.ts +0 -2
  320. package/dist/telemetry/redact.js +0 -1
  321. package/dist/telemetry/storage.d.ts +0 -8
  322. package/dist/telemetry/storage.js +0 -1
@@ -1 +0,0 @@
1
- import{analyzeTopology}from'./machine-topology.js';import{USER_DEFINED_PERM_INDEX_START,MAX_NODE_COUNT,MAX_NODE_PAIR_COUNT,MAX_FORWARD_COUNT,MAX_FORWARD_ORDER_COUNT}from'./onchain-constants.js';import{assessMachineRisks}from'./machine-risk.js';import{derivePuzzleFromMachineJson,generateConfirmationText}from'./machine-puzzle.js';export const PUBLISH_CHECKLIST=[{'id':'C-01','description':'Entry\x20point\x20exists:\x20at\x20least\x20one\x20Pair\x20with\x20prev_node=\x27\x27','status':'skip','detail':'Workflow\x20cannot\x20start\x20without\x20entry\x20Pair.\x20Verify\x20Pair\x20table\x20for\x20empty\x20prev_node.'},{'id':'C-02','description':'Every\x20node\x20has\x20outgoing\x20Forwards\x20(except\x20terminal\x20nodes)','status':'skip','detail':'Dead-end\x20nodes\x20trap\x20workflow.\x20Identify\x20terminals\x20and\x20verify\x20they\x20are\x20intended.'},{'id':'C-03','description':'Every\x20node\x20has\x20incoming\x20Pair\x20(except\x20entry\x20point)','status':'skip','detail':'Orphaned\x20nodes\x20are\x20unreachable.\x20Verify\x20all\x20non-entry\x20nodes\x20are\x20reachable.'},{'id':'C-04','description':'All\x20thresholds\x20independently\x20achievable\x20(no\x20dead\x20branches)','status':'skip','detail':'If\x20a\x20competing\x20Pair\x20always\x20loses,\x20it\x20is\x20dead\x20code.\x20Use\x20topology\x20analysis.'},{'id':'C-05','description':'All\x20Guards\x20exist\x20on-chain\x20and\x20tested\x20(via\x20gen_passport)','status':'skip','detail':'Guard\x20addresses\x20referenced\x20in\x20forwards\x20must\x20be\x20valid\x20published\x20Guard\x20objects.'},{'id':'C-06','description':'namedOperator\x20vs\x20permissionIndex\x20correct\x20per\x20Forward','status':'skip','detail':'Each\x20Forward\x20must\x20have\x20at\x20least\x20one\x20of\x20namedOperator\x20or\x20permissionIndex.'},{'id':'C-07','description':'Terminal\x20nodes\x20mapped\x20to\x20Allocator\x20entries\x20for\x20fund\x20distribution','status':'skip','detail':'Terminal\x20nodes\x20without\x20Allocator\x20risk\x20funds\x20being\x20locked\x20forever.'},{'id':'C-08','description':'Tested\x20end-to-end\x20on\x20testnet\x20via\x20a\x20test\x20Progress','status':'skip','detail':'Testnet\x20verification\x20is\x20mandatory\x20before\x20mainnet\x20publish.'},{'id':'C-09','description':'Current\x20state\x20exported\x20via\x20machineNode2file\x20as\x20backup','status':'skip','detail':'Backup\x20before\x20publish.\x20If\x20publish\x20fails,\x20you\x20can\x20rebuild\x20from\x20export.'},{'id':'C-10','description':'On-chain\x20constraint\x20limits\x20respected\x20(MAX_NODE_COUNT='+MAX_NODE_COUNT+',\x20MAX_NODE_PAIR_COUNT='+MAX_NODE_PAIR_COUNT+',\x20MAX_FORWARD_COUNT='+MAX_FORWARD_COUNT+')','status':'skip','detail':'Exceeding\x20on-chain\x20constants\x20will\x20cause\x20transaction\x20failure.'},{'id':'C-11','description':'All\x20permissionIndex\x20values\x20>=\x201000\x20(USER_DEFINED_PERM_INDEX_START)','status':'skip','detail':'On-chain\x20permission.move\x20reserves\x20indexes\x200-999\x20for\x20built-in\x20permissions.\x20'+'Custom\x20permission_index\x20MUST\x20be\x20>=\x201000\x20(see\x20doc\x2006\x20§4.4).\x20'+'Using\x20index\x20<\x201000\x20causes\x20confusion\x20with\x20built-in\x20permissions.'},{'id':'C-12','description':'All\x20Pair\x20thresholds\x20achievable\x20(sum\x20of\x20distinct\x20forward\x20weights\x20>=\x20threshold)','status':'skip','detail':'Each\x20forward\x20is\x20single-operator-locked:\x20it\x20contributes\x20its\x20weight\x20AT\x20MOST\x20ONCE\x20'+'(progress.move\x20session_accomplish_imp;\x20a\x20second\x20operator\x20re-executing\x20the\x20same\x20'+'accomplished\x20forward\x20aborts\x20E_NOT_THE_HOLDER).\x20A\x20Pair\x20whose\x20threshold\x20exceeds\x20the\x20'+'sum\x20of\x20its\x20forward\x20weights\x20can\x20never\x20migrate\x20—\x20the\x20workflow\x20gets\x20permanently\x20stuck.\x20'+'Multi-operator\x20cooperation\x20(threshold\x20>\x201)\x20needs\x20one\x20DISTINCT\x20forward\x20per\x20'+'contributing\x20operator\x20(e.g.\x20threshold\x202\x20→\x20begin_a\x20+\x20begin_b,\x20each\x20weight\x201).'}];export function runStaticChecklist(a){const b=[],c=[],d=[],e=analyzeTopology(a['nodes'],a['pairs']),f=e['entry_nodes']['length']>0x0;b['push']({'id':'C-01','description':'Entry\x20point\x20exists','status':f?'pass':'fail','detail':f?'Found\x20entry\x20nodes:\x20'+e['entry_nodes']['join'](',\x20'):'NO\x20entry\x20Pair\x20with\x20prev_node=\x27\x27'});if(!f)c['push'](b[b['length']-0x1]);const g=a['nodes']['filter'](l=>!e['terminal_nodes']['includes'](l['name'])&&!a['pairs']['some'](m=>m['prev_node']===l['name']));b['push']({'id':'C-02','description':'Every\x20node\x20has\x20outgoing\x20Forwards\x20(except\x20terminals)','status':g['length']===0x0?'pass':'fail','detail':g['length']===0x0?'All\x20non-terminal\x20nodes\x20have\x20outgoing\x20Pairs':'Dead-end\x20nodes:\x20'+g['map'](l=>l['name'])['join'](',\x20')});if(g['length']>0x0)c['push'](b[b['length']-0x1]);b['push']({'id':'C-03','description':'Every\x20node\x20has\x20incoming\x20Pair','status':e['orphaned_nodes']['length']===0x0?'pass':'fail','detail':e['orphaned_nodes']['length']===0x0?'All\x20non-entry\x20nodes\x20are\x20reachable':'Orphaned\x20nodes:\x20'+e['orphaned_nodes']['join'](',\x20')});if(e['orphaned_nodes']['length']>0x0)c['push'](b[b['length']-0x1]);b['push']({'id':'C-04','description':'All\x20thresholds\x20achievable','status':e['dead_branches']['length']===0x0?'pass':'warning','detail':e['dead_branches']['length']===0x0?'No\x20dead\x20branches\x20detected':'Potential\x20dead\x20branches:\x20'+e['dead_branches']['length']});if(e['dead_branches']['length']>0x0)d['push'](b[b['length']-0x1]);b['push']({'id':'C-05','description':'All\x20Guards\x20exist\x20on-chain','status':'skip','detail':'Verify\x20at\x20runtime\x20via\x20onchain_objects\x20query\x20for\x20each\x20Guard\x20address'});const h=[];for(const l of a['pairs']){for(const m of l['forwards']){const n=m['named_operator']!==undefined,o=m['permission_index']!==undefined;!n&&!o&&h['push'](l['prev_node']+'->'+l['next_node']+':'+m['name']);}}b['push']({'id':'C-06','description':'Forward\x20permission\x20model\x20correct','status':h['length']===0x0?'pass':'fail','detail':h['length']===0x0?'All\x20Forwards\x20have\x20valid\x20permission':'Invalid\x20Forwards:\x20'+h['join'](',\x20')});if(h['length']>0x0)c['push'](b[b['length']-0x1]);b['push']({'id':'C-07','description':'Terminal\x20nodes\x20have\x20Allocator','status':'skip','detail':'Verify\x20at\x20Service\x20binding\x20stage'}),b['push']({'id':'C-08','description':'Testnet\x20test\x20passed','status':'skip','detail':'Verify\x20at\x20Layer\x204\x20(environment)'}),b['push']({'id':'C-09','description':'machineNode2file\x20backup\x20created','status':'skip','detail':'Recommend\x20exporting\x20before\x20publish'});const i=[];if(!e['within_limits']['max_node_count'])i['push']('MAX_NODE_COUNT='+MAX_NODE_COUNT);if(!e['within_limits']['max_node_pair_count'])i['push']('MAX_NODE_PAIR_COUNT='+MAX_NODE_PAIR_COUNT);if(!e['within_limits']['max_forward_count'])i['push']('MAX_FORWARD_COUNT='+MAX_FORWARD_COUNT);if(!e['within_limits']['max_forward_order_count'])i['push']('MAX_FORWARD_ORDER_COUNT='+MAX_FORWARD_ORDER_COUNT);b['push']({'id':'C-10','description':'On-chain\x20limits\x20respected','status':i['length']===0x0?'pass':'fail','detail':i['length']===0x0?'All\x20limits\x20within\x20bounds':'Violations:\x20'+i['join'](',\x20')});if(i['length']>0x0)c['push'](b[b['length']-0x1]);const j=[];for(const p of a['pairs']){for(const q of p['forwards']){q['permission_index']!==undefined&&q['permission_index']!==null&&q['permission_index']<USER_DEFINED_PERM_INDEX_START&&j['push'](p['prev_node']+'->'+p['next_node']+':'+q['name']+'\x20(idx='+q['permission_index']+')');}}b['push']({'id':'C-11','description':'permissionIndex\x20>=\x20'+USER_DEFINED_PERM_INDEX_START,'status':j['length']===0x0?'pass':'fail','detail':j['length']===0x0?'All\x20permission_index\x20values\x20>=\x20'+USER_DEFINED_PERM_INDEX_START:'permission_index\x20<\x20'+USER_DEFINED_PERM_INDEX_START+':\x20'+j['join'](',\x20')});if(j['length']>0x0)c['push'](b[b['length']-0x1]);const k=e['unachievable_thresholds'];b['push']({'id':'C-12','description':'All\x20Pair\x20thresholds\x20achievable\x20(sum\x20of\x20distinct\x20forward\x20weights\x20>=\x20threshold)','status':k['length']===0x0?'pass':'fail','detail':k['length']===0x0?'Every\x20Pair\x20threshold\x20is\x20reachable\x20by\x20its\x20distinct\x20forward\x20weights':'Unreachable\x20thresholds:\x20'+k['map'](r=>(r['prev_node']===''?'entry':r['prev_node'])+'->'+r['next_node']+'\x20(thr='+r['threshold']+',\x20max='+r['max_achievable']+')')['join'](';\x20')+'\x20—\x20add\x20one\x20DISTINCT\x20forward\x20per\x20contributing\x20operator\x20or\x20lower\x20the\x20threshold'});if(k['length']>0x0)c['push'](b[b['length']-0x1]);return{'passed':c['length']===0x0,'checked_items':b,'failed_items':c,'warnings':d};}export function integrateRiskAssessment(a,b){const c={'nodes':a['nodes'],'pairs':a['pairs'],'b_published':a['b_published'],'b_paused':a['b_paused'],'scene_id':a['scene_id']},d=assessMachineRisks(c,b),e=[],f=[];for(const h of d['detected_risks']){if(h['severity']==='critical'||h['severity']==='high')e['push'](h['rule_id']);else h['severity']==='medium'&&f['push'](h['rule_id']);}let g;if(e['some'](i=>{const j=d['detected_risks']['find'](k=>k['rule_id']===i);return j?.['severity']==='critical';}))g='do_not_publish';else{if(e['length']>0x0)g='fix_first';else f['length']>0x3?g='fix_first':g='publish';}return{'overall_risk_level':d['overall_level'],'blocking_risks':e,'warning_risks':f,'recommendation':g};}export const CONFIRMATION_QUESTIONS=[{'id':'Q1','question':'Reviewed\x20topology\x20and\x20confirmed\x20all\x20nodes/forwards\x20are\x20correct?','expected_response':'yes','blocking':!![]},{'id':'Q2','question':'Tested\x20this\x20Machine\x20on\x20TESTNET\x20with\x20a\x20successful\x20Progress\x20run?','expected_response':'yes','blocking':!![]},{'id':'Q3','question':'All\x20Guards\x20created,\x20bound,\x20and\x20verified\x20via\x20gen_passport?','expected_response':'yes','blocking':!![]},{'id':'Q4','question':'All\x20Allocators\x20configured\x20for\x20terminal\x20nodes?','expected_response':'yes','blocking':!![]},{'id':'Q5','question':'Acknowledge\x20that\x20publishing\x20is\x20IRREVERSIBLE\x20and\x20gas\x20will\x20be\x20consumed?','expected_response':'yes','blocking':!![]},{'id':'Q6','question':'Proceed\x20with\x20publishing\x20this\x20Machine\x20NOW?','expected_response':'yes','blocking':!![]}];export function parseUserConfirmation(a){const b=a['split'](',')['map'](e=>e['trim']()['toLowerCase']()),c=[];for(let e=0x0;e<CONFIRMATION_QUESTIONS['length'];e++){const f=CONFIRMATION_QUESTIONS[e],g=b[e]||'(no\x20answer)',h=g['startsWith']('y')||g==='yes',j=g['startsWith']('n')||g==='no';c['push']({'question_id':f['id'],'response':h?'yes':j?'no':'unclear','raw_input':g});}const d=CONFIRMATION_QUESTIONS['filter'](k=>k['blocking'])['every']((k,l)=>c[l]['response']==='yes');return{'questions_asked':CONFIRMATION_QUESTIONS,'user_responses':c,'approved':d,'declined_reason':d?undefined:'One\x20or\x20more\x20blocking\x20questions\x20answered\x20\x27no\x27','timestamp':new Date()['toISOString']()};}export function generateFullConfirmationText(a,b,c){const d=derivePuzzleFromMachineJson({'nodes':a['nodes'],'pairs':a['pairs'],'scene_id':a['scene_id'],'template_id':a['template_id']}),e=generateConfirmationText(d),f=['╔═══════════════════════════════════════════════════════════════╗','║\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20MACHINE\x20PUBLISH\x20CONFIRMATION\x20REQUIRED\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20║','╚═══════════════════════════════════════════════════════════════╝','','⚠️\x20\x20WARNING:\x20Publishing\x20a\x20Machine\x20is\x20IRREVERSIBLE.','\x20\x20\x20-\x20Nodes,\x20Pairs,\x20Forwards\x20will\x20be\x20FROZEN\x20permanently.','\x20\x20\x20-\x20Gas\x20will\x20be\x20consumed\x20(cannot\x20be\x20refunded).','\x20\x20\x20-\x20Any\x20error\x20requires\x20creating\x20a\x20NEW\x20Machine\x20(with\x20new\x20gas\x20cost).','','═══════════════════════════════════════════════════════════════',e,'═══════════════════════════════════════════════════════════════','RISK\x20ASSESSMENT:','\x20\x20Overall\x20Risk\x20Level:\x20'+c['overall_risk_level']['toUpperCase'](),'\x20\x20Recommendation:\x20\x20\x20\x20\x20'+c['recommendation'],'\x20\x20Blocking\x20Risks:\x20\x20\x20\x20\x20'+(c['blocking_risks']['length']===0x0?'None':c['blocking_risks']['join'](',\x20')),'\x20\x20Warning\x20Risks:\x20\x20\x20\x20\x20'+(c['warning_risks']['length']===0x0?'None':c['warning_risks']['join'](',\x20')),'','═══════════════════════════════════════════════════════════════','STATIC\x20CHECKLIST:','\x20\x20Passed:\x20\x20\x20\x20'+b['checked_items']['filter'](g=>g['status']==='pass')['length']+'\x20/\x20'+b['checked_items']['length'],'\x20\x20Failed:\x20\x20\x20\x20'+b['failed_items']['length'],'\x20\x20Warnings:\x20\x20'+b['warnings']['length'],'\x20\x20Skipped:\x20\x20\x20'+b['checked_items']['filter'](g=>g['status']==='skip')['length'],'',...b['failed_items']['map'](g=>'\x20\x20❌\x20'+g['id']+':\x20'+g['description']+'\x20—\x20'+(g['detail']||'')),...b['warnings']['map'](g=>'\x20\x20⚠️\x20\x20'+g['id']+':\x20'+g['description']+'\x20—\x20'+(g['detail']||'')),'','═══════════════════════════════════════════════════════════════','USER\x20CONFIRMATION\x20QUESTIONS:','',...CONFIRMATION_QUESTIONS['map']((g,h)=>'\x20\x20Q'+(h+0x1)+'.\x20'+g['question']+'\x20[Yes\x20/\x20No]'),'','If\x20you\x20answer\x20\x27No\x27\x20to\x20ANY\x20of\x20Q1-Q5,\x20publish\x20will\x20be\x20BLOCKED.','If\x20you\x20answer\x20\x27No\x27\x20to\x20Q6,\x20publish\x20will\x20be\x20CANCELLED\x20(no\x20gas\x20spent).','','Type\x20your\x20answers\x20(Q1-Q6)\x20separated\x20by\x20commas:'];return f['join']('\x0a');}export function verifyEnvironment(a,b,c){const d=[];for(const g of a['pairs']){for(const h of g['forwards']){h['guard']&&!b['published_guards']['has'](h['guard'])&&d['push']('Guard:\x20'+h['guard']);}}const e=b['testnet_test_passed'],f=c?e:!![];return{'is_testnet':!c,'has_testnet_test_passed':f,'gas_estimation':b['gas_estimation'],'dependency_table_complete':d['length']===0x0,'missing_dependencies':d};}function hashMachineJson(a){const b=JSON['stringify']({'nodes':a['nodes']['map'](d=>d['name']),'pairs':a['pairs']['map'](d=>({'prev':d['prev_node'],'next':d['next_node'],'threshold':d['threshold'],'forwards':d['forwards']['map'](e=>e['name'])}))});let c=0x0;for(let d=0x0;d<b['length'];d++){const e=b['charCodeAt'](d);c=(c<<0x5)-c+e,c=c&c;}return'0x'+(c>>>0x0)['toString'](0x10)['padStart'](0x8,'0');}export function confirmPublish(a,b,c,d){const e={'timestamp':new Date()['toISOString'](),'user_address':b['user_address'],'machine_json_hash':hashMachineJson(a),'template_id':a['template_id'],'scene_id':a['scene_id'],'final_status':'blocked_checklist'},f=runStaticChecklist(a);if(!f['passed'])return{'status':'blocked_checklist','checklist_result':f,'decision_record':{...e,'final_status':'blocked_checklist'},'block_reason':'Checklist\x20failed:\x20'+f['failed_items']['map'](j=>j['id'])['join'](',\x20')};const g=integrateRiskAssessment(a,b);if(g['recommendation']==='do_not_publish')return{'status':'blocked_risk','checklist_result':f,'risk_result':g,'decision_record':{...e,'final_status':'blocked_risk'},'block_reason':'Critical\x20risks\x20detected:\x20'+g['blocking_risks']['join'](',\x20')};if(!d){const j=generateFullConfirmationText(a,f,g);return{'status':'blocked_user','checklist_result':f,'risk_result':g,'confirmation_text':j,'decision_record':{...e,'final_status':'blocked_user'},'block_reason':'Awaiting\x20user\x20confirmation'};}const h=parseUserConfirmation(d);if(!h['approved'])return{'status':'blocked_user','checklist_result':f,'risk_result':g,'user_confirmation':h,'decision_record':{...e,'final_status':'blocked_user'},'block_reason':h['declined_reason']||'User\x20declined'};const i=verifyEnvironment(a,b,c);if(!i['dependency_table_complete']||!i['has_testnet_test_passed']){const k=[];return!i['dependency_table_complete']&&k['push']('missing\x20dependencies:\x20'+i['missing_dependencies']['join'](',\x20')),!i['has_testnet_test_passed']&&k['push']('testnet\x20test\x20not\x20passed\x20(required\x20for\x20mainnet)'),{'status':'blocked_environment','checklist_result':f,'risk_result':g,'user_confirmation':h,'environment_result':i,'decision_record':{...e,'final_status':'blocked_environment'},'block_reason':'Environment\x20issues:\x20'+k['join'](';\x20')};}return{'status':'approved','checklist_result':f,'risk_result':g,'user_confirmation':h,'environment_result':i,'decision_record':{...e,'final_status':'approved'}};}export function overrideBlockWithReason(a,b){if(a['status']!=='blocked_risk')return a;const c=a['risk_result']?.['blocking_risks']['some'](d=>d['includes']('CRITICAL')||d['includes']('critical'));if(c)return{...a,'block_reason':'Cannot\x20override\x20CRITICAL\x20risks'};return{...a,'status':'approved','block_reason':undefined,'decision_record':{...a['decision_record'],'final_status':'approved'}};}export function progressiveCheck(a,b){const c=runStaticChecklist(a);if(b==='R5')return filterChecklist(c,['C-01','C-02','C-03','C-04','C-06','C-10']);if(b==='R6')return filterChecklist(c,['C-01','C-02','C-03','C-04','C-05','C-06','C-10']);return c;}function filterChecklist(a,b){const c=a['checked_items']['filter'](d=>b['includes'](d['id']));return{'passed':c['filter'](d=>d['status']==='fail')['length']===0x0,'checked_items':c,'failed_items':c['filter'](d=>d['status']==='fail'),'warnings':c['filter'](d=>d['status']==='warning')};}export function prePublishHook(a,b,c){const d=confirmPublish(a,b,c);if(d['status']!=='blocked_user'&&d['status']!=='approved')return{'proceed':![],'error':formatBlockError(d),'confirmGateResult':d};if(d['status']==='blocked_user'&&d['confirmation_text'])return{'proceed':![],'error':d['confirmation_text'],'confirmGateResult':d};return{'proceed':!![],'confirmGateResult':d};}export function postConfirmationHook(a,b,c,d){const e=confirmPublish(a,b,c,d);if(e['status']!=='approved')return{'proceed':![],'error':formatBlockError(e),'confirmGateResult':e};return{'proceed':!![],'confirmGateResult':e};}export function formatBlockError(a){const b=['❌\x20MACHINE\x20PUBLISH\x20BLOCKED','','Status:\x20'+a['status'],'Reason:\x20'+(a['block_reason']||'(no\x20reason\x20provided)'),''];if(a['status']==='blocked_checklist'){b['push']('Failed\x20checklist\x20items:');for(const c of a['checklist_result']['failed_items']){b['push']('\x20\x20-\x20'+c['id']+':\x20'+c['description']),b['push']('\x20\x20\x20\x20Detail:\x20'+(c['detail']||'(no\x20detail)'));}}if(a['status']==='blocked_risk'&&a['risk_result']){b['push']('Blocking\x20risks:');for(const d of a['risk_result']['blocking_risks']){b['push']('\x20\x20-\x20'+d);}b['push'](''),b['push']('Recommendation:\x20'+a['risk_result']['recommendation']);}if(a['status']==='blocked_environment'&&a['environment_result']){b['push']('Environment\x20issues:');for(const e of a['environment_result']['missing_dependencies']){b['push']('\x20\x20-\x20Missing\x20dependency:\x20'+e);}!a['environment_result']['has_testnet_test_passed']&&b['push']('\x20\x20-\x20Testnet\x20test\x20NOT\x20passed\x20(required\x20for\x20mainnet)');}return b['join']('\x0a');}export const MACHINE_CONFIRM_VERSION='1.0.0';export const MACHINE_CHECKLIST_ITEMS_COUNT=PUBLISH_CHECKLIST['length'];export const MACHINE_CONFIRMATION_QUESTIONS_COUNT=CONFIRMATION_QUESTIONS['length'];
@@ -1,160 +0,0 @@
1
- import { type MachineScene } from "./machine-ledger.js";
2
- import { type MachineTemplate } from "./machine-templates.js";
3
- import { type SemanticToMachineRule, type MachineConstraintRule } from "./machine-translation.js";
4
- import { type MachineRiskRule, type MachineRiskAssessment, type ProjectContextForRisk } from "./machine-risk.js";
5
- import { type MachineTopology, type MachineNode, type MachinePair } from "./machine-topology.js";
6
- import { type MachinePuzzle, type PuzzleCompleteness } from "./machine-puzzle.js";
7
- import { type ChecklistResult } from "./machine-confirm.js";
8
- import { type GuardScene } from "./guard-ledger.js";
9
- export declare const MACHINE_CONTEXT_VERSION = "1.0.0";
10
- export interface VerificationNote {
11
- topic: "bReplace" | "um" | "consensus_repositories" | "namedOperator_assignment" | "cross_machine_dependency" | "first_node_semantics_service_bound";
12
- judgment: "YES" | "PARTIAL" | "NO";
13
- verified_semantic: string;
14
- code_reference: string;
15
- affected_modes: ContextInjectionMode[];
16
- }
17
- export declare const MACHINE_VERIFICATION_NOTES: VerificationNote[];
18
- export type ContextInjectionMode = "initial_design" | "mid_design_review" | "pre_publish_check" | "post_publish_runtime" | "intent_match" | "cross_machine" | "guard_integration" | "allocation_integration";
19
- export interface InjectionOptions {
20
- max_templates?: number;
21
- max_constraints?: number;
22
- max_risks?: number;
23
- include_verification_notes?: boolean;
24
- include_guard_bridge?: boolean;
25
- existing_puzzle?: MachinePuzzle;
26
- existing_machine_json?: {
27
- nodes: MachineNode[];
28
- pairs: MachinePair[];
29
- scene_id?: string;
30
- template_id?: string;
31
- };
32
- project_context?: ProjectContextForRisk;
33
- filter_execution_mode?: "Sequential" | "Parallel AND" | "Parallel OR" | "Weighted Voting" | "Hybrid";
34
- filter_topology?: "Linear" | "ForkMerge" | "Competing";
35
- }
36
- export interface GuardBridgeInfo {
37
- machine_scene_id: string;
38
- guard_scenes: GuardScene[];
39
- forward_guard_mapping: Array<{
40
- forward_purpose: string;
41
- guard_scene_id: string;
42
- guard_scene_name: string;
43
- }>;
44
- }
45
- export interface WorkflowSuggestion {
46
- matched_scene: MachineScene | null;
47
- confidence: number;
48
- suggested_templates: Array<{
49
- template: MachineTemplate;
50
- rationale: string;
51
- }>;
52
- initial_puzzle: MachinePuzzle;
53
- recommended_pattern: SemanticToMachineRule | null;
54
- recommended_topology: string | null;
55
- next_step: string;
56
- }
57
- export interface MachineContextBundle {
58
- mode: ContextInjectionMode;
59
- version: string;
60
- matched_scene?: MachineScene;
61
- suggested_templates: MachineTemplate[];
62
- relevant_patterns: SemanticToMachineRule[];
63
- relevant_constraints: MachineConstraintRule[];
64
- relevant_risks: MachineRiskRule[];
65
- puzzle_state?: MachinePuzzle;
66
- puzzle_completeness?: PuzzleCompleteness;
67
- topology_analysis?: MachineTopology;
68
- risk_assessment?: MachineRiskAssessment;
69
- progressive_check_result?: ChecklistResult;
70
- guard_bridge?: GuardBridgeInfo;
71
- prompt_hints: string[];
72
- verification_notes: VerificationNote[];
73
- recommended_next_action: string;
74
- }
75
- export interface MachineContextSnapshot {
76
- version: string;
77
- modules: {
78
- ledger: string;
79
- templates: string;
80
- translation: string;
81
- risk: string;
82
- topology: string;
83
- puzzle: string;
84
- confirm: string;
85
- };
86
- counts: {
87
- scenes: number;
88
- templates: number;
89
- patterns: number;
90
- constraints: number;
91
- risk_rules: number;
92
- puzzle_dimensions: number;
93
- publish_checklist_items: number;
94
- confirmation_questions: number;
95
- verification_notes: number;
96
- };
97
- verification_summary: {
98
- total_topics: number;
99
- verified_yes: number;
100
- verified_partial: number;
101
- verified_no: number;
102
- topics: VerificationNote[];
103
- };
104
- guard_bridge: {
105
- available: boolean;
106
- guard_scenes_count: number;
107
- };
108
- on_chain_limits: {
109
- max_node_count: number;
110
- max_node_pair_count: number;
111
- max_forward_count: number;
112
- };
113
- }
114
- export declare function getMachineKnowledgeSnapshot(): MachineContextSnapshot;
115
- export declare function injectMachineContext(intent: string, mode: ContextInjectionMode, options?: InjectionOptions): MachineContextBundle;
116
- export declare function suggestWorkflow(intent: string): WorkflowSuggestion;
117
- export declare function buildPromptFromContext(bundle: MachineContextBundle): string;
118
- export declare function getRelatedGuardScenes(machineSceneId: string): GuardScene[];
119
- export declare function getVerificationNotes(mode?: ContextInjectionMode): VerificationNote[];
120
- export interface CrossMachineDependency {
121
- machine_a_id: string;
122
- machine_b_id: string;
123
- machine_b_published: boolean;
124
- dependency: {
125
- machine_a_forward: string;
126
- machine_b_node: string;
127
- };
128
- guard_query: string;
129
- }
130
- export interface GuardResolution {
131
- upstream_machine_id: string;
132
- upstream_node_name: string;
133
- guard_query_description: string;
134
- }
135
- export declare function identifyCrossMachineDependency(machineAId: string, machineJson: {
136
- nodes: MachineNode[];
137
- pairs: MachinePair[];
138
- }, guardResolutions: Map<string, GuardResolution>, publishedMachineIds?: Set<string>): CrossMachineDependency[];
139
- export declare function detectCrossMachineCycle(allDependencies: CrossMachineDependency[]): string[][];
140
- export declare function aggregateProjectDependencies(machines: Array<{
141
- machine_id: string;
142
- machine_json: {
143
- nodes: MachineNode[];
144
- pairs: MachinePair[];
145
- };
146
- guard_resolutions: Map<string, GuardResolution>;
147
- }>, publishedMachineIds?: Set<string>): CrossMachineDependency[];
148
- export declare const CONTEXT_PRESETS: {
149
- readonly newUserIntent: (intent: string) => MachineContextBundle;
150
- readonly midDesignReview: (intent: string, puzzle: MachinePuzzle) => MachineContextBundle;
151
- readonly prePublishFull: (intent: string, machineJson: {
152
- nodes: MachineNode[];
153
- pairs: MachinePair[];
154
- scene_id?: string;
155
- template_id?: string;
156
- }, projectContext: ProjectContextForRisk) => MachineContextBundle;
157
- readonly crossMachine: (intent: string) => MachineContextBundle;
158
- readonly guardIntegration: (intent: string) => MachineContextBundle;
159
- readonly allocationIntegration: (intent: string) => MachineContextBundle;
160
- };
@@ -1 +0,0 @@
1
- import{MACHINE_LEDGER_VERSION,MACHINE_SCENES_COUNT,findScene,inferSceneFromFlow}from'./machine-ledger.js';import{MAX_NODE_COUNT,MAX_NODE_PAIR_COUNT,MAX_FORWARD_COUNT}from'./onchain-constants.js';import{MACHINE_TEMPLATES,MACHINE_TEMPLATES_VERSION,getAllTemplates,getTemplatesByScene,suggestTemplateForIntent}from'./machine-templates.js';import{SEMANTIC_TO_MACHINE_RULES,MACHINE_CONSTRAINT_RULES,MACHINE_TRANSLATION_VERSION,matchSemanticPattern}from'./machine-translation.js';import{MACHINE_RISK_RULES,MACHINE_RISK_VERSION,assessMachineRisks}from'./machine-risk.js';import{analyzeTopology,formatTopologySummary,MACHINE_TOPOLOGY_VERSION}from'./machine-topology.js';import{initPuzzleFromIntent,initPuzzleFromTemplate,checkPuzzleCompleteness,MACHINE_PUZZLE_VERSION}from'./machine-puzzle.js';import{PUBLISH_CHECKLIST,CONFIRMATION_QUESTIONS,MACHINE_CONFIRM_VERSION,progressiveCheck}from'./machine-confirm.js';import{GUARD_SCENES}from'./guard-ledger.js';export const MACHINE_CONTEXT_VERSION='1.0.0';export const MACHINE_VERIFICATION_NOTES=[{'topic':'bReplace','judgment':'YES','verified_semantic':'bReplace\x20acts\x20at\x20the\x20pairs-list\x20level\x20of\x20an\x20ALREADY-EXISTING\x20node,\x20'+'NOT\x20at\x20the\x20whole-Machine\x20level.\x20bReplace=false\x20merges\x20new\x20pairs\x20into\x20the\x20'+'existing\x20node\x27s\x20pairs\x20list;\x20bReplace=true\x20replaces\x20that\x20node\x27s\x20pairs\x20list\x20entirely.','code_reference':'d:\x5cwowok\x5cagent\x5cmcp\x5csrc\x5ctools\x5cmachine.ts\x20(node\x20ops)','affected_modes':['initial_design','mid_design_review','pre_publish_check']},{'topic':'um','judgment':'PARTIAL','verified_semantic':'um\x20is\x20a\x20Messenger\x20Contact\x20object\x20reference\x20(off-chain\x20session\x20metadata).\x20'+'It\x20does\x20NOT\x20participate\x20in\x20any\x20on-chain\x20flow\x20logic;\x20omitting\x20it\x20has\x20zero\x20on-chain\x20impact.','code_reference':'machine.move\x20(no\x20um\x20field\x20in\x20on-chain\x20Machine)','affected_modes':['initial_design','mid_design_review']},{'topic':'consensus_repositories','judgment':'PARTIAL','verified_semantic':'consensus_repositories\x20is\x20a\x20declarative-only\x20field.\x20It\x20is\x20NOT\x20consumed\x20by\x20any\x20'+'on-chain\x20flow\x20logic\x20—\x20it\x20is\x20a\x20hint\x20for\x20off-chain\x20tooling\x20and\x20human\x20auditors.','code_reference':'machine.move\x20(no\x20consensus_repositories\x20field)','affected_modes':['initial_design','mid_design_review']},{'topic':'namedOperator_assignment','judgment':'PARTIAL','verified_semantic':'Move\x20progress::new\x20does\x20NOT\x20accept\x20namedOperator\x20parameter.\x20The\x20MCP/SDK\x20layer\x20'+'translates\x20the\x20API\x20parameter\x20into\x20a\x20separate\x20namedOperator_add\x20transaction\x20'+'(requires\x20permission\x20index\x20221).\x20At\x20runtime,\x20Forward\x20checks\x20namedOperator\x20membership.','code_reference':'progress.move\x20(progress::new\x20signature)\x20+\x20agent\x5cmcp\x5csrc\x5ctools\x5cprogress.ts\x20(namedOperator_add)','affected_modes':['initial_design','mid_design_review','pre_publish_check']},{'topic':'cross_machine_dependency','judgment':'PARTIAL','verified_semantic':'Cross-Machine\x20dependency\x20is\x20INDIRECT:\x20Machine\x20A\x27s\x20Forward\x20Guard\x20queries\x20Machine\x20B\x27s\x20'+'Progress\x20via\x20convert_witness\x20(TypeOrderProgress=100/103).\x20Machine\x20B\x20must\x20be\x20published\x20'+'before\x20Progress\x20can\x20be\x20created\x20(progress::new\x20->\x20assert_published).','code_reference':'progress.move\x20(progress::new,\x20assert_published)\x20+\x20guard.move\x20(convert_witness)','affected_modes':['cross_machine','pre_publish_check']},{'topic':'first_node_semantics_service_bound','judgment':'YES','verified_semantic':'For\x20Service-bound\x20Machines,\x20the\x20entry\x20node\x20(prev_node=\x27\x27\x20target)\x20represents\x20a\x20'+'POST-PAYMENT\x20state,\x20because\x20Service.buy()\x20performs\x20quote\x20+\x20buy\x20(payment)\x20+\x20'+'order_allocation\x20+\x20order_progress\x20ATOMICALLY\x20in\x20a\x20single\x20transaction.\x20The\x20Machine\x20'+'must\x20NOT\x20include\x20separate\x20\x27Order\x27,\x20\x27Pay\x27,\x20\x27Reserve\x27,\x20or\x20\x27Subscribe\x27\x20nodes\x20—\x20those\x20'+'actions\x20are\x20handled\x20by\x20the\x20Service\x20layer\x20before\x20the\x20Progress\x20(Machine\x20instance)\x20'+'is\x20created.\x20All\x20nodes\x20after\x20entry\x20represent\x20ORDER\x20PROCESSING\x20stages\x20(fulfillment,\x20'+'delivery,\x20confirmation,\x20review,\x20refund),\x20NOT\x20payment\x20actions.\x20Correct\x20entry\x20node\x20'+'examples:\x20\x27Paid\x27,\x20\x27DepositPaid\x27,\x20\x27Active\x27.\x20Incorrect:\x20\x27OrderCreated\x27,\x20\x27Reserved\x27,\x20'+'\x27Subscribed\x27.\x20See\x20machine-ledger.ts\x20first_node_semantics\x20field\x20per\x20scene\x20and\x20'+'machine-templates.ts\x20example_nodes/example_pairs\x20for\x20the\x20canonical\x20structure.','code_reference':'ts-sdk\x5cpackages\x5cwowok\x5csrc\x5cw\x5ccall\x5cservice.ts\x20(buy:\x20quote\x20->\x20buy\x20->\x20order_allocation\x20->\x20order_progress)\x20'+'+\x20machine-ledger.ts\x20(first_node_semantics\x20field)\x20+\x20machine-templates.ts\x20(example_nodes)','affected_modes':['initial_design','mid_design_review','pre_publish_check']}];export function getMachineKnowledgeSnapshot(){const a=MACHINE_VERIFICATION_NOTES['filter'](d=>d['judgment']==='YES')['length'],b=MACHINE_VERIFICATION_NOTES['filter'](d=>d['judgment']==='PARTIAL')['length'],c=MACHINE_VERIFICATION_NOTES['filter'](d=>d['judgment']==='NO')['length'];return{'version':MACHINE_CONTEXT_VERSION,'modules':{'ledger':MACHINE_LEDGER_VERSION,'templates':MACHINE_TEMPLATES_VERSION,'translation':MACHINE_TRANSLATION_VERSION,'risk':MACHINE_RISK_VERSION,'topology':MACHINE_TOPOLOGY_VERSION,'puzzle':MACHINE_PUZZLE_VERSION,'confirm':MACHINE_CONFIRM_VERSION},'counts':{'scenes':MACHINE_SCENES_COUNT,'templates':MACHINE_TEMPLATES['length'],'patterns':SEMANTIC_TO_MACHINE_RULES['length'],'constraints':MACHINE_CONSTRAINT_RULES['length'],'risk_rules':MACHINE_RISK_RULES['length'],'puzzle_dimensions':0x8,'publish_checklist_items':PUBLISH_CHECKLIST['length'],'confirmation_questions':CONFIRMATION_QUESTIONS['length'],'verification_notes':MACHINE_VERIFICATION_NOTES['length']},'verification_summary':{'total_topics':MACHINE_VERIFICATION_NOTES['length'],'verified_yes':a,'verified_partial':b,'verified_no':c,'topics':MACHINE_VERIFICATION_NOTES},'guard_bridge':{'available':!![],'guard_scenes_count':GUARD_SCENES['length']},'on_chain_limits':{'max_node_count':0x64,'max_node_pair_count':0x28,'max_forward_count':0x14}};}export function injectMachineContext(a,b,c={}){const d=c['max_templates']??0x3,e=c['max_constraints']??0xa,f=c['max_risks']??0xa,g=c['include_verification_notes']??!![],h=c['include_guard_bridge']??b==='guard_integration',i=inferSceneFromFlow(a);let j=[];i&&(j=getTemplatesByScene(i['id'])['slice'](0x0,d));if(j['length']===0x0){const w=suggestTemplateForIntent(a);w&&(j=[w]['slice'](0x0,d));}j['length']===0x0&&(j=getAllTemplates()['slice'](0x0,d));let k=[...SEMANTIC_TO_MACHINE_RULES];if(c['filter_execution_mode']){const x={'Sequential':'P-M-SEQ','Parallel\x20AND':'P-M-AND','Parallel\x20OR':'P-M-OR','Weighted\x20Voting':'P-M-VOTE','Hybrid':'P-M-HYBRID'},y=x[c['filter_execution_mode']];y&&(k=k['filter'](z=>z['id']===y));}if(c['filter_topology']){const z={'Linear':'P-M-LINEAR','ForkMerge':'P-M-FORKMERGE','Competing':'P-M-COMPETING'},A=z[c['filter_topology']];A&&(k=k['filter'](B=>B['id']===A));}k=filterPatternsByMode(k,b);let l=filterConstraintsByMode(MACHINE_CONSTRAINT_RULES,b);l=l['slice'](0x0,e);let m=filterRisksByMode(MACHINE_RISK_RULES,b);m=m['slice'](0x0,f);let n,o;if(c['existing_puzzle'])n=c['existing_puzzle'],o=checkPuzzleCompleteness(c['existing_puzzle']);else(b==='initial_design'||b==='intent_match')&&(n=initPuzzleFromIntent(a),o=checkPuzzleCompleteness(n));let p;c['existing_machine_json']&&(p=analyzeTopology(c['existing_machine_json']['nodes'],c['existing_machine_json']['pairs']));let q;if(c['existing_machine_json']&&c['project_context']){const B={'nodes':c['existing_machine_json']['nodes'],'pairs':c['existing_machine_json']['pairs']};q=assessMachineRisks(B,c['project_context']);}let r;if(b==='pre_publish_check'&&c['existing_machine_json']){const C={'nodes':c['existing_machine_json']['nodes'],'pairs':c['existing_machine_json']['pairs'],'template_id':c['existing_machine_json']['template_id'],'scene_id':c['existing_machine_json']['scene_id']};r=progressiveCheck(C,'R5');}let s;h&&i&&(s=buildGuardBridge(i));let t=[];g&&(t=MACHINE_VERIFICATION_NOTES['filter'](D=>D['affected_modes']['includes'](b)));const u=buildPromptHints({'mode':b,'matched_scene':i,'suggested_templates':j,'relevant_patterns':k,'relevant_constraints':l,'relevant_risks':m,'puzzle_state':n,'puzzle_completeness':o,'topology_analysis':p,'risk_assessment':q,'progressive_check_result':r,'guard_bridge':s,'verification_notes':t}),v=recommendNextAction(b,{'matched_scene':i,'suggested_templates':j,'puzzle_completeness':o,'risk_assessment':q,'progressive_check_result':r});return{'mode':b,'version':MACHINE_CONTEXT_VERSION,'matched_scene':i??undefined,'suggested_templates':j,'relevant_patterns':k,'relevant_constraints':l,'relevant_risks':m,'puzzle_state':n,'puzzle_completeness':o,'topology_analysis':p,'risk_assessment':q,'progressive_check_result':r,'guard_bridge':s,'prompt_hints':u,'verification_notes':t,'recommended_next_action':v};}export function suggestWorkflow(a){const b=inferSceneFromFlow(a),c=b?0.8:0.3,d=[];if(b){const k=getTemplatesByScene(b['id']);for(const l of k['slice'](0x0,0x3)){d['push']({'template':l,'rationale':'Template\x20for\x20scene\x20\x22'+b['name']+'\x22'});}}if(d['length']===0x0){const m=suggestTemplateForIntent(a);m&&d['push']({'template':m,'rationale':'Intent\x20keyword\x20match'});}if(d['length']===0x0){const n=getAllTemplates();n['length']>0x0&&d['push']({'template':n[0x0],'rationale':'Default\x20(no\x20specific\x20match)'});}let e;if(d['length']>0x0){const o=initPuzzleFromTemplate(d[0x0]['template']['id']);e=o??initPuzzleFromIntent(a);}else e=initPuzzleFromIntent(a);const f=matchSemanticPattern(a),g=f??null;let h=null;b&&b['recommended_topology']['length']>0x0&&(h=b['recommended_topology'][0x0]);const i=checkPuzzleCompleteness(e),j=i['next_step'];return{'matched_scene':b??null,'confidence':c,'suggested_templates':d,'initial_puzzle':e,'recommended_pattern':g,'recommended_topology':h,'next_step':j};}export function buildPromptFromContext(a){const b=[];b['push']('#\x20Machine\x20Design\x20Context\x20(mode:\x20'+a['mode']+')'),b['push'](''),b['push']('>\x20Context\x20injected\x20by\x20machine-context.ts.\x20Reflects\x20verified\x20on-chain\x20behavior.'),b['push']('');a['matched_scene']&&(b['push']('##\x20Matched\x20Scene'),b['push'](''),b['push']('-\x20**ID**:\x20'+a['matched_scene']['id']),b['push']('-\x20**Name**:\x20'+a['matched_scene']['name']),b['push']('-\x20**Scenario**:\x20'+a['matched_scene']['scenario']),b['push']('-\x20**Industry**:\x20'+a['matched_scene']['industry']['join'](',\x20')),b['push']('-\x20**Recommended\x20patterns**:\x20'+a['matched_scene']['recommended_patterns']['join'](',\x20')),b['push']('-\x20**Recommended\x20topology**:\x20'+a['matched_scene']['recommended_topology']['join'](',\x20')),b['push'](''));if(a['suggested_templates']['length']>0x0){b['push']('##\x20Suggested\x20Templates'),b['push']('');for(const e of a['suggested_templates']){b['push']('###\x20'+e['id']+':\x20'+e['name']),b['push'](''),b['push']('-\x20**Scene**:\x20'+e['scene_id']),b['push']('-\x20**Description**:\x20'+e['description']);if(e['parameters']['length']>0x0){b['push']('-\x20**Parameters**:');for(const f of e['parameters']){b['push']('\x20\x20-\x20`'+f['name']+'`\x20('+f['type']+'):\x20'+f['description']);}}b['push']('');}}if(a['relevant_patterns']['length']>0x0){b['push']('##\x20Relevant\x20Patterns'),b['push']('');for(const g of a['relevant_patterns']){b['push']('###\x20'+g['id']+':\x20'+g['pattern_name']),b['push'](''),b['push']('-\x20**Category**:\x20'+g['category']),b['push']('-\x20**Intent**:\x20'+g['semantic_intent']),g['match_keywords']['length']>0x0&&b['push']('-\x20**Keywords**:\x20'+g['match_keywords']['join'](',\x20')),b['push']('');}}if(a['relevant_constraints']['length']>0x0){b['push']('##\x20Relevant\x20Constraints'),b['push']('');for(const i of a['relevant_constraints']){b['push']('-\x20**'+i['id']+'**\x20('+i['category']+',\x20'+(i['on_chain_enforced']?'on-chain':'off-chain')+'):\x20'+i['description']);}b['push']('');}if(a['relevant_risks']['length']>0x0){b['push']('##\x20Relevant\x20Risks'),b['push']('');for(const j of a['relevant_risks']){b['push']('-\x20**'+j['id']+'**\x20['+j['severity']+']\x20'+j['name']+':\x20'+j['description']),b['push']('\x20\x20-\x20Fix:\x20'+j['recommendation']);}b['push']('');}if(a['puzzle_state']&&a['puzzle_completeness']){b['push']('##\x20Puzzle\x20State'),b['push'](''),b['push']('-\x20**Complete**:\x20'+a['puzzle_completeness']['complete']),b['push']('-\x20**Next\x20step**:\x20'+a['puzzle_completeness']['next_step']),b['push'](''),b['push']('###\x20Per-dimension\x20completeness:');for(const k of a['puzzle_completeness']['dimensions']){const l=k['complete']?'✓':'✗';b['push']('\x20\x20-\x20'+l+'\x20'+k['dimension']),!k['complete']&&k['missing_fields']['length']>0x0&&b['push']('\x20\x20\x20\x20-\x20Missing:\x20'+k['missing_fields']['join'](',\x20'));}b['push']('');}a['topology_analysis']&&(b['push']('##\x20Topology\x20Analysis'),b['push'](''),b['push']('```'),b['push'](formatTopologySummary(a['topology_analysis'])),b['push']('```'),b['push'](''));if(a['risk_assessment']){b['push']('##\x20Risk\x20Assessment'),b['push'](''),b['push']('-\x20**Overall\x20level**:\x20'+a['risk_assessment']['overall_level']),b['push']('-\x20**Recommendation**:\x20'+a['risk_assessment']['recommendation']),b['push']('-\x20**Summary**:\x20'+JSON['stringify'](a['risk_assessment']['summary']));if(a['risk_assessment']['detected_risks']['length']>0x0){b['push'](''),b['push']('###\x20Detected\x20risks:');for(const o of a['risk_assessment']['detected_risks']){b['push']('-\x20['+o['severity']+']\x20'+o['name']+':\x20'+o['detail']);}}b['push']('');}if(a['progressive_check_result']){const q=a['progressive_check_result'];b['push']('##\x20Progressive\x20Checklist\x20Result\x20(R5)'),b['push'](''),b['push']('-\x20**Passed**:\x20'+q['passed']);if(q['checked_items']['length']>0x0){b['push'](''),b['push']('###\x20Checked\x20items:');for(const s of q['checked_items']){b['push']('\x20\x20-\x20['+s['status']+']\x20'+s['id']+':\x20'+s['description']),s['detail']&&b['push']('\x20\x20\x20\x20-\x20'+s['detail']);}}b['push']('');}if(a['guard_bridge']){b['push']('##\x20Guard\x20Bridge'),b['push'](''),b['push']('Machine\x20scene\x20`'+a['guard_bridge']['machine_scene_id']+'`\x20relates\x20to:'),b['push']('');for(const u of a['guard_bridge']['forward_guard_mapping']){b['push']('-\x20Forward\x20\x22'+u['forward_purpose']+'\x22\x20→\x20Guard\x20scene\x20`'+u['guard_scene_id']+'`\x20('+u['guard_scene_name']+')');}b['push']('');}if(a['prompt_hints']['length']>0x0){b['push']('##\x20Prompt\x20Hints'),b['push']('');for(const v of a['prompt_hints']){b['push']('-\x20'+v);}b['push']('');}if(a['verification_notes']['length']>0x0){b['push']('##\x20Verification\x20Notes\x20(06\x20§14)'),b['push'](''),b['push']('>\x20These\x20notes\x20reflect\x20code-level\x20verification\x20of\x20on-chain\x20behavior.');for(const w of a['verification_notes']){b['push'](''),b['push']('-\x20**'+w['topic']+'**\x20('+w['judgment']+'):\x20'+w['verified_semantic']),b['push']('\x20\x20-\x20Code\x20reference:\x20`'+w['code_reference']+'`');}b['push']('');}return b['push']('##\x20Recommended\x20Next\x20Action'),b['push'](''),b['push'](a['recommended_next_action']),b['push'](''),b['join']('\x0a');}export function getRelatedGuardScenes(a){const b=findScene(a);if(!b)return[];const c=new Set();for(const d of b['guard_requirements']){c['add'](d['scene']);}return GUARD_SCENES['filter'](e=>c['has'](e['id']));}export function getVerificationNotes(a){if(!a)return MACHINE_VERIFICATION_NOTES;return MACHINE_VERIFICATION_NOTES['filter'](b=>b['affected_modes']['includes'](a));}export function identifyCrossMachineDependency(a,b,c,d){const e=[];for(const f of b['pairs']){const g=f['prev_node']+'->'+f['next_node'];for(const h of f['forwards']){if(!h['guard'])continue;const i=c['get'](h['guard']);if(!i)continue;e['push']({'machine_a_id':a,'machine_b_id':i['upstream_machine_id'],'machine_b_published':d?d['has'](i['upstream_machine_id']):![],'dependency':{'machine_a_forward':g+':'+h['name'],'machine_b_node':i['upstream_node_name']},'guard_query':i['guard_query_description']});}}return e;}export function detectCrossMachineCycle(a){const b=new Map();for(const j of a){if(!b['has'](j['machine_a_id']))b['set'](j['machine_a_id'],new Set());b['get'](j['machine_a_id'])['add'](j['machine_b_id']);if(!b['has'](j['machine_b_id']))b['set'](j['machine_b_id'],new Set());}const c=[],d=0x0,e=0x1,f=0x2,g=new Map();for(const k of b['keys']())g['set'](k,d);const h=[],i=l=>{g['set'](l,e),h['push'](l);const m=b['get'](l)??new Set();for(const n of m){const o=g['get'](n)??d;if(o===e){const p=h['indexOf'](n),q=h['slice'](p)['concat']([n]);c['push'](q);}else o===d&&i(n);}h['pop'](),g['set'](l,f);};for(const l of b['keys']()){g['get'](l)===d&&i(l);}return c;}export function aggregateProjectDependencies(a,b){const c=[];for(const d of a){const e=identifyCrossMachineDependency(d['machine_id'],d['machine_json'],d['guard_resolutions'],b);c['push'](...e);}return c;}function filterPatternsByMode(a,b){switch(b){case'cross_machine':return a['filter'](c=>c['id']==='P-M-CROSS-MACHINE');case'allocation_integration':return a['filter'](c=>c['id']==='P-M-ALLOCATION-INTEGRATED');case'guard_integration':return a['filter'](c=>c['match_keywords']['some'](d=>['guard','validation']['some'](e=>d['toLowerCase']()['includes'](e['toLowerCase']())))||c['semantic_intent']['toLowerCase']()['includes']('guard'));case'post_publish_runtime':return a['filter'](c=>c['category']==='execution'&&['and','or','vote','hybrid']['some'](d=>c['pattern_name']['toLowerCase']()['includes'](d)));default:return a;}}function filterConstraintsByMode(a,b){switch(b){case'initial_design':case'intent_match':return a['filter'](d=>d['category']==='creation');case'mid_design_review':return a['filter'](d=>['creation','structure','node_operation']['includes'](d['category']));case'pre_publish_check':return a['filter'](d=>['publish','structure','node_operation']['includes'](d['category']));case'post_publish_runtime':return a['filter'](d=>d['category']==='runtime');case'cross_machine':return a['filter'](d=>['structure','publish']['includes'](d['category']));case'guard_integration':return a['filter'](d=>d['description']['toLowerCase']()['includes']('guard')||d['description']['toLowerCase']()['includes']('forward'));case'allocation_integration':return a['filter'](d=>d['description']['toLowerCase']()['includes']('allocator')||d['description']['toLowerCase']()['includes']('terminal')||d['description']['toLowerCase']()['includes']('allocation'));default:return a;}}function filterRisksByMode(a,b){switch(b){case'initial_design':case'intent_match':return a['filter'](c=>['structural','permission']['includes'](c['category']));case'mid_design_review':return a['filter'](c=>['structural','guard_integration','permission']['includes'](c['category']));case'pre_publish_check':return a['slice']()['sort']((c,d)=>severityRank(d['severity'])-severityRank(c['severity']));case'post_publish_runtime':return a['filter'](c=>c['category']==='environment');case'cross_machine':return a['filter'](c=>c['category']==='guard_integration');case'guard_integration':return a['filter'](c=>c['category']==='guard_integration');case'allocation_integration':return a['filter'](c=>c['description']['toLowerCase']()['includes']('allocator')||c['description']['toLowerCase']()['includes']('allocation')||c['description']['toLowerCase']()['includes']('terminal'));default:return a;}}function severityRank(a){switch(a){case'critical':return 0x5;case'high':return 0x4;case'medium':return 0x3;case'low':return 0x2;}}function buildGuardBridge(a){const b=new Set(),c=[];for(const e of a['guard_requirements']){b['add'](e['scene']);const f=GUARD_SCENES['find'](h=>h['id']===e['scene']);c['push']({'forward_purpose':e['purpose'],'guard_scene_id':e['scene'],'guard_scene_name':f?.['name']||e['scene']});}const d=GUARD_SCENES['filter'](h=>b['has'](h['id']));return{'machine_scene_id':a['id'],'guard_scenes':d,'forward_guard_mapping':c};}function buildPromptHints(a){const b=[];switch(a['mode']){case'initial_design':case'intent_match':b['push']('Start\x20by\x20confirming\x20the\x20matched\x20scene\x20and\x20selecting\x20a\x20template.');a['matched_scene']&&(b['push']('Scene\x20\x22'+a['matched_scene']['name']+'\x22\x20recommends\x20patterns:\x20'+a['matched_scene']['recommended_patterns']['join'](',\x20')+'.'),a['matched_scene']['first_node_semantics']&&b['push']('First-node\x20semantics:\x20'+a['matched_scene']['first_node_semantics']));b['push']('⚠\x20First\x20node\x20convention:\x20For\x20Service-bound\x20Machines,\x20the\x20entry\x20node\x20(prev_node=\x27\x27\x20target)\x20MUST\x20represent\x20a\x20POST-PAYMENT\x20state\x20(e.g.\x20\x27Paid\x27,\x20\x27DepositPaid\x27).\x20Do\x20NOT\x20add\x20\x27Order\x27/\x27Pay\x27/\x27Reserve\x27/\x27Subscribe\x27\x20nodes\x20—\x20Service.buy()\x20handles\x20payment\x20atomically\x20before\x20Progress\x20is\x20created.');a['suggested_templates']['length']>0x0&&b['push']('Top\x20template\x20suggestion:\x20'+a['suggested_templates'][0x0]['id']+'\x20('+a['suggested_templates'][0x0]['name']+').');break;case'mid_design_review':a['puzzle_completeness']&&(a['puzzle_completeness']['complete']?b['push']('Puzzle\x20is\x20complete.\x20Proceed\x20to\x20pre-publish\x20check.'):b['push']('Puzzle\x20incomplete.\x20Next\x20step:\x20'+a['puzzle_completeness']['next_step']));a['topology_analysis']&&(a['topology_analysis']['has_cycles']&&b['push']('⚠\x20Cycle\x20detected\x20in\x20topology\x20—\x20must\x20fix\x20before\x20publish.'),a['topology_analysis']['orphaned_nodes']['length']>0x0&&b['push']('⚠\x20Orphaned\x20nodes:\x20'+a['topology_analysis']['orphaned_nodes']['join'](',\x20')));break;case'pre_publish_check':if(a['risk_assessment']){if(a['risk_assessment']['overall_level']==='critical')b['push']('⛔\x20CRITICAL\x20risk\x20detected\x20—\x20DO\x20NOT\x20publish\x20until\x20resolved.');else a['risk_assessment']['overall_level']==='high'&&b['push']('⚠\x20HIGH\x20risk\x20—\x20fix\x20before\x20publish\x20or\x20override\x20with\x20explicit\x20reason.');b['push']('Risk\x20recommendation:\x20'+a['risk_assessment']['recommendation']);}if(a['progressive_check_result']){if(!a['progressive_check_result']['passed']){const c=a['progressive_check_result']['checked_items']['filter'](d=>d['status']!=='pass')['map'](d=>d['id']);b['push']('⛔\x20Pre-publish\x20checklist\x20FAILED\x20on:\x20'+(c['join'](',\x20')||'see\x20details'));}else b['push']('✓\x20Pre-publish\x20checklist\x20(R5)\x20passed.');}b['push']('Run\x20full\x20confirmPublish()\x20with\x20user\x20confirmation\x20before\x20any\x20on-chain\x20publish\x20transaction.');break;case'post_publish_runtime':b['push']('Machine\x20is\x20already\x20published\x20—\x20nodes\x20cannot\x20be\x20modified.'),b['push']('Only\x20progress\x20advancement\x20(Forward\x20execution)\x20is\x20possible.');a['topology_analysis']&&b['push']('Current\x20topology:\x20'+(a['topology_analysis']['within_limits']?'within\x20on-chain\x20limits':'EXCEEDS\x20limits'));break;case'cross_machine':b['push']('Cross-Machine\x20dependency\x20is\x20INDIRECT:\x20Machine\x20A\x20queries\x20Machine\x20B\x27s\x20Progress\x20via\x20convert_witness.'),b['push']('Machine\x20B\x20MUST\x20be\x20published\x20before\x20Progress::new\x20can\x20create\x20a\x20Progress\x20for\x20it\x20(assert_published).'),b['push']('Use\x20convert_witness\x20TypeOrderProgress\x20(100)\x20or\x20TypeOrderProgressSession\x20(103)\x20in\x20Guard\x20queries.');break;case'guard_integration':if(a['guard_bridge']){b['push']('This\x20scene\x20integrates\x20with\x20'+a['guard_bridge']['guard_scenes']['length']+'\x20Guard\x20scene(s).');for(const d of a['guard_bridge']['forward_guard_mapping']){b['push']('\x20\x20-\x20Forward\x20\x22'+d['forward_purpose']+'\x22\x20→\x20Guard\x20scene:\x20'+d['guard_scene_name']);}}b['push']('Forward.guard\x20cannot\x20be\x20modified\x20after\x20Machine\x20publish\x20(immutable).'),b['push']('Use\x20machine_forward_guard\x20scene\x20from\x20guard-ledger.ts\x20for\x20Guard\x20design.');break;case'allocation_integration':b['push']('Terminal\x20nodes\x20map\x20to\x20Service\x20order_allocators.'),b['push']('order_allocators\x20is\x20order-sensitive\x20(first-match-wins).'),b['push']('Each\x20Allocator\x20requires\x20a\x20UNIQUE\x20Guard\x20object\x20(no\x20two\x20allocators\x20may\x20share\x20the\x20same\x20Guard).'),b['push']('order_allocators\x20CANNOT\x20be\x20modified\x20after\x20Service\x20publish\x20(immutable).');break;}for(const e of a['verification_notes']){b['push']('[Verified\x20'+e['judgment']+']\x20'+e['topic']+':\x20'+e['verified_semantic']);}return b['push']('On-chain\x20limits:\x20MAX_NODE_COUNT='+MAX_NODE_COUNT+',\x20MAX_NODE_PAIR_COUNT='+MAX_NODE_PAIR_COUNT+',\x20MAX_FORWARD_COUNT='+MAX_FORWARD_COUNT+'.'),b;}function recommendNextAction(a,b){switch(a){case'initial_design':case'intent_match':{if(!b['matched_scene'])return'Ask\x20the\x20user\x20to\x20clarify\x20the\x20business\x20scenario\x20—\x20no\x20scene\x20matched.';if(b['suggested_templates']['length']===0x0)return'Scene\x20\x22'+b['matched_scene']['name']+'\x22\x20matched\x20but\x20no\x20template\x20available\x20—\x20design\x20Machine\x20manually\x20using\x20the\x20scene\x27s\x20recommended\x20patterns.';return'Present\x20template\x20\x22'+b['suggested_templates'][0x0]['id']+'\x22\x20to\x20user.\x20After\x20user\x20confirms,\x20fill\x20parameters\x20and\x20initialize\x20puzzle.';}case'mid_design_review':{if(!b['puzzle_completeness'])return'Initialize\x20puzzle\x20state\x20and\x20re-run\x20injection\x20with\x20existing_puzzle\x20option.';if(b['puzzle_completeness']['complete'])return'Puzzle\x20complete.\x20Proceed\x20to\x20pre_publish_check\x20mode.';return'Complete\x20missing\x20puzzle\x20dimensions:\x20'+b['puzzle_completeness']['next_step'];}case'pre_publish_check':{if(b['progressive_check_result']&&!b['progressive_check_result']['passed']){const c=b['progressive_check_result']['failed_items']['map'](d=>d['id'])['join'](',\x20');return'⛔\x20Pre-publish\x20checklist\x20FAILED\x20on:\x20'+(c||'see\x20checklist\x20result')+'.\x20Fix\x20these\x20items\x20before\x20proceeding.';}if(b['risk_assessment']){if(b['risk_assessment']['overall_level']==='critical')return'⛔\x20CRITICAL\x20risk\x20—\x20DO\x20NOT\x20publish.\x20Fix\x20risks\x20first.';if(b['risk_assessment']['overall_level']==='high')return'⚠\x20HIGH\x20risk\x20—\x20fix\x20risks\x20OR\x20obtain\x20explicit\x20user\x20override\x20with\x20reason.';}return'All\x20checks\x20passed.\x20Present\x20confirmation\x20text\x20to\x20user\x20and\x20obtain\x20explicit\x20approval\x20before\x20publish\x20transaction.';}case'post_publish_runtime':return'Machine\x20is\x20published.\x20Use\x20onchain_operations\x20to\x20execute\x20Forward\x20advancements.\x20Monitor\x20Progress\x20state\x20via\x20query\x20tool.';case'cross_machine':return'Design\x20Machine\x20A\x27s\x20Forward.guard\x20to\x20query\x20Machine\x20B\x27s\x20Progress\x20via\x20convert_witness=100.\x20Ensure\x20Machine\x20B\x20is\x20published\x20first.';case'guard_integration':return'For\x20each\x20Forward.guard\x20binding,\x20design\x20the\x20Guard\x20using\x20the\x20related\x20Guard\x20scene.\x20Use\x20guard-ledger\x20+\x20guard-templates\x20+\x20guard-puzzle\x20modules.';case'allocation_integration':return'Map\x20each\x20terminal\x20node\x20to\x20an\x20Allocator\x20in\x20Service.order_allocators.\x20Each\x20Allocator\x20needs\x20a\x20unique\x20Guard\x20object.\x20Configure\x20sharing.who\x20(prefer\x20Entity\x20over\x20Signer).';default:return'Proceed\x20with\x20current\x20task.';}}export const CONTEXT_PRESETS={'newUserIntent':a=>injectMachineContext(a,'intent_match',{'max_templates':0x2,'max_constraints':0x5,'max_risks':0x3,'include_verification_notes':![],'include_guard_bridge':![]}),'midDesignReview':(a,b)=>injectMachineContext(a,'mid_design_review',{'max_templates':0x1,'max_constraints':0xf,'max_risks':0xa,'include_verification_notes':!![],'include_guard_bridge':![],'existing_puzzle':b}),'prePublishFull':(a,b,c)=>injectMachineContext(a,'pre_publish_check',{'max_templates':0x0,'max_constraints':0x14,'max_risks':0x27,'include_verification_notes':!![],'include_guard_bridge':!![],'existing_machine_json':b,'project_context':c}),'crossMachine':a=>injectMachineContext(a,'cross_machine',{'max_templates':0x2,'max_constraints':0xa,'max_risks':0x8,'include_verification_notes':!![],'include_guard_bridge':!![]}),'guardIntegration':a=>injectMachineContext(a,'guard_integration',{'max_templates':0x1,'max_constraints':0xa,'max_risks':0x8,'include_verification_notes':!![],'include_guard_bridge':!![]}),'allocationIntegration':a=>injectMachineContext(a,'allocation_integration',{'max_templates':0x1,'max_constraints':0x8,'max_risks':0x8,'include_verification_notes':![],'include_guard_bridge':![]})};
@@ -1,41 +0,0 @@
1
- export interface MachineNodeForRender {
2
- name: string;
3
- description?: string | null;
4
- }
5
- export interface MachineForwardForRender {
6
- name: string;
7
- weight: number;
8
- named_operator?: string | null;
9
- permission_index?: number | null;
10
- guard?: string | null;
11
- retained_submission?: number[] | string | null;
12
- }
13
- export interface MachineEdgeForRender {
14
- from: string;
15
- to: string;
16
- threshold: number;
17
- forwards: MachineForwardForRender[];
18
- }
19
- export interface MachineRenderInput {
20
- nodes: MachineNodeForRender[];
21
- edges: MachineEdgeForRender[];
22
- machineName?: string | null;
23
- machineAddress?: string | null;
24
- published?: boolean | null;
25
- paused?: boolean | null;
26
- }
27
- export declare function sanitizeMermaidNodeId(name: string): string;
28
- export declare function renderMachineMermaid(nodes: MachineNodeForRender[], edges: MachineEdgeForRender[], options?: {
29
- colored?: boolean;
30
- }): string;
31
- export declare function renderMachineTreeIndented(input: MachineRenderInput): string;
32
- export declare function parseMachineTreeIndented(text: string): {
33
- success: boolean;
34
- data?: {
35
- nodes: MachineNodeForRender[];
36
- edges: MachineEdgeForRender[];
37
- };
38
- errors: string[];
39
- };
40
- export declare function renderMachineAscii(input: MachineRenderInput): string;
41
- export declare function renderMachineMarkmap(input: MachineRenderInput): string;
@@ -1 +0,0 @@
1
- function sanitizeMermaidLabel(a){if(/[<>"\[\]{}()|&]/['test'](a))return'\x22'+a['replace'](/"/g,'\x27')+'\x22';return a;}const MACHINE_NODE_COLORS={'entry':{'fill':'#10b981','stroke':'#065f46'},'terminal':{'fill':'#ef4444','stroke':'#991b1b'},'revision':{'fill':'#f59e0b','stroke':'#92400e'},'normal':{'fill':'#3b82f6','stroke':'#1e40af'}};function classifyMachineNode(a,b,c){const d=b['filter'](g=>g['from']===a);if(d['length']===0x0)return'terminal';const e=d['some'](g=>g['to']!=='');if(!e)return'terminal';const f=b['some'](g=>g['to']===a&&g['from']===a);if(f)return'revision';if(c['has'](a))return'entry';return'normal';}export function sanitizeMermaidNodeId(a){if(/[^a-zA-Z0-9_]/['test'](a))return'\x22'+a+'\x22';return a;}export function renderMachineMermaid(a,b,c){const d=c?.['colored']!==![],e=['stateDiagram-v2'];d&&(e['push']('\x20\x20%%\x20Color\x20Legend\x20(BehaviorTree.CPP-inspired\x20workflow\x20roles):'),e['push']('\x20\x20%%\x20\x20\x20green\x20\x20#10b981\x20-\x20entry\x20\x20\x20\x20(start\x20state,\x20targeted\x20by\x20[*])'),e['push']('\x20\x20%%\x20\x20\x20red\x20\x20\x20\x20#ef4444\x20-\x20terminal\x20(end\x20state,\x20no\x20outgoing\x20edges)'),e['push']('\x20\x20%%\x20\x20\x20amber\x20\x20#f59e0b\x20-\x20revision\x20(self-loop\x20/\x20revision\x20cycle)'),e['push']('\x20\x20%%\x20\x20\x20blue\x20\x20\x20#3b82f6\x20-\x20normal\x20\x20\x20(regular\x20intermediate\x20state)'),e['push']('\x20\x20%%\x20Priority:\x20terminal\x20>\x20revision\x20>\x20entry\x20>\x20normal'));const f=new Set(b['filter'](i=>i['from']!=='')['map'](i=>i['to'])),g=new Set();for(const i of a){!f['has'](i['name'])&&g['add'](i['name']);}const h=a['filter'](j=>g['has'](j['name']));for(const j of h){const k=b['filter'](l=>l['from']===''&&l['to']===j['name']);if(k['length']>0x0)for(const l of k){for(const m of l['forwards']){const n=buildForwardLabel(m,l['threshold']);e['push']('\x20\x20[*]\x20-->\x20'+sanitizeMermaidNodeId(j['name'])+':\x20'+sanitizeMermaidLabel(n));}}else e['push']('\x20\x20[*]\x20-->\x20'+sanitizeMermaidNodeId(j['name']));}for(const o of b){if(o['from']==='')continue;const p=sanitizeMermaidNodeId(o['from']),q=o['to']===''?'[*]':sanitizeMermaidNodeId(o['to']);for(const r of o['forwards']){const s=buildForwardLabel(r,o['threshold']);e['push']('\x20\x20'+p+'\x20-->\x20'+q+':\x20'+sanitizeMermaidLabel(s));}}for(const t of a){t['description']&&e['push']('\x20\x20'+sanitizeMermaidNodeId(t['name'])+':\x20'+sanitizeMermaidLabel(t['description']));}if(d){e['push'](''),e['push']('\x20\x20%%\x20Node\x20colors\x20(BehaviorTree.CPP-inspired\x20workflow\x20roles)');for(const u of a){const v=classifyMachineNode(u['name'],b,g),w=MACHINE_NODE_COLORS[v];e['push']('\x20\x20style\x20'+sanitizeMermaidNodeId(u['name'])+'\x20fill:'+w['fill']+',stroke:'+w['stroke']+',color:#fff');}}return e['join']('\x0a');}function buildForwardLabel(a,b){let c=a['name'];const d=[];b>0x1&&d['push']('threshold='+b);if(a['guard']){const e=a['guard']['length']>0xa?a['guard']['slice'](0x0,0x6)+'…'+a['guard']['slice'](-0x4):a['guard'];d['push']('guard='+e);}return d['length']>0x0&&(c+='\x20('+d['join'](',\x20')+')'),c;}export function renderMachineTreeIndented(a){const {nodes:b,edges:c,machineName:d,machineAddress:e,published:f,paused:g}=a,h=[];h['push']('#\x20Machine\x20Workflow\x20Definition'),h['push']('');d&&h['push']('**Machine:**\x20'+d);e&&h['push']('**Address:**\x20'+e);h['push']('**Total\x20Nodes:**\x20'+b['length']),h['push']('**Total\x20Edges:**\x20'+c['length']);f!==null&&f!==undefined&&h['push']('**Published:**\x20'+f);g!==null&&g!==undefined&&h['push']('**Paused:**\x20'+g);h['push'](''),h['push']('##\x20Topology\x20(directed\x20graph\x20outline)'),h['push']('');const i=c['filter'](m=>m['from']===''),j=c['filter'](m=>m['from']!=='');for(const m of i){const n='-\x20[*]\x20-->\x20'+m['to']+'\x20(threshold='+m['threshold']+')';h['push'](n);for(const o of m['forwards']){h['push']('\x20\x20-\x20forward:\x20'+formatForwardInline(o));}}for(const p of j){const q=p['from']===p['to'],r=q?'\x20\x20#\x20self-loop\x20(revision\x20cycle)':'',s=p['to']===''?'[*]':p['to'],t='-\x20'+p['from']+'\x20-->\x20'+s+'\x20(threshold='+p['threshold']+')'+r;h['push'](t);for(const u of p['forwards']){h['push']('\x20\x20-\x20forward:\x20'+formatForwardInline(u));}}const k=b['filter'](v=>v['description']);if(k['length']>0x0){h['push'](''),h['push']('##\x20Node\x20Descriptions'),h['push']('');for(const v of b){v['description']&&h['push']('-\x20'+v['name']+':\x20'+v['description']);}}const l=new Map();for(const w of c){if(!l['has'](w['to']))l['set'](w['to'],[]);l['get'](w['to'])['push']({'from':w['from']===''?'[*]':w['from'],'forwards':w['forwards']['map'](x=>x['name'])});}if(l['size']>0x0){h['push'](''),h['push']('##\x20Backrefs\x20(incoming\x20edges\x20per\x20node)'),h['push']('');for(const x of b){const y=l['get'](x['name']);if(!y||y['length']===0x0)continue;const z=y['map'](A=>{const B=A['forwards']['length']>0x0?'\x20('+A['forwards']['join'](',\x20')+')':'',C=A['from']===x['name']?'\x20#\x20self-loop':'';return'<-\x20'+A['from']+B+C;});h['push']('-\x20'+x['name']+':\x20'+z['join'](',\x20'));}}return h['push'](''),h['push']('##\x20JSON\x20Definition'),h['push'](''),h['push']('```json'),h['push'](JSON['stringify']({'nodes':b,'edges':c},null,0x2)),h['push']('```'),h['join']('\x0a');}function formatForwardInline(a){const b=['weight='+a['weight']];a['named_operator']!==null&&a['named_operator']!==undefined&&b['push']('namedOperator=\x27'+a['named_operator']+'\x27');a['permission_index']!==null&&a['permission_index']!==undefined&&b['push']('permissionIndex='+a['permission_index']);a['guard']&&b['push']('guard='+a['guard']);if(a['retained_submission']){const c=Array['isArray'](a['retained_submission'])?'['+a['retained_submission']['join'](',')+']':String(a['retained_submission']);b['push']('retained_submission='+c);}return a['name']+'\x20('+b['join'](',\x20')+')';}export function parseMachineTreeIndented(a){const b=[],c=a['match'](/```json\s*\n([\s\S]*?)```/);if(c)try{const o=JSON['parse'](c[0x1]['trim']());if(o&&typeof o==='object'&&Array['isArray'](o['nodes'])&&Array['isArray'](o['edges']))return{'success':!![],'data':o,'errors':[]};if(Array['isArray'](o)){const {nodes:p,edges:q}=convertNodeArrayToGraph(o);return{'success':!![],'data':{'nodes':p,'edges':q},'errors':[]};}}catch(r){b['push']('JSON\x20code\x20block\x20parse\x20error:\x20'+r['message']);}const d=a['match'](/##\s*Topology[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i);if(!d)return{'success':![],'errors':['No\x20\x27##\x20Topology\x27\x20section\x20found.\x20'+'Use\x20the\x20format\x20produced\x20by\x20renderMachineTreeIndented()\x20or\x20a\x20JSON\x20code\x20block.']};const f=d[0x1],g=new Set(),h=[],i=f['split']('\x0a')['filter'](s=>s['trim']()['startsWith']('-\x20'));let j=null;for(const s of i){const t=s['trim'](),u=s['startsWith']('\x20\x20-');if(u){const w=t['match'](/^-\s*forward:\s*(.+)$/);if(w&&j){const x=parseForwardInline(w[0x1]);x&&j['forwards']['push'](x);}continue;}const v=t['match'](/^-\s+(.+?)\s+-->\s+(\S+)(?:\s+\(threshold=(\d+)\))?(.*)$/);if(v){j&&h['push'](j);const y=v[0x1]['trim'](),z=v[0x2]['trim'](),A=v[0x3]?parseInt(v[0x3],0xa):0x1,B=y==='[*]'?'':y;j={'from':B,'to':z,'threshold':A,'forwards':[]},g['add'](z);if(B)g['add'](B);}}j&&h['push'](j);if(h['length']===0x0)return{'success':![],'errors':['No\x20edges\x20found\x20in\x20\x27##\x20Topology\x27\x20section.\x20Expected\x20lines\x20like\x20\x27-\x20A\x20-->\x20B\x20(threshold=1)\x27.']};const k=a['match'](/##\s*Node Descriptions[^\n]*\n([\s\S]*?)(?=\n##\s|$)/i),l=new Map();if(k){const C=k[0x1]['split']('\x0a');for(const D of C){const E=D['match'](/^-\s+(\S+):\s*(.+)$/);E&&l['set'](E[0x1],E[0x2]);}}const n=[];for(const F of g){n['push']({'name':F,'description':l['get'](F)??null});}return{'success':!![],'data':{'nodes':n,'edges':h},'errors':b};}function parseForwardInline(a){const b=a['match'](/^(\S+)\s*\(([^)]*)\)$/);if(!b)return{'name':a['trim'](),'weight':0x1,'named_operator':null,'permission_index':null,'guard':null,'retained_submission':null};const c=b[0x1],d=b[0x2],e={'name':c,'weight':0x1,'named_operator':null,'permission_index':null,'guard':null,'retained_submission':null};for(const f of d['split'](',')['map'](g=>g['trim']())){if(!f)continue;const [g,...h]=f['split']('='),i=h['join']('=')['trim']();switch(g['trim']()){case'weight':e['weight']=parseInt(i,0xa)||0x1;break;case'namedOperator':e['named_operator']=i['replace'](/^'|'$/g,'');break;case'permissionIndex':e['permission_index']=parseInt(i,0xa)||null;break;case'guard':e['guard']=i||null;break;case'retained_submission':i['startsWith']('[')&&i['endsWith'](']')?e['retained_submission']=i['slice'](0x1,-0x1)['split'](',')['map'](j=>parseInt(j['trim'](),0xa))['filter'](j=>!isNaN(j)):e['retained_submission']=i;break;}}return e;}function convertNodeArrayToGraph(a){const b=[],c=[];for(const d of a){if(!d||typeof d!=='object')continue;const e=d,f=typeof e['name']==='string'?e['name']:'';if(!f)continue;b['push']({'name':f,'description':typeof e['description']==='string'?e['description']:null});const g=Array['isArray'](e['pairs'])?e['pairs']:[];for(const h of g){if(!h||typeof h!=='object')continue;const i=h,j=typeof i['prev_node']==='string'?i['prev_node']:'',k=typeof i['threshold']==='number'?i['threshold']:0x1,l=Array['isArray'](i['forwards'])?i['forwards']:[],m=l['map'](n=>{const o=n;return{'name':typeof o['name']==='string'?o['name']:'','weight':typeof o['weight']==='number'?o['weight']:0x1,'named_operator':typeof o['namedOperator']==='string'?o['namedOperator']:null,'permission_index':typeof o['permissionIndex']==='number'?o['permissionIndex']:null,'guard':typeof o['guard']==='string'?o['guard']:o['guard']&&typeof o['guard']['guard']==='string'?o['guard']['guard']:null,'retained_submission':null};});c['push']({'from':j,'to':f,'threshold':k,'forwards':m});}}return{'nodes':b,'edges':c};}export function renderMachineAscii(a){const {nodes:b,edges:c,machineName:d,machineAddress:e,published:f,paused:g}=a,h=[];d&&h['push']('Machine:\x20'+d);e&&h['push']('Address:\x20'+e);f!==null&&f!==undefined&&h['push']('Published:\x20'+f);g!==null&&g!==undefined&&h['push']('Paused:\x20'+g);(d||e)&&h['push']('');const i=new Map();for(const n of c){if(n['from']==='')continue;if(!i['has'](n['from']))i['set'](n['from'],[]);i['get'](n['from'])['push'](n);}const j=new Set();for(const o of b){const p=i['get'](o['name'])??[],q=p['some'](r=>r['to']!=='');if(!q){const r=c['some'](s=>s['to']===o['name']);r&&j['add'](o['name']);}}const k=new Set();for(const s of c){s['from']===''&&k['add'](s['to']);}const l=new Set();for(const t of c){t['from']===t['to']&&t['from']!==''&&l['add'](t['from']);}for(const u of c){const v=u['from']===''?'[*]':u['from'],w=u['to']===''?'[*]':u['to'],x=u['from']===u['to']&&u['from']!=='';for(const y of u['forwards']){const z=[];if(x)z['push']('cycle');if(y['guard'])z['push']('guard='+y['guard']);y['named_operator']!==null&&y['named_operator']!==undefined&&y['named_operator']!==''&&z['push']('op='+y['named_operator']);y['permission_index']!==null&&y['permission_index']!==undefined&&z['push']('perm='+y['permission_index']);if(u['threshold']>0x1)z['push']('threshold='+u['threshold']);const A=z['length']>0x0?'\x20['+z['join'](',\x20')+']':'',B=x?'\x20⟲':'';h['push'](v+'\x20─'+y['name']+'→\x20'+w+B+A);}}const m=[];for(const C of b){const D=[];if(k['has'](C['name']))D['push']('entry');if(j['has'](C['name']))D['push']('terminal');if(l['has'](C['name']))D['push']('revision');D['length']>0x0&&m['push']('\x20\x20'+C['name']+':\x20'+D['join'](',\x20'));}return m['length']>0x0&&(h['push'](''),h['push']('Node\x20roles:'),h['push'](...m)),h['join']('\x0a');}export function renderMachineMarkmap(a){const {nodes:b,edges:c,machineName:d,machineAddress:e,published:f,paused:g}=a,h=[],i=['Machine'];if(d)i['push'](d);h['push']('#\x20'+i['join'](':\x20'));if(e||f!==null||g!==null){h['push']('');if(e)h['push']('**Address:**\x20'+e);if(f!==null&&f!==undefined)h['push']('**Published:**\x20'+f);if(g!==null&&g!==undefined)h['push']('**Paused:**\x20'+g);}h['push']('');const j=new Map();for(const l of c){if(l['from']==='')continue;if(!j['has'](l['from']))j['set'](l['from'],[]);j['get'](l['from'])['push'](l);}const k=new Set();for(const m of b){const n=j['get'](m['name'])??[],o=n['some'](p=>p['to']!=='');if(!o){const p=c['some'](q=>q['to']===m['name']);if(p)k['add'](m['name']);}}for(const q of c){const r=q['from']===''?'[*]':q['from'],s=q['to']===''?'[*]':q['to'],t=q['from']===q['to']&&q['from']!=='',u=t?'\x20(cycle)':'',v=k['has'](q['to'])?'\x20(terminal)':'';h['push']('##\x20'+r+'\x20→\x20'+s+u+v);for(const w of q['forwards']){const x=['weight='+w['weight']];w['named_operator']!==null&&w['named_operator']!==undefined&&x['push']('namedOperator=\x27'+w['named_operator']+'\x27'),w['permission_index']!==null&&w['permission_index']!==undefined&&x['push']('permissionIndex='+w['permission_index']),w['guard']&&x['push']('guard='+w['guard']),q['threshold']>0x1&&x['push']('threshold='+q['threshold']),h['push']('###\x20forward:\x20'+w['name']+'\x20('+x['join'](',\x20')+')');}h['push']('');}return h['join']('\x0a');}
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{scanAllMcpSchemas,formatAuditReport,MCP_SCHEMA_AUDIT_VERSION}from'./mcp-schema-audit.js';import*as a154a from'fs';import*as a154b from'path';console['log']('MCP\x20Schema\x20Audit\x20v'+MCP_SCHEMA_AUDIT_VERSION),console['log']('Auditing\x204\x20layers:\x20ts-sdk\x20→\x20Zod\x20→\x20Generated\x20→\x20Deployed\x20...');const result=scanAllMcpSchemas();console['log']('\x0aAudited\x20'+result['census']['length']+'\x20sub-tools,\x20found\x20'+result['total_findings']+'\x20findings.'),console['log']('\x20\x20Gateway\x20deployed:\x20'+(result['gateway']['file_exists']?'yes\x20('+result['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),console['log']('\x20\x20any/unknown:\x20'+result['any_unknown_instances']['length']+'\x20total\x20('+result['fixable_any_count']+'\x20fixable,\x20'+result['legitimate_any_count']+'\x20legitimate)');const report=formatAuditReport(result),outputPath=a154b['resolve']('d:/wowok/wiki/market/GLM3/mcp-schema-audit-report.md');a154a['writeFileSync'](outputPath,report,'utf-8'),console['log']('\x0aReport\x20written\x20to\x20'+outputPath),console['log']('\x0a===\x20Layer\x204\x20Gateway\x20===');result['gateway']['file_exists']?(console['log']('\x20\x20Descriptor:\x20\x20\x20\x20\x20'+result['gateway']['gateway_file']+'\x20('+(result['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),console['log']('\x20\x20Name:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+result['gateway']['gateway_name']),console['log']('\x20\x20Dispatch:\x20\x20\x20\x20\x20\x20\x20tool='+(result['gateway']['has_tool_field']?'OK':'MISSING')+'\x20data='+(result['gateway']['has_data_field']?'OK':'MISSING')+'\x20strict='+(result['gateway']['is_strict']?'OK':'NO')),console['log']('\x20\x20Definitions:\x20\x20\x20\x20'+result['gateway']['definitions_count']),console['log']('\x20\x20schema_query:\x20\x20\x20'+(result['gateway']['has_schema_hint']?'OK':'MISSING'))):console['log']('\x20\x20MISSING\x20—\x20no\x20wowok.json\x20under\x20any\x20Trae\x20mount');console['log']('\x0a===\x20Per-Tool\x20Census\x20==='),console['log']('Tool'['padEnd'](0x1c)+'L3-Input'['padEnd'](0xe)+'L3-Output');for(const c of result['census']){const l3i=c['layer3_generated']['input_exists']?(c['layer3_generated']['input_size_bytes']/0x400)['toFixed'](0x1)+'KB':'MISSING',l3o=c['layer3_generated']['output_exists']?(c['layer3_generated']['output_size_bytes']/0x400)['toFixed'](0x1)+'KB':'MISSING';console['log'](c['name']['padEnd'](0x1c)+l3i['padEnd'](0xe)+l3o);}console['log']('\x0a===\x20Findings\x20by\x20Severity\x20===');for(const sev of['critical','high','medium','low','info']){const arr=result['findings_by_severity']['get'](sev)??[];if(arr['length']>0x0)console['log']('\x20\x20'+sev['padEnd'](0xa)+'\x20'+arr['length']);}console['log']('\x0a===\x20Findings\x20by\x20Category\x20===');for(const cat of['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection']){const arr=result['findings_by_category']['get'](cat)??[];if(arr['length']>0x0)console['log']('\x20\x20'+cat['padEnd'](0x16)+'\x20'+arr['length']);}console['log']('\x0a===\x20any/unknown\x20by\x20Pattern\x20===');const patternGroups=new Map();for(const inst of result['any_unknown_instances']){patternGroups['set'](inst['pattern'],(patternGroups['get'](inst['pattern'])??0x0)+0x1);}for(const [pattern,count]of[...patternGroups['entries']()]['sort']((d,e)=>e[0x1]-d[0x1])){console['log']('\x20\x20'+pattern['padEnd'](0x18)+'\x20'+count);}
@@ -1,91 +0,0 @@
1
- export declare const TRAE_MCPS_ROOT = "c:\\Users\\zhou\\.trae-cn\\mcps";
2
- export declare const GENERATED_SCHEMAS_DIR = "d:\\wowok\\agent\\mcp\\dist\\schemas";
3
- export declare const MCP_SRC_SCHEMA_DIR = "d:\\wowok\\agent\\mcp\\src\\schema";
4
- export declare const MCP_SRC_TOOLS_DIR = "d:\\wowok\\agent\\mcp\\src\\tools";
5
- export declare const GENERATION_SCRIPT = "d:\\wowok\\agent\\mcp\\scripts\\generate-json-schemas.ts";
6
- export declare const TOOLS_INDEX_FILE = "d:\\wowok\\agent\\mcp\\src\\tools\\index.ts";
7
- export declare const MCP_SCHEMA_AUDIT_VERSION = "2.1.0";
8
- export interface ToolDescriptor {
9
- name: string;
10
- input_schema_export: string;
11
- output_schema_export: string | null;
12
- }
13
- export declare const ALL_TOOLS: readonly ToolDescriptor[];
14
- export type FindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
15
- export type FindingCategory = 'layer_census' | 'gateway_deployment' | 'layer_parity' | 'any_unknown' | 'handler_types' | 'output_coverage' | 'generation_sync' | 'reflection' | 'glossary_alignment';
16
- export interface Finding {
17
- rule_id: string;
18
- severity: FindingSeverity;
19
- category: FindingCategory;
20
- tool_name: string;
21
- description: string;
22
- location?: string;
23
- fix?: string;
24
- }
25
- export interface LayerCensus {
26
- name: string;
27
- layer2_zod: {
28
- input_schema_export: string;
29
- output_schema_export: string | null;
30
- schema_dir: string;
31
- };
32
- layer3_generated: {
33
- input_schema_file: string;
34
- output_schema_file: string;
35
- input_exists: boolean;
36
- output_exists: boolean;
37
- input_size_bytes: number;
38
- output_size_bytes: number;
39
- };
40
- }
41
- export interface Layer4GatewayInfo {
42
- gateway_file: string;
43
- file_exists: boolean;
44
- gateway_name: string | null;
45
- has_definitions: boolean;
46
- definitions_count: number;
47
- has_properties: boolean;
48
- has_tool_field: boolean;
49
- has_data_field: boolean;
50
- is_strict: boolean;
51
- has_schema_hint: boolean;
52
- size_bytes: number;
53
- all_mounts: string[];
54
- }
55
- export type AnyUnknownPattern = 'z.any()' | 'z.unknown()' | 'args: any' | 'Promise<any>' | 'Record<string, any>' | 'as any' | ': any' | '<any>';
56
- export type AnyUnknownCategory = 'fixable' | 'legitimate' | 'external';
57
- export interface AnyUnknownInstance {
58
- file: string;
59
- line: number;
60
- code: string;
61
- pattern: AnyUnknownPattern;
62
- category: AnyUnknownCategory;
63
- reason: string;
64
- fix_suggestion?: string;
65
- }
66
- export interface ScanResult {
67
- census: LayerCensus[];
68
- gateway: Layer4GatewayInfo;
69
- findings: Finding[];
70
- any_unknown_instances: AnyUnknownInstance[];
71
- findings_by_severity: Map<FindingSeverity, Finding[]>;
72
- findings_by_category: Map<FindingCategory, Finding[]>;
73
- total_findings: number;
74
- fixable_any_count: number;
75
- legitimate_any_count: number;
76
- external_any_count: number;
77
- }
78
- export declare function discoverDeployedGatewayMounts(): string[];
79
- export declare function loadLayer4Gateway(): Layer4GatewayInfo;
80
- export declare function loadLayer3Generated(toolName: string): LayerCensus['layer3_generated'];
81
- export declare function analyzeLayerCensus(): LayerCensus[];
82
- export declare function analyzeGatewayDeployment(gateway: Layer4GatewayInfo): Finding[];
83
- export declare function analyzeGatewayDispatchContract(gateway: Layer4GatewayInfo): Finding[];
84
- export declare function analyzeAnyUnknownCensus(): AnyUnknownInstance[];
85
- export declare function analyzeHandlerTypeSafety(instances: AnyUnknownInstance[]): Finding[];
86
- export declare function analyzeOutputSchemaCoverage(census: LayerCensus[]): Finding[];
87
- export declare function analyzeGenerationScriptSync(): Finding[];
88
- export declare function analyzeSchemaQueryReflection(census: LayerCensus[]): Finding[];
89
- export declare function analyzeGlossaryAlignment(): Finding[];
90
- export declare function scanAllMcpSchemas(): ScanResult;
91
- export declare function formatAuditReport(result: ScanResult): string;
@@ -1 +0,0 @@
1
- import*as a155a from'fs';import*as a155b from'path';import{CONCEPT_GLOSSARY}from'./glossary.js';export const TRAE_MCPS_ROOT='c:\x5cUsers\x5czhou\x5c.trae-cn\x5cmcps';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='2.1.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':'config_operation','input_schema_export':'ConfigOperationInputSchema','output_schema_export':'ConfigOperationOutputSchema'},{'name':'trust_score','input_schema_export':'TrustScoreInputSchema','output_schema_export':'TrustScoreOutputSchema'},{'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'},{'name':'employee_operation','input_schema_export':'EmployeeOperationInputSchema','output_schema_export':'EmployeeOperationOutputSchema'},{'name':'industry_pack_operation','input_schema_export':'IndustryPackOperationInputSchema','output_schema_export':'IndustryPackOperationOutputSchema'},{'name':'workspace_operation','input_schema_export':'WorkspaceOperationInputSchema','output_schema_export':'WorkspaceOperationOutputSchema'}];export function discoverDeployedGatewayMounts(){const a=[];if(!a155a['existsSync'](TRAE_MCPS_ROOT))return[];for(const b of a155a['readdirSync'](TRAE_MCPS_ROOT,{'withFileTypes':!![]})){if(!b['isDirectory']())continue;const c=a155b['join'](TRAE_MCPS_ROOT,b['name'],'solo_agent','mcp_wagent','tools','wowok.json');try{const d=a155a['statSync'](c);if(d['isFile']())a['push']({'file':c,'mtime':d['mtimeMs']});}catch{}}return a['sort']((e,f)=>f['mtime']-e['mtime']),a['map'](e=>e['file']);}const GATEWAY_MISSING={'gateway_file':a155b['join'](TRAE_MCPS_ROOT,'<none>','solo_agent','mcp_wagent','tools','wowok.json'),'file_exists':![],'gateway_name':null,'has_definitions':![],'definitions_count':0x0,'has_properties':![],'has_tool_field':![],'has_data_field':![],'is_strict':![],'has_schema_hint':![],'size_bytes':0x0,'all_mounts':[]};export function loadLayer4Gateway(){const a=discoverDeployedGatewayMounts();if(a['length']===0x0)return GATEWAY_MISSING;const b=a[0x0];try{const c=a155a['readFileSync'](b,'utf-8'),d=JSON['parse'](c),e=d['arguments']??{},f=e['definitions']??{},g=Object['keys'](f)['length'];let h=e;const i=e['$ref'];if(i&&i['startsWith']('#/definitions/')){const l=i['slice']('#/definitions/'['length']),m=f[l];if(m&&typeof m==='object')h=m;}const j=h['properties']??{},k=d['description']??'';return{'gateway_file':b,'file_exists':!![],'gateway_name':d['name']??null,'has_definitions':g>0x0,'definitions_count':g,'has_properties':Object['keys'](j)['length']>0x0,'has_tool_field':'tool'in j,'has_data_field':'data'in j,'is_strict':h['additionalProperties']===![],'has_schema_hint':k['includes']('schema_query'),'size_bytes':Buffer['byteLength'](c,'utf-8'),'all_mounts':a};}catch{return{...GATEWAY_MISSING,'gateway_file':b,'all_mounts':a};}}export function loadLayer3Generated(a){const b=a155b['join'](GENERATED_SCHEMAS_DIR,a+'.schema.json'),c=a155b['join'](GENERATED_SCHEMAS_DIR,a+'.output.json'),d=a155a['existsSync'](b),e=a155a['existsSync'](c),f=d?a155a['statSync'](b)['size']:0x0,g=e?a155a['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'])});}return a;}export function analyzeGatewayDeployment(a){const b=[],c='(gateway)';if(!a['file_exists'])return b['push']({'rule_id':'MCP-GATEWAY-001','severity':'critical','category':'gateway_deployment','tool_name':c,'description':'No\x20deployed\x20wowok.json\x20gateway\x20descriptor\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT+'.\x20The\x20MCP\x20server\x20is\x20not\x20loaded\x20by\x20any\x20Trae\x20session,\x20or\x20tools/list\x20failed.','fix':'Load\x20the\x20WoWok\x20MCP\x20server\x20in\x20a\x20Trae\x20session\x20and\x20verify\x20tools/list\x20returns\x20the\x20single\x20\x27wowok\x27\x20tool.'}),b;return a['gateway_name']!=='wowok'&&b['push']({'rule_id':'MCP-GATEWAY-002','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20name\x20is\x20\x27'+a['gateway_name']+'\x27\x20—\x20expected\x20\x27wowok\x27\x20(the\x20single\x20unified\x20tool\x20registered\x20by\x20the\x20server).','location':a['gateway_file'],'fix':'Restart\x20the\x20Trae\x20session\x20so\x20Trae\x20regenerates\x20wowok.json\x20from\x20the\x20server\x27s\x20tools/list.'}),!a['has_definitions']&&a['definitions_count']===0x0&&!a['has_properties']&&b['push']({'rule_id':'MCP-GATEWAY-003','severity':'high','category':'gateway_deployment','tool_name':c,'description':'Deployed\x20gateway\x20descriptor\x20carries\x20no\x20argument\x20schema\x20(no\x20definitions\x20and\x20no\x20properties)\x20—\x20the\x20LLM\x20has\x20no\x20parameter\x20structure\x20at\x20all.','location':a['gateway_file'],'fix':'Ensure\x20listTools()\x20advertises\x20WowokToolDisplaySchema\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['has_schema_hint']&&b['push']({'rule_id':'MCP-GATEWAY-004','severity':'medium','category':'gateway_deployment','tool_name':c,'description':'Gateway\x20descriptor\x20description\x20does\x20not\x20mention\x20schema_query\x20—\x20the\x20LLM\x20is\x20not\x20told\x20about\x20the\x20schema\x20self-correction\x20path\x20(sub-tool\x20schemas\x20are\x20returned\x20on\x20validation\x20mismatch).','location':a['gateway_file'],'fix':'Keep\x20the\x20schema_query\x20mention\x20in\x20WOWOK_TOOL_DESCRIPTION\x20(src/tools/index.ts).'}),b;}export function analyzeGatewayDispatchContract(a){const b=[],c='(gateway)';if(!a['file_exists'])return b;const d=[];if(!a['has_tool_field'])d['push']('tool');if(!a['has_data_field'])d['push']('data');return d['length']>0x0&&b['push']({'rule_id':'MCP-PARITY-001','severity':'high','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20argument\x20schema\x20is\x20missing\x20dispatch\x20field(s):\x20'+d['join'](',\x20')+'.\x20Calls\x20of\x20the\x20form\x20wowok({\x20tool,\x20data\x20})\x20cannot\x20be\x20validated.','location':a['gateway_file'],'fix':'Ensure\x20WowokToolDisplaySchema\x20exposes\x20tool/data\x20properties\x20and\x20restart\x20the\x20Trae\x20session.'}),!a['is_strict']&&b['push']({'rule_id':'MCP-PARITY-002','severity':'medium','category':'layer_parity','tool_name':c,'description':'Deployed\x20gateway\x20root\x20schema\x20is\x20not\x20strict\x20(additionalProperties\x20!==\x20false)\x20—\x20unknown\x20keys\x20silently\x20pass\x20the\x20client-side\x20check.','location':a['gateway_file'],'fix':'Keep\x20additionalProperties:false\x20on\x20WowokToolDisplaySchema\x20(aliases\x20are\x20explicit\x20properties).'}),b;}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=a155a['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(!a155a['existsSync'](a))return b;const c=a155a['readdirSync'](a,{'withFileTypes':!![]});for(const d of c){const e=a155b['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=a155b['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[\\/]/['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':a155b['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(!a155a['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=a155a['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=a155b['join'](GENERATED_SCHEMAS_DIR,'onchain_operations_'+f+'.schema.json');!a155a['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;}function normalizeGlossaryTerm(a){return a['toLowerCase']()['replace'](/[-_\s]/g,'');}const GLOSSARY_ALIAS_INDEX=((()=>{const a=new Set(CONCEPT_GLOSSARY['map'](c=>normalizeGlossaryTerm(c['term']))),b=new Map();for(const c of CONCEPT_GLOSSARY){for(const d of c['aliases']){const e=normalizeGlossaryTerm(d);if(a['has'](e))continue;if(!b['has'](e))b['set'](e,c['term']);}}return b;})());function collectSchemaProperties(a,b,c){if(!a||typeof a!=='object')return;const d=a;if(d['properties']&&typeof d['properties']==='object')for(const e of Object['keys'](d['properties'])){c['push']({'file':b,'property':e}),collectSchemaProperties(d['properties'][e],b,c);}if(d['definitions']&&typeof d['definitions']==='object')for(const f of Object['keys'](d['definitions'])){collectSchemaProperties(d['definitions'][f],b,c);}if(d['items'])collectSchemaProperties(d['items'],b,c);if(Array['isArray'](d['anyOf']))d['anyOf']['forEach'](g=>collectSchemaProperties(g,b,c));if(Array['isArray'](d['oneOf']))d['oneOf']['forEach'](g=>collectSchemaProperties(g,b,c));d['additionalProperties']&&typeof d['additionalProperties']==='object'&&collectSchemaProperties(d['additionalProperties'],b,c);}export function analyzeGlossaryAlignment(){const a=[];if(!a155a['existsSync'](GENERATED_SCHEMAS_DIR))return a;const b=a155a['readdirSync'](GENERATED_SCHEMAS_DIR)['filter'](d=>d['endsWith']('.schema.json')||d['endsWith']('.output.json')),c=new Set();for(const d of b){const e=a155b['join'](GENERATED_SCHEMAS_DIR,d);let f;try{f=JSON['parse'](a155a['readFileSync'](e,'utf-8'));}catch{continue;}const g=[];collectSchemaProperties(f,d,g);for(const h of g){const i=normalizeGlossaryTerm(h['property']),j=GLOSSARY_ALIAS_INDEX['get'](i);if(!j)continue;const k=h['file']+'::'+h['property'];if(c['has'](k))continue;c['add'](k),a['push']({'rule_id':'MCP-GLOSSARY-001','severity':'medium','category':'glossary_alignment','tool_name':d['replace'](/\.(schema|output)\.json$/,''),'description':'Schema\x20field\x20\x27'+h['property']+'\x27\x20uses\x20a\x20deprecated\x20glossary\x20alias\x20—\x20the\x20canonical\x20term\x20is\x20\x27'+j+'\x27.','location':e,'fix':'Rename\x20the\x20field\x20to\x20the\x20canonical\x20term\x20(camelCase/snake_case\x20of\x20\x27'+j+'\x27).'});}}return a;}export function scanAllMcpSchemas(){const a=analyzeLayerCensus(),b=loadLayer4Gateway(),c=analyzeAnyUnknownCensus(),d=[...analyzeGatewayDeployment(b),...analyzeGatewayDispatchContract(b),...analyzeHandlerTypeSafety(c),...analyzeOutputSchemaCoverage(a),...analyzeGenerationScriptSync(),...analyzeSchemaQueryReflection(a),...analyzeGlossaryAlignment()],e=new Map(),g=new Map();for(const k of d){if(!e['has'](k['severity']))e['set'](k['severity'],[]);e['get'](k['severity'])['push'](k);if(!g['has'](k['category']))g['set'](k['category'],[]);g['get'](k['category'])['push'](k);}const h=c['filter'](l=>l['category']==='fixable')['length'],i=c['filter'](l=>l['category']==='legitimate')['length'],j=c['filter'](l=>l['category']==='external')['length'];return{'census':a,'gateway':b,'findings':d,'any_unknown_instances':c,'findings_by_severity':e,'findings_by_category':g,'total_findings':d['length'],'fixable_any_count':h,'legitimate_any_count':i,'external_any_count':j};}export function formatAuditReport(a){const b=[];b['push']('#\x20MCP\x20Schema\x20Audit\x20Report\x20—\x20'+a['census']['length']+'\x20WoWok\x20Sub-Tools\x20+\x20Unified\x20Gateway'),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**Gateway\x20deployed**:\x20'+(a['gateway']['file_exists']?'yes\x20('+a['gateway']['all_mounts']['length']+'\x20Trae\x20mount(s))':'NO')),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']('-\x20**Glossary\x20alignment**:\x20'+(a['findings_by_category']['get']('glossary_alignment')??[])['length']+'\x20deprecated-alias\x20schema\x20field(s)'),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['gateway_deployment','layer_parity','handler_types','output_coverage','generation_sync','reflection','glossary_alignment']){const k=a['findings_by_category']['get'](j)??[];b['push']('|\x20'+j+'\x20|\x20'+k['length']+'\x20|');}b['push'](''),b['push']('##\x20Layer\x204\x20—\x20Deployed\x20Gateway'),b['push']('');a['gateway']['file_exists']?(b['push']('-\x20**Descriptor**:\x20`'+a['gateway']['gateway_file']+'`\x20('+(a['gateway']['size_bytes']/0x400)['toFixed'](0x1)+'KB)'),b['push']('-\x20**Name**:\x20'+a['gateway']['gateway_name']),b['push']('-\x20**Dispatch\x20contract**:\x20tool='+(a['gateway']['has_tool_field']?'✓':'✗')+'\x20data='+(a['gateway']['has_data_field']?'✓':'✗')+'\x20strict='+(a['gateway']['is_strict']?'✓':'✗')),b['push']('-\x20**Definitions**:\x20'+a['gateway']['definitions_count']),b['push']('-\x20**schema_query\x20hint**:\x20'+(a['gateway']['has_schema_hint']?'✓':'✗')),b['push']('-\x20**Trae\x20mounts**:\x20'+a['gateway']['all_mounts']['length'])):b['push']('-\x20✗\x20No\x20wowok.json\x20found\x20under\x20any\x20Trae\x20mount\x20in\x20'+TRAE_MCPS_ROOT);b['push'](''),b['push']('##\x20Layer\x20Census\x20—\x20All\x20'+a['census']['length']+'\x20Sub-Tools\x20(dispatched\x20via\x20the\x20wowok\x20gateway)'),b['push'](''),b['push']('|\x20Tool\x20|\x20L3\x20Input\x20|\x20L3\x20Output\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';b['push']('|\x20'+l['name']+'\x20|\x20'+m+'\x20|\x20'+n+'\x20|');}b['push'](''),b['push']('##\x20Findings\x20Detail'),b['push']('');const d=['critical','high','medium','low','info'];for(const o of d){const p=a['findings_by_severity']['get'](o)??[];if(p['length']===0x0)continue;const q=o['toUpperCase']();b['push']('###\x20'+q+'\x20('+p['length']+')'),b['push']('');for(const r of p){b['push']('-\x20**['+r['rule_id']+']\x20'+r['description']);if(r['location'])b['push']('\x20\x20-\x20Location:\x20`'+r['location']+'`');if(r['fix'])b['push']('\x20\x20-\x20Fix:\x20'+r['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 s of a['any_unknown_instances']){if(!e['has'](s['pattern']))e['set'](s['pattern'],[]);e['get'](s['pattern'])['push'](s);}for(const [t,u]of[...e['entries']()]['sort']((v,w)=>w[0x1]['length']-v[0x1]['length'])){const v=u['filter'](y=>y['category']==='fixable')['length'],w=u['filter'](y=>y['category']==='legitimate')['length'],x=u['filter'](y=>y['category']==='external')['length'];b['push']('|\x20`'+t+'`\x20|\x20'+u['length']+'\x20|\x20'+v+'\x20|\x20'+w+'\x20|\x20'+x+'\x20|');}b['push']('');const g=a['any_unknown_instances']['filter'](y=>y['category']==='fixable');if(g['length']>0x0){b['push']('###\x20Fixable\x20Instances\x20(Priority\x20List)'),b['push']('');for(const y of g){b['push']('-\x20**'+a155b['basename'](y['file'])+':'+y['line']+'**\x20[`'+y['pattern']+'`]'),b['push']('\x20\x20-\x20Code:\x20`'+y['code']+'`'),b['push']('\x20\x20-\x20Reason:\x20'+y['reason']);if(y['fix_suggestion'])b['push']('\x20\x20-\x20Fix:\x20'+y['fix_suggestion']);b['push']('');}}return b['push']('##\x20Recommended\x20Action\x20Plan'),b['push'](''),b['push']('###\x20Phase\x201:\x20Keep\x20the\x20Layer\x203\x20schema\x20set\x20regenerable'),b['push'](''),b['push']('Layer\x204\x20(the\x20deployed\x20wowok.json\x20gateway)\x20is\x20CLIENT-generated\x20from\x20our\x20tools/list\x20—\x20keep\x20Layer\x203\x20in\x20sync\x20so\x20schema_query\x20reflection\x20always\x20serves\x20fresh\x20schemas:'),b['push'](''),b['push']('```bash'),b['push']('cd\x20d:/wowok/agent/mcp\x20&&\x20pnpm\x20generate:schemas'),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**query_toolkit\x20output\x20result**\x20(src/tools/index.ts:250)\x20—\x20discriminated\x20union\x20by\x20query_type'),b['push']('4.\x20**SchemaQueryOutputSchema.data**\x20(src/schema/schema-query/index.ts:34)\x20—\x20discriminated\x20union\x20by\x20action'),b['push']('5.\x20**RepositoryKeyValueSchema.key_value**\x20(src/schema/operations.ts:331)\x20—\x20discriminated\x20union\x20by\x20key_type'),b['push']('6.\x20**Handler\x20args:\x20any**\x20—\x20replace\x20with\x20`unknown`\x20(forces\x20strictParse\x20at\x20top\x20of\x20handler)'),b['push']('7.\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');}