@wowok/agent-mcp 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.d.ts +5 -1
  13. package/dist/customer/risk-assessment.js +1 -397
  14. package/dist/customer/types.js +1 -13
  15. package/dist/customer/user-preferences.js +1 -460
  16. package/dist/evaluation/arbitration-game.d.ts +23 -0
  17. package/dist/evaluation/arbitration-game.js +1 -0
  18. package/dist/evaluation/builtins/demand-match.d.ts +15 -0
  19. package/dist/evaluation/builtins/demand-match.js +1 -0
  20. package/dist/evaluation/builtins/index.d.ts +3 -0
  21. package/dist/evaluation/builtins/index.js +1 -0
  22. package/dist/evaluation/builtins/service-risk.d.ts +6 -0
  23. package/dist/evaluation/builtins/service-risk.js +1 -0
  24. package/dist/evaluation/capability.d.ts +50 -0
  25. package/dist/evaluation/capability.js +1 -0
  26. package/dist/evaluation/composer.d.ts +13 -0
  27. package/dist/evaluation/composer.js +1 -0
  28. package/dist/evaluation/engine.d.ts +18 -0
  29. package/dist/evaluation/engine.js +1 -0
  30. package/dist/evaluation/extract.d.ts +30 -0
  31. package/dist/evaluation/extract.js +1 -0
  32. package/dist/evaluation/game-strategy.d.ts +27 -0
  33. package/dist/evaluation/game-strategy.js +1 -0
  34. package/dist/evaluation/gap.d.ts +2 -0
  35. package/dist/evaluation/gap.js +1 -0
  36. package/dist/evaluation/index.d.ts +12 -0
  37. package/dist/evaluation/index.js +1 -0
  38. package/dist/evaluation/node-game.d.ts +62 -0
  39. package/dist/evaluation/node-game.js +1 -0
  40. package/dist/evaluation/region.d.ts +10 -0
  41. package/dist/evaluation/region.js +1 -0
  42. package/dist/evaluation/types.d.ts +77 -0
  43. package/dist/evaluation/types.js +1 -0
  44. package/dist/evaluation/user-injection.d.ts +6 -0
  45. package/dist/evaluation/user-injection.js +1 -0
  46. package/dist/examples/education-contact-create.json +40 -0
  47. package/dist/examples/freelance-contact-create.json +40 -0
  48. package/dist/examples/insurance-machine-create.json +1 -1
  49. package/dist/examples/insurance-service-allocators.json +1 -1
  50. package/dist/examples/machine-publish.json +1 -1
  51. package/dist/examples/rental-ziroom-service-create.json +1 -1
  52. package/dist/examples/retail-adv-guard-messenger-proof-create.json +1 -1
  53. package/dist/examples/retail-myshop-service-create.json +1 -1
  54. package/dist/examples/retail-myshop-service-customer-required.json +1 -1
  55. package/dist/examples/subscription-contact-create.json +40 -0
  56. package/dist/examples/threebody-machine-create.json +1 -1
  57. package/dist/examples/travel-machine-create.json +1 -1
  58. package/dist/examples/travel-service-create.json +1 -1
  59. package/dist/experience/experience-reuse.js +1 -103
  60. package/dist/experience/index.js +1 -5
  61. package/dist/experience/intent-distill.js +1 -83
  62. package/dist/experience/realtime-feedback.js +1 -94
  63. package/dist/experience/types.js +1 -1
  64. package/dist/experience/user-profile.js +1 -171
  65. package/dist/extensions/business-modules.js +1 -287
  66. package/dist/extensions/capability-manifest.js +1 -781
  67. package/dist/extensions/constraint-registry.js +1 -198
  68. package/dist/extensions/index.js +1 -6
  69. package/dist/extensions/metric-registry.js +1 -257
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.js +1 -717
  73. package/dist/extensions/types.js +1 -1
  74. package/dist/harness/auto-escalation.js +1 -68
  75. package/dist/harness/checkpoint.js +1 -129
  76. package/dist/harness/index.js +1 -78
  77. package/dist/harness/plan.js +1 -276
  78. package/dist/harness/recover.js +1 -139
  79. package/dist/harness/types.js +1 -1
  80. package/dist/harness/verify.js +1 -237
  81. package/dist/index.js +1 -273
  82. package/dist/intent/enrich.d.ts +1 -0
  83. package/dist/intent/enrich.js +1 -0
  84. package/dist/intent/index.d.ts +23 -0
  85. package/dist/intent/index.js +1 -0
  86. package/dist/intent/matcher.d.ts +2 -0
  87. package/dist/intent/matcher.js +1 -0
  88. package/dist/intent/store.d.ts +19 -0
  89. package/dist/intent/store.js +1 -0
  90. package/dist/intent/types.d.ts +33 -0
  91. package/dist/intent/types.js +1 -0
  92. package/dist/knowledge/acquisition-flywheel.js +1 -192
  93. package/dist/knowledge/allocation-confirm.js +1 -534
  94. package/dist/knowledge/allocation-context.js +1 -249
  95. package/dist/knowledge/allocation-ledger.js +1 -463
  96. package/dist/knowledge/allocation-puzzle.js +1 -298
  97. package/dist/knowledge/allocation-risk.js +1 -568
  98. package/dist/knowledge/allocation-templates.js +1 -970
  99. package/dist/knowledge/allocation-translation.js +1 -585
  100. package/dist/knowledge/arb-risk.js +1 -210
  101. package/dist/knowledge/arbitration-confirm.js +1 -559
  102. package/dist/knowledge/arbitration-context.js +1 -505
  103. package/dist/knowledge/arbitration-ledger.js +1 -521
  104. package/dist/knowledge/arbitration-puzzle.js +1 -304
  105. package/dist/knowledge/arbitration-risk.js +1 -433
  106. package/dist/knowledge/arbitration-templates.js +1 -276
  107. package/dist/knowledge/arbitration-translation.js +1 -487
  108. package/dist/knowledge/arbitration-trust.js +1 -117
  109. package/dist/knowledge/audit-rules.js +1 -141
  110. package/dist/knowledge/bridge-risk.js +1 -263
  111. package/dist/knowledge/contact-risk.js +1 -200
  112. package/dist/knowledge/contact-templates.d.ts +27 -0
  113. package/dist/knowledge/contact-templates.js +1 -0
  114. package/dist/knowledge/demand-confirm.js +1 -206
  115. package/dist/knowledge/demand-matching.js +1 -132
  116. package/dist/knowledge/demand-risk.js +1 -240
  117. package/dist/knowledge/demand-translation.js +1 -354
  118. package/dist/knowledge/deployment-scanner.js +1 -823
  119. package/dist/knowledge/dynamic-pricing.js +1 -87
  120. package/dist/knowledge/examples-scanner-cli.js +1 -26
  121. package/dist/knowledge/examples-scanner.js +1 -825
  122. package/dist/knowledge/flywheel-loop.js +1 -404
  123. package/dist/knowledge/fund-layer.js +1 -973
  124. package/dist/knowledge/glossary.js +1 -211
  125. package/dist/knowledge/guard-confirm.js +1 -406
  126. package/dist/knowledge/guard-context.js +1 -287
  127. package/dist/knowledge/guard-design-patterns.js +1 -360
  128. package/dist/knowledge/guard-ledger.js +1 -260
  129. package/dist/knowledge/guard-lint.js +1 -670
  130. package/dist/knowledge/guard-migration.js +1 -228
  131. package/dist/knowledge/guard-puzzle.js +1 -805
  132. package/dist/knowledge/guard-render.js +1 -700
  133. package/dist/knowledge/guard-risk.js +1 -1879
  134. package/dist/knowledge/guard-submission-prompt.js +1 -171
  135. package/dist/knowledge/guard-templates.js +1 -1105
  136. package/dist/knowledge/guard-translation.js +1 -1119
  137. package/dist/knowledge/index.js +1 -436
  138. package/dist/knowledge/industry-evolution.js +1 -323
  139. package/dist/knowledge/industry-generalizer.js +1 -381
  140. package/dist/knowledge/industry-registry.js +1 -174
  141. package/dist/knowledge/intent-metrics.d.ts +4 -3
  142. package/dist/knowledge/intent-metrics.js +1 -566
  143. package/dist/knowledge/machine-confirm.js +1 -559
  144. package/dist/knowledge/machine-context.js +1 -833
  145. package/dist/knowledge/machine-ledger.js +1 -338
  146. package/dist/knowledge/machine-puzzle.js +1 -494
  147. package/dist/knowledge/machine-render.js +1 -565
  148. package/dist/knowledge/machine-risk.js +1 -670
  149. package/dist/knowledge/machine-templates.js +1 -1597
  150. package/dist/knowledge/machine-topology.js +1 -234
  151. package/dist/knowledge/machine-translation.js +1 -513
  152. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  153. package/dist/knowledge/mcp-schema-audit.d.ts +1 -1
  154. package/dist/knowledge/mcp-schema-audit.js +1 -773
  155. package/dist/knowledge/onchain-constants.js +1 -35
  156. package/dist/knowledge/order-confirm.js +1 -573
  157. package/dist/knowledge/order-context.js +1 -390
  158. package/dist/knowledge/order-ledger.js +1 -341
  159. package/dist/knowledge/order-puzzle.js +1 -255
  160. package/dist/knowledge/order-risk.js +1 -653
  161. package/dist/knowledge/order-templates.js +1 -368
  162. package/dist/knowledge/order-translation.js +1 -550
  163. package/dist/knowledge/overrides-loader.js +1 -65
  164. package/dist/knowledge/passport-confirm.js +1 -531
  165. package/dist/knowledge/passport-context.js +1 -306
  166. package/dist/knowledge/passport-ledger.js +1 -282
  167. package/dist/knowledge/passport-puzzle.js +1 -333
  168. package/dist/knowledge/passport-risk.js +1 -450
  169. package/dist/knowledge/passport-templates.js +1 -568
  170. package/dist/knowledge/passport-translation.js +1 -516
  171. package/dist/knowledge/payment-risk.js +1 -249
  172. package/dist/knowledge/permission-confirm.js +1 -426
  173. package/dist/knowledge/permission-context.js +1 -224
  174. package/dist/knowledge/permission-ledger.js +1 -403
  175. package/dist/knowledge/permission-puzzle.js +1 -173
  176. package/dist/knowledge/permission-risk.js +1 -411
  177. package/dist/knowledge/permission-templates.js +1 -234
  178. package/dist/knowledge/permission-translation.js +1 -350
  179. package/dist/knowledge/personal-risk.js +1 -212
  180. package/dist/knowledge/process-model.js +1 -160
  181. package/dist/knowledge/progress-confirm.js +1 -456
  182. package/dist/knowledge/progress-context.js +1 -452
  183. package/dist/knowledge/progress-ledger.js +1 -330
  184. package/dist/knowledge/progress-puzzle.js +1 -219
  185. package/dist/knowledge/progress-risk.js +1 -461
  186. package/dist/knowledge/progress-templates.js +1 -228
  187. package/dist/knowledge/progress-translation.js +1 -405
  188. package/dist/knowledge/proof-confirm.js +1 -187
  189. package/dist/knowledge/proof-risk.js +1 -207
  190. package/dist/knowledge/proof-translation.js +1 -283
  191. package/dist/knowledge/registrar-risk.js +1 -217
  192. package/dist/knowledge/repository-confirm.js +1 -286
  193. package/dist/knowledge/repository-risk.js +1 -373
  194. package/dist/knowledge/repository-translation.js +1 -445
  195. package/dist/knowledge/reputation-rules.js +1 -99
  196. package/dist/knowledge/resource-risk.js +1 -157
  197. package/dist/knowledge/reward-confirm.js +1 -526
  198. package/dist/knowledge/reward-context.js +1 -504
  199. package/dist/knowledge/reward-ledger.js +1 -502
  200. package/dist/knowledge/reward-puzzle.js +1 -300
  201. package/dist/knowledge/reward-risk.js +1 -627
  202. package/dist/knowledge/reward-templates.js +1 -197
  203. package/dist/knowledge/reward-translation.js +1 -501
  204. package/dist/knowledge/safety-rules.js +1 -404
  205. package/dist/knowledge/scenario-modes.js +1 -321
  206. package/dist/knowledge/service-confirm.js +1 -807
  207. package/dist/knowledge/service-context.js +1 -403
  208. package/dist/knowledge/service-ledger.js +1 -609
  209. package/dist/knowledge/service-puzzle.js +1 -236
  210. package/dist/knowledge/service-risk.js +1 -615
  211. package/dist/knowledge/service-templates.js +1 -456
  212. package/dist/knowledge/service-translation.js +1 -622
  213. package/dist/knowledge/template-registry.d.ts +1 -1
  214. package/dist/knowledge/template-registry.js +1 -341
  215. package/dist/knowledge/tool-constraints.js +1 -195
  216. package/dist/knowledge/tools-reference.js +1 -155
  217. package/dist/knowledge/treasury-confirm.js +1 -512
  218. package/dist/knowledge/treasury-context.js +1 -363
  219. package/dist/knowledge/treasury-ledger.js +1 -300
  220. package/dist/knowledge/treasury-puzzle.js +1 -216
  221. package/dist/knowledge/treasury-risk.js +1 -440
  222. package/dist/knowledge/treasury-templates.js +1 -358
  223. package/dist/knowledge/treasury-translation.js +1 -498
  224. package/dist/knowledge/trust-metrics.js +1 -198
  225. package/dist/knowledge/util-risk.js +1 -135
  226. package/dist/loop-engineering/aggregate.js +1 -132
  227. package/dist/loop-engineering/context-collect.js +1 -83
  228. package/dist/loop-engineering/diagnose.js +1 -273
  229. package/dist/loop-engineering/improve.js +1 -405
  230. package/dist/loop-engineering/index.js +1 -4
  231. package/dist/loop-engineering/pipeline.js +1 -56
  232. package/dist/mode-market/index.js +1 -3
  233. package/dist/mode-market/registry.js +1 -124
  234. package/dist/mode-market/review.js +1 -214
  235. package/dist/mode-market/submission.js +1 -85
  236. package/dist/participation/collaborator-interest.d.ts +23 -0
  237. package/dist/participation/collaborator-interest.js +1 -0
  238. package/dist/participation/customer-interest.d.ts +25 -0
  239. package/dist/participation/customer-interest.js +1 -0
  240. package/dist/participation/merchant-interest.js +1 -100
  241. package/dist/participation/radar-core.d.ts +13 -3
  242. package/dist/participation/radar-core.js +1 -269
  243. package/dist/participation/supplier-interest.d.ts +25 -0
  244. package/dist/participation/supplier-interest.js +1 -0
  245. package/dist/persona/analyzer.d.ts +16 -0
  246. package/dist/persona/analyzer.js +1 -0
  247. package/dist/persona/bridge.d.ts +5 -0
  248. package/dist/persona/bridge.js +1 -0
  249. package/dist/persona/defaults.d.ts +4 -0
  250. package/dist/persona/defaults.js +1 -0
  251. package/dist/persona/experience-bridge.d.ts +3 -0
  252. package/dist/persona/experience-bridge.js +1 -0
  253. package/dist/persona/index.d.ts +18 -0
  254. package/dist/persona/index.js +1 -0
  255. package/dist/persona/model.d.ts +7 -0
  256. package/dist/persona/model.js +1 -0
  257. package/dist/persona/store.d.ts +19 -0
  258. package/dist/persona/store.js +1 -0
  259. package/dist/persona/types.d.ts +45 -0
  260. package/dist/persona/types.js +1 -0
  261. package/dist/project/business-puzzle.js +1 -383
  262. package/dist/project/context-assembly.js +1 -254
  263. package/dist/project/deployment-bridge.js +1 -120
  264. package/dist/project/deployment-doc.js +1 -1126
  265. package/dist/project/edit-planner.js +1 -1342
  266. package/dist/project/evaluation.js +1 -2011
  267. package/dist/project/game-theory.js +1 -177
  268. package/dist/project/graph-builder.js +1 -656
  269. package/dist/project/graph.js +1 -340
  270. package/dist/project/handlers.d.ts +5 -0
  271. package/dist/project/handlers.js +1 -1762
  272. package/dist/project/index.d.ts +1 -0
  273. package/dist/project/index.js +1 -301
  274. package/dist/project/intent-analyzer.js +1 -149
  275. package/dist/project/machine-nodes.js +1 -36
  276. package/dist/project/merchant-guide.js +1 -264
  277. package/dist/project/migration.js +1 -125
  278. package/dist/project/mode-actions.js +1 -309
  279. package/dist/project/namespace.js +1 -206
  280. package/dist/project/participation-radar.js +1 -428
  281. package/dist/project/pipeline-actions.js +1 -109
  282. package/dist/project/project-store.js +1 -422
  283. package/dist/project/query.js +1 -153
  284. package/dist/project/reverse-mapping.d.ts +34 -0
  285. package/dist/project/reverse-mapping.js +1 -0
  286. package/dist/project/risk-aggregator.js +1 -295
  287. package/dist/project/rollback-policy.js +1 -290
  288. package/dist/project/semantic-assembler.js +1 -345
  289. package/dist/project/semantic-graph.js +1 -245
  290. package/dist/project/stage-gate.js +1 -369
  291. package/dist/project/substep-trace.js +1 -332
  292. package/dist/project/task-tracker.js +1 -78
  293. package/dist/role/derivation.d.ts +18 -0
  294. package/dist/role/derivation.js +1 -0
  295. package/dist/role/index.d.ts +5 -0
  296. package/dist/role/index.js +1 -0
  297. package/dist/role/model.d.ts +8 -0
  298. package/dist/role/model.js +1 -0
  299. package/dist/role/resolution.d.ts +11 -0
  300. package/dist/role/resolution.js +1 -0
  301. package/dist/role/types.d.ts +11 -0
  302. package/dist/role/types.js +1 -0
  303. package/dist/rules.d.ts +2 -0
  304. package/dist/rules.js +1 -9
  305. package/dist/safety/confirm-gate.js +1 -88
  306. package/dist/safety/index.js +1 -3
  307. package/dist/safety/preview.js +1 -52
  308. package/dist/schema/call/allocation.js +1 -34
  309. package/dist/schema/call/arbitration.js +1 -113
  310. package/dist/schema/call/base.d.ts +15 -15
  311. package/dist/schema/call/base.js +1 -370
  312. package/dist/schema/call/bridge-handler.js +1 -265
  313. package/dist/schema/call/bridge.d.ts +7 -7
  314. package/dist/schema/call/bridge.js +1 -458
  315. package/dist/schema/call/contact.js +1 -37
  316. package/dist/schema/call/demand.js +1 -47
  317. package/dist/schema/call/guard.js +1 -161
  318. package/dist/schema/call/handler.js +1 -322
  319. package/dist/schema/call/index.js +1 -20
  320. package/dist/schema/call/machine.js +1 -193
  321. package/dist/schema/call/order.js +1 -35
  322. package/dist/schema/call/payment.js +1 -37
  323. package/dist/schema/call/permission-handler.js +1 -54
  324. package/dist/schema/call/permission.js +1 -105
  325. package/dist/schema/call/personal.js +1 -78
  326. package/dist/schema/call/progress.js +1 -47
  327. package/dist/schema/call/proof.js +1 -33
  328. package/dist/schema/call/repository.js +1 -77
  329. package/dist/schema/call/reward.js +1 -30
  330. package/dist/schema/call/semantic.js +1 -1657
  331. package/dist/schema/call/service.js +1 -178
  332. package/dist/schema/call/treasury.js +1 -71
  333. package/dist/schema/common/index.js +1 -407
  334. package/dist/schema/config/index.js +1 -68
  335. package/dist/schema/evaluation/index.d.ts +4436 -0
  336. package/dist/schema/evaluation/index.js +1 -0
  337. package/dist/schema/index.d.ts +4 -0
  338. package/dist/schema/index.js +1 -13
  339. package/dist/schema/intent-radar/index.d.ts +284 -0
  340. package/dist/schema/intent-radar/index.js +1 -0
  341. package/dist/schema/local/index.d.ts +21 -21
  342. package/dist/schema/local/index.js +1 -927
  343. package/dist/schema/local/wip.js +1 -187
  344. package/dist/schema/messenger/index.d.ts +7 -7
  345. package/dist/schema/messenger/index.js +1 -475
  346. package/dist/schema/operations.d.ts +7 -7
  347. package/dist/schema/operations.js +1 -520
  348. package/dist/schema/persona/index.d.ts +1985 -0
  349. package/dist/schema/persona/index.js +1 -0
  350. package/dist/schema/project/index.d.ts +96 -50
  351. package/dist/schema/project/index.js +1 -2057
  352. package/dist/schema/query/index.d.ts +423 -7
  353. package/dist/schema/query/index.js +1 -1640
  354. package/dist/schema/schema-query/index.js +1 -104
  355. package/dist/schema/schema-version.js +1 -76
  356. package/dist/schema/sync-layer4.d.ts +1 -1
  357. package/dist/schema/sync-layer4.js +1 -282
  358. package/dist/schema/task-status.d.ts +168 -0
  359. package/dist/schema/task-status.js +1 -0
  360. package/dist/schema/trust/index.js +1 -314
  361. package/dist/schema/utils/guard-parser.js +1 -419
  362. package/dist/schema/utils/guard-query-utils.js +1 -46
  363. package/dist/schema/utils/node-parser.js +1 -369
  364. package/dist/schema/utils/object-type-utils.js +1 -35
  365. package/dist/schema/utils/permission-index-utils.js +1 -7
  366. package/dist/schema/utils/permission-machine-check.js +1 -121
  367. package/dist/schema/utils/skills-recommendation.js +1 -77
  368. package/dist/schema-query/index.js +1 -810
  369. package/dist/schemas/account_operation.output.json +5 -2
  370. package/dist/schemas/bridge_operation.output.json +5 -2
  371. package/dist/schemas/evaluation_operation.output.json +782 -0
  372. package/dist/schemas/evaluation_operation.schema.json +990 -0
  373. package/dist/schemas/index.json +25 -1
  374. package/dist/schemas/intent_radar.output.json +232 -0
  375. package/dist/schemas/intent_radar.schema.json +138 -0
  376. package/dist/schemas/local_info_operation.output.json +5 -2
  377. package/dist/schemas/local_mark_operation.output.json +5 -2
  378. package/dist/schemas/messenger_operation.output.json +5 -2
  379. package/dist/schemas/onchain_events.output.json +5 -2
  380. package/dist/schemas/onchain_operations.output.json +5 -2
  381. package/dist/schemas/onchain_operations.schema.json +6 -6
  382. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  383. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  384. package/dist/schemas/onchain_operations_service.schema.json +3 -3
  385. package/dist/schemas/onchain_table_data.output.json +6 -3
  386. package/dist/schemas/persona_operation.output.json +392 -0
  387. package/dist/schemas/persona_operation.schema.json +250 -0
  388. package/dist/schemas/project_operation.output.json +28 -8
  389. package/dist/schemas/query_task_status.output.json +115 -0
  390. package/dist/schemas/query_task_status.schema.json +24 -0
  391. package/dist/schemas/query_toolkit.output.json +9 -6
  392. package/dist/schemas/trust_score.schema.json +1 -1
  393. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  394. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  395. package/dist/telemetry/index.js +1 -112
  396. package/dist/telemetry/redact.js +1 -23
  397. package/dist/telemetry/storage.js +1 -80
  398. package/dist/tools/handlers/bridge.js +1 -1
  399. package/dist/tools/handlers/config.js +1 -74
  400. package/dist/tools/handlers/evaluation.d.ts +2 -0
  401. package/dist/tools/handlers/evaluation.js +1 -0
  402. package/dist/tools/handlers/file-export.js +1 -90
  403. package/dist/tools/handlers/intent-radar.d.ts +2 -0
  404. package/dist/tools/handlers/intent-radar.js +1 -0
  405. package/dist/tools/handlers/local.js +1 -53
  406. package/dist/tools/handlers/messenger.js +1 -188
  407. package/dist/tools/handlers/onchain.js +1 -1082
  408. package/dist/tools/handlers/persona.d.ts +4 -0
  409. package/dist/tools/handlers/persona.js +1 -0
  410. package/dist/tools/handlers/project.js +1 -211
  411. package/dist/tools/handlers/query.js +1 -434
  412. package/dist/tools/handlers/schema-query.js +1 -176
  413. package/dist/tools/handlers/task-status.d.ts +0 -168
  414. package/dist/tools/handlers/task-status.js +1 -55
  415. package/dist/tools/handlers/trust.js +1 -380
  416. package/dist/tools/handlers/wip.js +1 -90
  417. package/dist/tools/index.js +1 -1306
  418. package/dist/tools/retry.js +1 -85
  419. package/dist/tools/rules-hook.js +1 -23
  420. package/dist/tools/shared.js +1 -130
  421. package/dist/tools/types.js +1 -1
  422. package/dist/tools/upgrade-check.d.ts +19 -0
  423. package/dist/tools/upgrade-check.js +1 -0
  424. package/dist/tools/wip-deploy-assist.d.ts +1 -1
  425. package/dist/tools/wip-deploy-assist.js +1 -278
  426. package/dist/tools/wrap.js +1 -500
  427. package/package.json +5 -3
@@ -1,550 +1 @@
1
- import { MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, } from "@wowok/wowok";
2
- import { ORDER_SCENES, inferSceneFromIntent, } from "./order-ledger.js";
3
- export const SEMANTIC_TO_SCHEMA_RULES = [
4
- {
5
- id: "P-O-01",
6
- pattern_name: "Create Order via service::buy (compound creation)",
7
- semantic_intent: "Buy items from a Service — atomically creates Order + Allocation + Progress, snapshots service.machine, emits NewOrderEvent",
8
- match_keywords: ["buy", "purchase", "order"],
9
- schema_fields: ["(via service::buy, not direct order::create)"],
10
- example_json: {
11
- _note: "Order is NOT created via CallOrder_Data. It is created via service::buy() which internally calls order::new + order::create.",
12
- _call_target: "service",
13
- object: "0xSERVICE_ADDRESS",
14
- buy: {
15
- items: [{ name: "Product A", price: "1000000000", quantity: 1, wip_hash: "0xABC..." }],
16
- discount: null,
17
- named_order: "my_order_alias",
18
- machine_forward: null,
19
- },
20
- },
21
- reverse_explanation: "Order creation is composite — service::buy atomically builds Order + Allocation + Progress + emits NewOrderEvent. order::create is package-only.",
22
- operation_field: "object",
23
- permission_layer: "L3_package_only",
24
- },
25
- {
26
- id: "P-O-02",
27
- pattern_name: "Advance Progress (forward/hold)",
28
- semantic_intent: "Advance Order's Progress to next node via forward or hold",
29
- match_keywords: ["advance", "forward", "progress", "next"],
30
- schema_fields: ["object", "progress"],
31
- example_json: {
32
- object: "0xORDER_ADDRESS",
33
- progress: {
34
- next_node_name: "shipped",
35
- forward: { name: "deliver", operator: null, guard: null },
36
- op: "next",
37
- message: "Order dispatched",
38
- },
39
- },
40
- reverse_explanation: "progress.forward triggers Progress::operate → order.progress node transition. Both owner and agent can advance (L2).",
41
- operation_field: "progress",
42
- permission_layer: "L2_owner_or_agent",
43
- },
44
- {
45
- id: "P-O-03",
46
- pattern_name: "Set agent list (owner-only, pre-progress)",
47
- semantic_intent: "Replace the entire agent list. Frozen after Progress binding.",
48
- match_keywords: ["set agent", "agent", "delegate"],
49
- schema_fields: ["object", "agent"],
50
- example_json: {
51
- object: "0xORDER_ADDRESS",
52
- agent: ["0xAGENT1", "0xAGENT2"],
53
- },
54
- reverse_explanation: "agent field overwrites entire agent list. Owner-only (L1). Aborts E_PROGRESS_NOT_SPECIFIED if Progress already bound. ⚠️ Boundary bug: actual max 11 (not 10).",
55
- operation_field: "agent",
56
- permission_layer: "L1_owner_only",
57
- },
58
- {
59
- id: "P-O-04",
60
- pattern_name: "Set required_info (Contact or WTS Proof)",
61
- semantic_intent: "Update recipient contact or delivery proof. Both owner and agent can update.",
62
- match_keywords: ["required_info", "recipient", "contact", "wts proof"],
63
- schema_fields: ["object", "required_info"],
64
- example_json: {
65
- object: "0xORDER_ADDRESS",
66
- required_info: "0xCONTACT_ADDRESS",
67
- },
68
- reverse_explanation: "required_info accepts Contact object (recipient) or WTS Proof object (delivery proof). null clears. L2 (owner or agent).",
69
- operation_field: "required_info",
70
- permission_layer: "L2_owner_or_agent",
71
- },
72
- {
73
- id: "P-O-05",
74
- pattern_name: "Apply for arbitration (arb_confirm)",
75
- semantic_intent: "File arbitration with confirm/deny + description + proposition. Triggers dispute() appending Arb to order.dispute.",
76
- match_keywords: ["arb_confirm", "apply arbitration", "file dispute", "compensation"],
77
- schema_fields: ["object", "arb_confirm"],
78
- example_json: {
79
- object: "0xORDER_ADDRESS",
80
- arb_confirm: {
81
- arb: "0xARB_ADDRESS",
82
- confirm: true,
83
- description: "Item never arrived",
84
- proposition: ["Refund full amount", "Compensation for delay"],
85
- },
86
- },
87
- reverse_explanation: "arb_confirm triggers arb::principal_confirm + arb::description_change + arb::proposition_change, and Arb module calls order::dispute(arb) to append. L2.",
88
- operation_field: "arb_confirm",
89
- permission_layer: "L2_owner_or_agent",
90
- },
91
- {
92
- id: "P-O-06",
93
- pattern_name: "Object to arbitration (arb_objection)",
94
- semantic_intent: "Object to Arb ruling and request re-arbitration",
95
- match_keywords: ["arb_objection", "object", "appeal"],
96
- schema_fields: ["object", "arb_objection"],
97
- example_json: {
98
- object: "0xORDER_ADDRESS",
99
- arb_objection: {
100
- arb: "0xARB_ADDRESS",
101
- objection: "Evidence was not properly reviewed",
102
- },
103
- },
104
- reverse_explanation: "arb_objection triggers arb::objection. Requires Arb status = Arbitrated. L2 (owner or agent). Irreversible.",
105
- operation_field: "arb_objection",
106
- permission_layer: "L2_owner_or_agent",
107
- },
108
- {
109
- id: "P-O-07",
110
- pattern_name: "Claim compensation (arb_claim_compensation)",
111
- semantic_intent: "Claim compensation from a ruled Arb. Sets claimed_by — ONE-TIME, IRREVERSIBLE, blocks future disputes.",
112
- match_keywords: ["arb_claim_compensation", "claim", "compensation"],
113
- schema_fields: ["object", "arb_claim_compensation"],
114
- example_json: {
115
- object: "0xORDER_ADDRESS",
116
- arb_claim_compensation: {
117
- arb: "0xRULED_ARB_ADDRESS",
118
- },
119
- },
120
- reverse_explanation: "arb_claim_compensation triggers service::compensation_claim → order::compensate(arb) → sets claimed_by=arb. IRREVERSIBLE. L2.",
121
- operation_field: "arb_claim_compensation",
122
- permission_layer: "L2_owner_or_agent",
123
- },
124
- {
125
- id: "P-O-08",
126
- pattern_name: "Receive payment/objects (owner-only)",
127
- semantic_intent: "Receive CoinWrapper or arbitrary Receiving<K> from Progress. Funds forwarded to owner.",
128
- match_keywords: ["receive", "collect", "extract"],
129
- schema_fields: ["object", "receive"],
130
- example_json: {
131
- object: "0xORDER_ADDRESS",
132
- receive: {
133
- received: "0xRECEIVING_OBJECT_ID",
134
- },
135
- },
136
- reverse_explanation: "receive calls order::owner_receive or owner_receive_object. Owner-only (L1) — agent CANNOT receive. Aborts E_ORDER_DELIVERING if Progress not at terminal.",
137
- operation_field: "receive",
138
- permission_layer: "L1_owner_only",
139
- },
140
- {
141
- id: "P-O-09",
142
- pattern_name: "Transfer ownership (transfer_to)",
143
- semantic_intent: "Transfer Order ownership to new address. IRREVERSIBLE. New owner takes over ALL permissions.",
144
- match_keywords: ["transfer", "transfer_to", "handover"],
145
- schema_fields: ["object", "transfer_to"],
146
- example_json: {
147
- object: "0xORDER_ADDRESS",
148
- transfer_to: "0xNEW_OWNER_ADDRESS",
149
- },
150
- reverse_explanation: "transfer_to calls order::owner_change(new_owner). Owner-only (L1). IRREVERSIBLE. Unlike agent_set, can be called after Progress binding.",
151
- operation_field: "transfer_to",
152
- permission_layer: "L1_owner_only",
153
- },
154
- {
155
- id: "P-O-10",
156
- pattern_name: "Query Order state (read-only)",
157
- semantic_intent: "Read Order fields: items, amount, owner/builder, agent, dispute, claimed_by, progress, machine, time",
158
- match_keywords: ["query", "read", "check", "status"],
159
- schema_fields: ["(read-only via query layer, not CallOrder_Data)"],
160
- example_json: {
161
- _note: "Query uses the query/object endpoint, not CallOrder_Data",
162
- _call_target: "query",
163
- object: "0xORDER_ADDRESS",
164
- fields: ["items", "amount", "owner", "agent", "dispute", "claimed_by", "progress", "machine"],
165
- },
166
- reverse_explanation: "Query is read-only — does not modify state. Use to verify state before any L1/L2 operation. SDK ObjectOrder returns all 14 fields.",
167
- operation_field: "object",
168
- },
169
- {
170
- id: "P-O-11",
171
- pattern_name: "Query Order history (event log)",
172
- semantic_intent: "Query Order lifecycle events. ⚠️ Only NewOrderEvent is actually emitted — other events must be INFERRED from field changes.",
173
- match_keywords: ["history", "events", "lifecycle", "audit"],
174
- schema_fields: ["(read-only via query layer, event filter)"],
175
- example_json: {
176
- _note: "Only NewOrderEvent is emitted on-chain. Other lifecycle events must be inferred by querying Order field diffs over time.",
177
- _call_target: "query",
178
- object: "0xORDER_ADDRESS",
179
- event_filter: { type: "order::NewOrderEvent" },
180
- },
181
- reverse_explanation: "Audit weakness: only 1 of 11 lifecycle events is actually emitted. Use status_inference formula from ORDER_AUDIT_FORMULAS to derive state.",
182
- operation_field: "object",
183
- },
184
- {
185
- id: "P-O-12",
186
- pattern_name: "Monitor Order status changes (polling)",
187
- semantic_intent: "Poll Order status to detect: Progress advance, dispute append, claimed_by set, ownership transfer",
188
- match_keywords: ["monitor", "poll", "watch", "track"],
189
- schema_fields: ["(read-only via query layer, polling)"],
190
- example_json: {
191
- _note: "Monitor by querying Order at intervals and diffing fields",
192
- _call_target: "query",
193
- object: "0xORDER_ADDRESS",
194
- poll_interval_ms: 5000,
195
- watch_fields: ["progress", "dispute", "claimed_by", "owner"],
196
- },
197
- reverse_explanation: "No push notifications — must poll. Track 4 critical fields: progress (advance), dispute (new arb), claimed_by (terminal), owner (transfer).",
198
- operation_field: "object",
199
- },
200
- ];
201
- export const SCHEMA_TO_SEMANTIC_RULES = [
202
- {
203
- element_type: "field",
204
- type_name: "object",
205
- semantic_explanation: "Order object address. STRING=operate existing Order. null/omitted is invalid (Order creation goes through service::buy).",
206
- constraints: ["Must be valid Order object ID", "Order must exist on-chain"],
207
- },
208
- {
209
- element_type: "field",
210
- type_name: "agent",
211
- semantic_explanation: "Agent address list (overwrites entire list). Owner-only (L1). Frozen after Progress binding. ⚠️ Boundary bug: actual max 11 (not 10).",
212
- constraints: [`<= ${MAX_AGENT_COUNT} agents (doc) / 11 (actual bug)`, "Owner-only", "Frozen after Progress binding"],
213
- },
214
- {
215
- element_type: "field",
216
- type_name: "required_info",
217
- semantic_explanation: "Contact object (recipient info) or WTS Proof object (delivery proof). null clears. L2 (owner or agent).",
218
- constraints: ["Must be Contact or WTS Proof object", "null clears the field"],
219
- },
220
- {
221
- element_type: "field",
222
- type_name: "progress",
223
- semantic_explanation: "Progress operation object — advance via forward/hold. Both owner and agent can advance. Node transition is irreversible.",
224
- constraints: ["Requires Progress binding (order.progress.is_some())", "L2 (owner or agent)", "Node transition irreversible"],
225
- },
226
- {
227
- element_type: "field",
228
- type_name: "arb_confirm",
229
- semantic_explanation: "Apply for arbitration compensation. Triggers dispute() appending Arb to order.dispute. L2. Irreversible.",
230
- constraints: ["Arb must exist", "L2 (owner or agent)", "claimed_by must be None"],
231
- },
232
- {
233
- element_type: "field",
234
- type_name: "arb_objection",
235
- semantic_explanation: "Object to Arb ruling and request re-arbitration. Requires Arb status = Arbitrated. L2. Irreversible.",
236
- constraints: ["Arb must be in Arbitrated state", "L2 (owner or agent)"],
237
- },
238
- {
239
- element_type: "field",
240
- type_name: "arb_claim_compensation",
241
- semantic_explanation: "Claim compensation from ruled Arb. Sets claimed_by. ONE-TIME, IRREVERSIBLE, blocks future disputes. L2.",
242
- constraints: ["Arb must be Arbitrated", "claimed_by must be None", "L2 (owner or agent)", "IRREVERSIBLE"],
243
- },
244
- {
245
- element_type: "field",
246
- type_name: "receive",
247
- semantic_explanation: "Receive CoinWrapper or arbitrary Receiving<K> from Progress. Funds forwarded to owner. Owner-only (L1) — agent CANNOT.",
248
- constraints: ["Owner-only (L1)", "Progress must be at terminal node (not delivering)", "Can be called multiple times"],
249
- },
250
- {
251
- element_type: "field",
252
- type_name: "transfer_to",
253
- semantic_explanation: "New owner address for ownership transfer. IRREVERSIBLE. New owner takes over ALL permissions. Owner-only (L1).",
254
- constraints: ["Owner-only (L1)", "IRREVERSIBLE", "Valid Wow address"],
255
- },
256
- {
257
- element_type: "op",
258
- type_name: "forward",
259
- semantic_explanation: "Advance Progress to next node via named forward. Triggers Progress::operate.",
260
- constraints: ["Forward name must exist on current node", "Guard (if any) must pass"],
261
- },
262
- {
263
- element_type: "op",
264
- type_name: "hold",
265
- semantic_explanation: "Hold at current Progress node (optional pause).",
266
- constraints: ["Node must support hold"],
267
- },
268
- {
269
- element_type: "op",
270
- type_name: "confirm",
271
- semantic_explanation: "In arb_confirm: true=confirm materials valid, false=deny materials.",
272
- constraints: ["Boolean — no other values"],
273
- },
274
- {
275
- element_type: "index",
276
- type_name: "dispute_index",
277
- semantic_explanation: "Position in order.dispute vector. 0-based. Max 10 disputes total.",
278
- constraints: [`<= ${MAX_DISPUTE_COUNT} disputes`, "Frozen when claimed_by.is_some()"],
279
- },
280
- {
281
- element_type: "error",
282
- type_name: "E_OWNER (code 1)",
283
- semantic_explanation: "Sender != order.owner. L1 operation attempted by non-owner (agent or third party).",
284
- constraints: ["Aborts assert_owner"],
285
- },
286
- {
287
- element_type: "error",
288
- type_name: "E_PERMISSION (code 5)",
289
- semantic_explanation: "Sender is neither owner nor in agent[]. L2 operation attempted by unauthorized caller.",
290
- constraints: ["Aborts assert_op_permission (via has_op_permission returning false)"],
291
- },
292
- {
293
- element_type: "error",
294
- type_name: "E_PROGRESS_NOT_SPECIFIED (code 3)",
295
- semantic_explanation: "⚠️ DUAL SEMANTICS: (a) order::create — machine is Some but progress is None; (b) agent_set/owner_change — progress is already bound (frozen).",
296
- constraints: ["Check context to disambiguate", "Same code, opposite meanings"],
297
- },
298
- {
299
- element_type: "error",
300
- type_name: "E_ORDER_ALREADY_CLAIMED (code 7)",
301
- semantic_explanation: "claimed_by is already Some. Cannot file new disputes, claim again, or call compensate.",
302
- constraints: ["IRREVERSIBLE — no way to reset claimed_by"],
303
- },
304
- {
305
- element_type: "error",
306
- type_name: "E_MAX_AGENT_COUNT (code 2)",
307
- semantic_explanation: "agent list exceeds MAX_AGENT_COUNT (10). ⚠️ Actual boundary uses <= so allows 11 (bug).",
308
- constraints: [`Doc limit: ${MAX_AGENT_COUNT}`, "Actual limit: 11 (boundary bug)"],
309
- },
310
- {
311
- element_type: "error",
312
- type_name: "E_MAX_DISPUTE_COUNT (code 6)",
313
- semantic_explanation: "dispute vector at MAX_DISPUTE_COUNT (10). Next dispute() call aborts.",
314
- constraints: [`Max: ${MAX_DISPUTE_COUNT}`],
315
- },
316
- {
317
- element_type: "error",
318
- type_name: "E_ALLOCATION_NOT_SPECIFIED (code 8)",
319
- semantic_explanation: "order::create with amount > 0 but allocation is None.",
320
- constraints: ["If amount > 0, allocation must be set"],
321
- },
322
- {
323
- element_type: "error",
324
- type_name: "E_ALLOCATION_ALREADY_SPECIFIED (code 9)",
325
- semantic_explanation: "on_allocation called twice. Allocation is one-time set.",
326
- constraints: ["One-time only"],
327
- },
328
- {
329
- element_type: "error",
330
- type_name: "E_PROGRESS_ALREADY_SPECIFIED (code 10)",
331
- semantic_explanation: "on_progress called twice. Progress is one-time set.",
332
- constraints: ["One-time only"],
333
- },
334
- ];
335
- export const ORDER_CONSTRAINT_RULES = [
336
- {
337
- id: "MC-O-01",
338
- category: "structural",
339
- rule: "Order has 14 fields; SDK uses 'builder' for Move's 'owner' (only naming deviation in 22 objects)",
340
- applies_to: ["object.owner", "object.builder"],
341
- },
342
- {
343
- id: "MC-O-02",
344
- category: "structural",
345
- rule: `agent count <= MAX_AGENT_COUNT (${MAX_AGENT_COUNT}) per docs; ⚠️ actual allows 11 due to <= bug`,
346
- applies_to: ["agent"],
347
- },
348
- {
349
- id: "MC-O-03",
350
- category: "structural",
351
- rule: `dispute count <= MAX_DISPUTE_COUNT (${MAX_DISPUTE_COUNT}); frozen when claimed_by.is_some()`,
352
- applies_to: ["dispute"],
353
- },
354
- {
355
- id: "MC-O-04",
356
- category: "structural",
357
- rule: "Order creation is COMPOSITE via service::buy — order::create is package-only",
358
- applies_to: ["(creation flow)"],
359
- },
360
- {
361
- id: "MC-O-05",
362
- category: "semantic",
363
- rule: "order.machine is a SNAPSHOT copied from service.machine at buy time (not a reference)",
364
- applies_to: ["machine"],
365
- },
366
- {
367
- id: "MC-O-06",
368
- category: "semantic",
369
- rule: "E_PROGRESS_NOT_SPECIFIED has DUAL semantics: (a) create: machine Some + progress None; (b) agent_set/owner_change: progress already bound",
370
- applies_to: ["error code 3"],
371
- },
372
- {
373
- id: "MC-O-07",
374
- category: "semantic",
375
- rule: "Only NewOrderEvent is actually emitted; 10 other lifecycle events must be inferred from field changes",
376
- applies_to: ["events"],
377
- },
378
- {
379
- id: "MC-O-08",
380
- category: "semantic",
381
- rule: "SaleItem.item ↔ PurchasedItem.name (different field names for same concept)",
382
- applies_to: ["items.item", "purchased_items.name"],
383
- },
384
- {
385
- id: "MC-O-09",
386
- category: "authority",
387
- rule: "L1 owner-only operations: receive, transfer_to, owner_change, agent_set (assert_owner)",
388
- applies_to: ["receive", "transfer_to", "agent"],
389
- },
390
- {
391
- id: "MC-O-10",
392
- category: "authority",
393
- rule: "L2 owner-or-agent operations: required_info, progress, arb_confirm, arb_objection, arb_claim_compensation (has_op_permission)",
394
- applies_to: ["required_info", "progress", "arb_confirm", "arb_objection", "arb_claim_compensation"],
395
- },
396
- {
397
- id: "MC-O-11",
398
- category: "authority",
399
- rule: "L3 package-only operations: on_progress, on_allocation, dispute, compensate (no external access)",
400
- applies_to: ["(package-only functions)"],
401
- },
402
- {
403
- id: "MC-O-12",
404
- category: "authority",
405
- rule: "Agent CANNOT receive payments — only owner can call owner_receive / owner_receive_object",
406
- applies_to: ["receive"],
407
- },
408
- {
409
- id: "MC-O-13",
410
- category: "lifecycle",
411
- rule: "Progress binding FREEZES owner and agent — agent_set/owner_change abort E_PROGRESS_NOT_SPECIFIED after binding",
412
- applies_to: ["agent", "transfer_to (pre-progress)", "owner_change"],
413
- },
414
- {
415
- id: "MC-O-14",
416
- category: "lifecycle",
417
- rule: "claimed_by is ONE-TIME, IRREVERSIBLE — blocks future dispute(), compensate(), and arb_claim_compensation",
418
- applies_to: ["claimed_by", "arb_claim_compensation", "dispute"],
419
- },
420
- {
421
- id: "MC-O-15",
422
- category: "cross_object",
423
- rule: "Order + Allocation + Progress are 1:1:1 bound at creation; cannot rebind or detach",
424
- applies_to: ["progress", "allocation"],
425
- },
426
- ];
427
- export const ORDER_TRANSLATION_VERSION = "1.0.0";
428
- export function matchSemanticPattern(userIntent) {
429
- const lower = userIntent.toLowerCase();
430
- return SEMANTIC_TO_SCHEMA_RULES.filter(rule => rule.match_keywords.some(kw => lower.includes(kw.toLowerCase())));
431
- }
432
- export function explainOrderCallData(data) {
433
- const lines = [];
434
- if (!data.object) {
435
- lines.push("Operation: ⚠️ INVALID — Order object address required (Order creation goes through service::buy, not CallOrder_Data)");
436
- return lines.join("\n");
437
- }
438
- lines.push(`Operation: MODIFY existing Order at ${data.object}`);
439
- if (data.agent) {
440
- lines.push(`- ⚠️ Set agent list (${data.agent.length} agent(s)): [${data.agent.join(", ")}]`);
441
- lines.push(` Owner-only (L1). Frozen after Progress binding. Boundary bug allows max 11 (not 10).`);
442
- }
443
- if (data.required_info !== undefined) {
444
- if (data.required_info === null) {
445
- lines.push(`- Clear required_info (L2 — owner or agent)`);
446
- }
447
- else {
448
- lines.push(`- Set required_info: ${data.required_info} (Contact or WTS Proof; L2 — owner or agent)`);
449
- }
450
- }
451
- if (data.progress) {
452
- const p = data.progress;
453
- lines.push(`- Advance Progress (L2 — owner or agent)`);
454
- if (p.next_node_name)
455
- lines.push(` Next node: ${p.next_node_name}`);
456
- if (p.forward)
457
- lines.push(` Forward: ${p.forward.name}${p.forward.operator ? ` (operator: ${p.forward.operator})` : ""}`);
458
- if (p.op)
459
- lines.push(` Op: ${p.op}`);
460
- if (p.message)
461
- lines.push(` Message: "${p.message}"`);
462
- }
463
- if (data.arb_confirm) {
464
- const a = data.arb_confirm;
465
- lines.push(`- ⚠️ Apply for arbitration (L2 — owner or agent, IRREVERSIBLE)`);
466
- lines.push(` Arb: ${a.arb}`);
467
- lines.push(` Confirm: ${a.confirm ? "valid materials" : "deny materials"}`);
468
- if (a.description)
469
- lines.push(` Description: "${a.description}"`);
470
- if (a.proposition && a.proposition.length > 0) {
471
- lines.push(` Propositions: ${a.proposition.length} claim(s)`);
472
- }
473
- }
474
- if (data.arb_objection) {
475
- const a = data.arb_objection;
476
- lines.push(`- ⚠️ Object to Arb ruling (L2 — owner or agent, IRREVERSIBLE)`);
477
- lines.push(` Arb: ${a.arb}`);
478
- lines.push(` Objection: "${a.objection}"`);
479
- }
480
- if (data.arb_claim_compensation) {
481
- const a = data.arb_claim_compensation;
482
- lines.push(`- ⚠️⚠️ CLAIM COMPENSATION (L2 — owner or agent, ONE-TIME, IRREVERSIBLE)`);
483
- lines.push(` Arb: ${a.arb}`);
484
- lines.push(` After claim: NO new disputes can be filed (E_ORDER_ALREADY_CLAIMED)`);
485
- }
486
- if (data.receive) {
487
- lines.push(`- Receive (L1 — OWNER-ONLY, agent CANNOT)`);
488
- lines.push(` Received object: ${data.receive.received}`);
489
- lines.push(` Funds/objects forwarded to owner address`);
490
- }
491
- if (data.transfer_to) {
492
- lines.push(`- ⚠️⚠️ TRANSFER OWNERSHIP to ${data.transfer_to} (L1 — OWNER-ONLY, IRREVERSIBLE)`);
493
- lines.push(` New owner takes over ALL permissions`);
494
- lines.push(` Can be called even after Progress binding (unlike agent_set)`);
495
- }
496
- return lines.join("\n");
497
- }
498
- export function explainField(fieldName) {
499
- return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "field" && r.type_name === fieldName);
500
- }
501
- export function explainOp(opName) {
502
- return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "op" && r.type_name === opName);
503
- }
504
- export function explainOrderError(errorNameOrCode) {
505
- const str = String(errorNameOrCode);
506
- return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "error" && (r.type_name === str ||
507
- r.type_name.startsWith(str + " ") ||
508
- r.type_name.includes(str)));
509
- }
510
- export function getConstraintsByCategory(category) {
511
- return ORDER_CONSTRAINT_RULES.filter(r => r.category === category);
512
- }
513
- export function explainPermissionLayer(layer) {
514
- const descriptions = {
515
- L1_owner_only: "L1 — Owner-only (assert_owner). Aborts E_OWNER (code 1) if sender != owner. Agent CANNOT perform L1 ops.",
516
- L2_owner_or_agent: "L2 — Owner or agent (has_op_permission). Aborts E_PERMISSION (code 5) if sender is neither owner nor in agent[].",
517
- L3_package_only: "L3 — Package-only (no external access). Called by other wow-framework modules (progress, allocation, arbitration).",
518
- };
519
- return descriptions[layer];
520
- }
521
- export function resolveFieldName(sdkOrMoveName) {
522
- if (sdkOrMoveName === "builder" || sdkOrMoveName === "owner") {
523
- return { sdk_name: "builder", move_name: "owner", is_deviation: true };
524
- }
525
- return { sdk_name: sdkOrMoveName, move_name: sdkOrMoveName, is_deviation: false };
526
- }
527
- export function matchSceneFromOperation(operationField) {
528
- const scenes = ORDER_SCENES.filter(s => s.operation_field === operationField);
529
- return scenes.length > 0 ? scenes[0] : undefined;
530
- }
531
- export function explainOrderIntent(intent) {
532
- const matchedScene = inferSceneFromIntent(intent);
533
- const matchedPatterns = matchSemanticPattern(intent);
534
- const relevantConstraints = matchedScene
535
- ? ORDER_CONSTRAINT_RULES.filter(c => {
536
- if (matchedScene.permission_layer === "L1_owner_only") {
537
- return c.category === "authority" || c.category === "lifecycle";
538
- }
539
- if (matchedScene.permission_layer === "L2_owner_or_agent") {
540
- return c.category === "authority" || c.category === "semantic";
541
- }
542
- return c.category === "structural" || c.category === "cross_object";
543
- })
544
- : ORDER_CONSTRAINT_RULES;
545
- return {
546
- matched_scene: matchedScene,
547
- matched_patterns: matchedPatterns,
548
- relevant_constraints: relevantConstraints,
549
- };
550
- }
1
+ import{MAX_AGENT_COUNT,MAX_DISPUTE_COUNT}from'@wowok/wowok';import{ORDER_SCENES,inferSceneFromIntent}from'./order-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-O-01','pattern_name':'Create\x20Order\x20via\x20service::buy\x20(compound\x20creation)','semantic_intent':'Buy\x20items\x20from\x20a\x20Service\x20—\x20atomically\x20creates\x20Order\x20+\x20Allocation\x20+\x20Progress,\x20snapshots\x20service.machine,\x20emits\x20NewOrderEvent','match_keywords':['buy','purchase','order'],'schema_fields':['(via\x20service::buy,\x20not\x20direct\x20order::create)'],'example_json':{'_note':'Order\x20is\x20NOT\x20created\x20via\x20CallOrder_Data.\x20It\x20is\x20created\x20via\x20service::buy()\x20which\x20internally\x20calls\x20order::new\x20+\x20order::create.','_call_target':'service','object':'0xSERVICE_ADDRESS','buy':{'items':[{'name':'Product\x20A','price':'1000000000','quantity':0x1,'wip_hash':'0xABC...'}],'discount':null,'named_order':'my_order_alias','machine_forward':null}},'reverse_explanation':'Order\x20creation\x20is\x20composite\x20—\x20service::buy\x20atomically\x20builds\x20Order\x20+\x20Allocation\x20+\x20Progress\x20+\x20emits\x20NewOrderEvent.\x20order::create\x20is\x20package-only.','operation_field':'object','permission_layer':'L3_package_only'},{'id':'P-O-02','pattern_name':'Advance\x20Progress\x20(forward/hold)','semantic_intent':'Advance\x20Order\x27s\x20Progress\x20to\x20next\x20node\x20via\x20forward\x20or\x20hold','match_keywords':['advance','forward','progress','next'],'schema_fields':['object','progress'],'example_json':{'object':'0xORDER_ADDRESS','progress':{'next_node_name':'shipped','forward':{'name':'deliver','operator':null,'guard':null},'op':'next','message':'Order\x20dispatched'}},'reverse_explanation':'progress.forward\x20triggers\x20Progress::operate\x20→\x20order.progress\x20node\x20transition.\x20Both\x20owner\x20and\x20agent\x20can\x20advance\x20(L2).','operation_field':'progress','permission_layer':'L2_owner_or_agent'},{'id':'P-O-03','pattern_name':'Set\x20agent\x20list\x20(owner-only,\x20pre-progress)','semantic_intent':'Replace\x20the\x20entire\x20agent\x20list.\x20Frozen\x20after\x20Progress\x20binding.','match_keywords':['set\x20agent','agent','delegate'],'schema_fields':['object','agent'],'example_json':{'object':'0xORDER_ADDRESS','agent':['0xAGENT1','0xAGENT2']},'reverse_explanation':'agent\x20field\x20overwrites\x20entire\x20agent\x20list.\x20Owner-only\x20(L1).\x20Aborts\x20E_PROGRESS_NOT_SPECIFIED\x20if\x20Progress\x20already\x20bound.\x20⚠️\x20Boundary\x20bug:\x20actual\x20max\x2011\x20(not\x2010).','operation_field':'agent','permission_layer':'L1_owner_only'},{'id':'P-O-04','pattern_name':'Set\x20required_info\x20(Contact\x20or\x20WTS\x20Proof)','semantic_intent':'Update\x20recipient\x20contact\x20or\x20delivery\x20proof.\x20Both\x20owner\x20and\x20agent\x20can\x20update.','match_keywords':['required_info','recipient','contact','wts\x20proof'],'schema_fields':['object','required_info'],'example_json':{'object':'0xORDER_ADDRESS','required_info':'0xCONTACT_ADDRESS'},'reverse_explanation':'required_info\x20accepts\x20Contact\x20object\x20(recipient)\x20or\x20WTS\x20Proof\x20object\x20(delivery\x20proof).\x20null\x20clears.\x20L2\x20(owner\x20or\x20agent).','operation_field':'required_info','permission_layer':'L2_owner_or_agent'},{'id':'P-O-05','pattern_name':'Apply\x20for\x20arbitration\x20(arb_confirm)','semantic_intent':'File\x20arbitration\x20with\x20confirm/deny\x20+\x20description\x20+\x20proposition.\x20Triggers\x20dispute()\x20appending\x20Arb\x20to\x20order.dispute.','match_keywords':['arb_confirm','apply\x20arbitration','file\x20dispute','compensation'],'schema_fields':['object','arb_confirm'],'example_json':{'object':'0xORDER_ADDRESS','arb_confirm':{'arb':'0xARB_ADDRESS','confirm':!![],'description':'Item\x20never\x20arrived','proposition':['Refund\x20full\x20amount','Compensation\x20for\x20delay']}},'reverse_explanation':'arb_confirm\x20triggers\x20arb::principal_confirm\x20+\x20arb::description_change\x20+\x20arb::proposition_change,\x20and\x20Arb\x20module\x20calls\x20order::dispute(arb)\x20to\x20append.\x20L2.','operation_field':'arb_confirm','permission_layer':'L2_owner_or_agent'},{'id':'P-O-06','pattern_name':'Object\x20to\x20arbitration\x20(arb_objection)','semantic_intent':'Object\x20to\x20Arb\x20ruling\x20and\x20request\x20re-arbitration','match_keywords':['arb_objection','object','appeal'],'schema_fields':['object','arb_objection'],'example_json':{'object':'0xORDER_ADDRESS','arb_objection':{'arb':'0xARB_ADDRESS','objection':'Evidence\x20was\x20not\x20properly\x20reviewed'}},'reverse_explanation':'arb_objection\x20triggers\x20arb::objection.\x20Requires\x20Arb\x20status\x20=\x20Arbitrated.\x20L2\x20(owner\x20or\x20agent).\x20Irreversible.','operation_field':'arb_objection','permission_layer':'L2_owner_or_agent'},{'id':'P-O-07','pattern_name':'Claim\x20compensation\x20(arb_claim_compensation)','semantic_intent':'Claim\x20compensation\x20from\x20a\x20ruled\x20Arb.\x20Sets\x20claimed_by\x20—\x20ONE-TIME,\x20IRREVERSIBLE,\x20blocks\x20future\x20disputes.','match_keywords':['arb_claim_compensation','claim','compensation'],'schema_fields':['object','arb_claim_compensation'],'example_json':{'object':'0xORDER_ADDRESS','arb_claim_compensation':{'arb':'0xRULED_ARB_ADDRESS'}},'reverse_explanation':'arb_claim_compensation\x20triggers\x20service::compensation_claim\x20→\x20order::compensate(arb)\x20→\x20sets\x20claimed_by=arb.\x20IRREVERSIBLE.\x20L2.','operation_field':'arb_claim_compensation','permission_layer':'L2_owner_or_agent'},{'id':'P-O-08','pattern_name':'Receive\x20payment/objects\x20(owner-only)','semantic_intent':'Receive\x20CoinWrapper\x20or\x20arbitrary\x20Receiving<K>\x20from\x20Progress.\x20Funds\x20forwarded\x20to\x20owner.','match_keywords':['receive','collect','extract'],'schema_fields':['object','receive'],'example_json':{'object':'0xORDER_ADDRESS','receive':{'received':'0xRECEIVING_OBJECT_ID'}},'reverse_explanation':'receive\x20calls\x20order::owner_receive\x20or\x20owner_receive_object.\x20Owner-only\x20(L1)\x20—\x20agent\x20CANNOT\x20receive.\x20Aborts\x20E_ORDER_DELIVERING\x20if\x20Progress\x20not\x20at\x20terminal.','operation_field':'receive','permission_layer':'L1_owner_only'},{'id':'P-O-09','pattern_name':'Transfer\x20ownership\x20(transfer_to)','semantic_intent':'Transfer\x20Order\x20ownership\x20to\x20new\x20address.\x20IRREVERSIBLE.\x20New\x20owner\x20takes\x20over\x20ALL\x20permissions.','match_keywords':['transfer','transfer_to','handover'],'schema_fields':['object','transfer_to'],'example_json':{'object':'0xORDER_ADDRESS','transfer_to':'0xNEW_OWNER_ADDRESS'},'reverse_explanation':'transfer_to\x20calls\x20order::owner_change(new_owner).\x20Owner-only\x20(L1).\x20IRREVERSIBLE.\x20Unlike\x20agent_set,\x20can\x20be\x20called\x20after\x20Progress\x20binding.','operation_field':'transfer_to','permission_layer':'L1_owner_only'},{'id':'P-O-10','pattern_name':'Query\x20Order\x20state\x20(read-only)','semantic_intent':'Read\x20Order\x20fields:\x20items,\x20amount,\x20owner/builder,\x20agent,\x20dispute,\x20claimed_by,\x20progress,\x20machine,\x20time','match_keywords':['query','read','check','status'],'schema_fields':['(read-only\x20via\x20query\x20layer,\x20not\x20CallOrder_Data)'],'example_json':{'_note':'Query\x20uses\x20the\x20query/object\x20endpoint,\x20not\x20CallOrder_Data','_call_target':'query','object':'0xORDER_ADDRESS','fields':['items','amount','owner','agent','dispute','claimed_by','progress','machine']},'reverse_explanation':'Query\x20is\x20read-only\x20—\x20does\x20not\x20modify\x20state.\x20Use\x20to\x20verify\x20state\x20before\x20any\x20L1/L2\x20operation.\x20SDK\x20ObjectOrder\x20returns\x20all\x2014\x20fields.','operation_field':'object'},{'id':'P-O-11','pattern_name':'Query\x20Order\x20history\x20(event\x20log)','semantic_intent':'Query\x20Order\x20lifecycle\x20events.\x20⚠️\x20Only\x20NewOrderEvent\x20is\x20actually\x20emitted\x20—\x20other\x20events\x20must\x20be\x20INFERRED\x20from\x20field\x20changes.','match_keywords':['history','events','lifecycle','audit'],'schema_fields':['(read-only\x20via\x20query\x20layer,\x20event\x20filter)'],'example_json':{'_note':'Only\x20NewOrderEvent\x20is\x20emitted\x20on-chain.\x20Other\x20lifecycle\x20events\x20must\x20be\x20inferred\x20by\x20querying\x20Order\x20field\x20diffs\x20over\x20time.','_call_target':'query','object':'0xORDER_ADDRESS','event_filter':{'type':'order::NewOrderEvent'}},'reverse_explanation':'Audit\x20weakness:\x20only\x201\x20of\x2011\x20lifecycle\x20events\x20is\x20actually\x20emitted.\x20Use\x20status_inference\x20formula\x20from\x20ORDER_AUDIT_FORMULAS\x20to\x20derive\x20state.','operation_field':'object'},{'id':'P-O-12','pattern_name':'Monitor\x20Order\x20status\x20changes\x20(polling)','semantic_intent':'Poll\x20Order\x20status\x20to\x20detect:\x20Progress\x20advance,\x20dispute\x20append,\x20claimed_by\x20set,\x20ownership\x20transfer','match_keywords':['monitor','poll','watch','track'],'schema_fields':['(read-only\x20via\x20query\x20layer,\x20polling)'],'example_json':{'_note':'Monitor\x20by\x20querying\x20Order\x20at\x20intervals\x20and\x20diffing\x20fields','_call_target':'query','object':'0xORDER_ADDRESS','poll_interval_ms':0x1388,'watch_fields':['progress','dispute','claimed_by','owner']},'reverse_explanation':'No\x20push\x20notifications\x20—\x20must\x20poll.\x20Track\x204\x20critical\x20fields:\x20progress\x20(advance),\x20dispute\x20(new\x20arb),\x20claimed_by\x20(terminal),\x20owner\x20(transfer).','operation_field':'object'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Order\x20object\x20address.\x20STRING=operate\x20existing\x20Order.\x20null/omitted\x20is\x20invalid\x20(Order\x20creation\x20goes\x20through\x20service::buy).','constraints':['Must\x20be\x20valid\x20Order\x20object\x20ID','Order\x20must\x20exist\x20on-chain']},{'element_type':'field','type_name':'agent','semantic_explanation':'Agent\x20address\x20list\x20(overwrites\x20entire\x20list).\x20Owner-only\x20(L1).\x20Frozen\x20after\x20Progress\x20binding.\x20⚠️\x20Boundary\x20bug:\x20actual\x20max\x2011\x20(not\x2010).','constraints':['<=\x20'+MAX_AGENT_COUNT+'\x20agents\x20(doc)\x20/\x2011\x20(actual\x20bug)','Owner-only','Frozen\x20after\x20Progress\x20binding']},{'element_type':'field','type_name':'required_info','semantic_explanation':'Contact\x20object\x20(recipient\x20info)\x20or\x20WTS\x20Proof\x20object\x20(delivery\x20proof).\x20null\x20clears.\x20L2\x20(owner\x20or\x20agent).','constraints':['Must\x20be\x20Contact\x20or\x20WTS\x20Proof\x20object','null\x20clears\x20the\x20field']},{'element_type':'field','type_name':'progress','semantic_explanation':'Progress\x20operation\x20object\x20—\x20advance\x20via\x20forward/hold.\x20Both\x20owner\x20and\x20agent\x20can\x20advance.\x20Node\x20transition\x20is\x20irreversible.','constraints':['Requires\x20Progress\x20binding\x20(order.progress.is_some())','L2\x20(owner\x20or\x20agent)','Node\x20transition\x20irreversible']},{'element_type':'field','type_name':'arb_confirm','semantic_explanation':'Apply\x20for\x20arbitration\x20compensation.\x20Triggers\x20dispute()\x20appending\x20Arb\x20to\x20order.dispute.\x20L2.\x20Irreversible.','constraints':['Arb\x20must\x20exist','L2\x20(owner\x20or\x20agent)','claimed_by\x20must\x20be\x20None']},{'element_type':'field','type_name':'arb_objection','semantic_explanation':'Object\x20to\x20Arb\x20ruling\x20and\x20request\x20re-arbitration.\x20Requires\x20Arb\x20status\x20=\x20Arbitrated.\x20L2.\x20Irreversible.','constraints':['Arb\x20must\x20be\x20in\x20Arbitrated\x20state','L2\x20(owner\x20or\x20agent)']},{'element_type':'field','type_name':'arb_claim_compensation','semantic_explanation':'Claim\x20compensation\x20from\x20ruled\x20Arb.\x20Sets\x20claimed_by.\x20ONE-TIME,\x20IRREVERSIBLE,\x20blocks\x20future\x20disputes.\x20L2.','constraints':['Arb\x20must\x20be\x20Arbitrated','claimed_by\x20must\x20be\x20None','L2\x20(owner\x20or\x20agent)','IRREVERSIBLE']},{'element_type':'field','type_name':'receive','semantic_explanation':'Receive\x20CoinWrapper\x20or\x20arbitrary\x20Receiving<K>\x20from\x20Progress.\x20Funds\x20forwarded\x20to\x20owner.\x20Owner-only\x20(L1)\x20—\x20agent\x20CANNOT.','constraints':['Owner-only\x20(L1)','Progress\x20must\x20be\x20at\x20terminal\x20node\x20(not\x20delivering)','Can\x20be\x20called\x20multiple\x20times']},{'element_type':'field','type_name':'transfer_to','semantic_explanation':'New\x20owner\x20address\x20for\x20ownership\x20transfer.\x20IRREVERSIBLE.\x20New\x20owner\x20takes\x20over\x20ALL\x20permissions.\x20Owner-only\x20(L1).','constraints':['Owner-only\x20(L1)','IRREVERSIBLE','Valid\x20Wow\x20address']},{'element_type':'op','type_name':'forward','semantic_explanation':'Advance\x20Progress\x20to\x20next\x20node\x20via\x20named\x20forward.\x20Triggers\x20Progress::operate.','constraints':['Forward\x20name\x20must\x20exist\x20on\x20current\x20node','Guard\x20(if\x20any)\x20must\x20pass']},{'element_type':'op','type_name':'hold','semantic_explanation':'Hold\x20at\x20current\x20Progress\x20node\x20(optional\x20pause).','constraints':['Node\x20must\x20support\x20hold']},{'element_type':'op','type_name':'confirm','semantic_explanation':'In\x20arb_confirm:\x20true=confirm\x20materials\x20valid,\x20false=deny\x20materials.','constraints':['Boolean\x20—\x20no\x20other\x20values']},{'element_type':'index','type_name':'dispute_index','semantic_explanation':'Position\x20in\x20order.dispute\x20vector.\x200-based.\x20Max\x2010\x20disputes\x20total.','constraints':['<=\x20'+MAX_DISPUTE_COUNT+'\x20disputes','Frozen\x20when\x20claimed_by.is_some()']},{'element_type':'error','type_name':'E_OWNER\x20(code\x201)','semantic_explanation':'Sender\x20!=\x20order.owner.\x20L1\x20operation\x20attempted\x20by\x20non-owner\x20(agent\x20or\x20third\x20party).','constraints':['Aborts\x20assert_owner']},{'element_type':'error','type_name':'E_PERMISSION\x20(code\x205)','semantic_explanation':'Sender\x20is\x20neither\x20owner\x20nor\x20in\x20agent[].\x20L2\x20operation\x20attempted\x20by\x20unauthorized\x20caller.','constraints':['Aborts\x20assert_op_permission\x20(via\x20has_op_permission\x20returning\x20false)']},{'element_type':'error','type_name':'E_PROGRESS_NOT_SPECIFIED\x20(code\x203)','semantic_explanation':'⚠️\x20DUAL\x20SEMANTICS:\x20(a)\x20order::create\x20—\x20machine\x20is\x20Some\x20but\x20progress\x20is\x20None;\x20(b)\x20agent_set/owner_change\x20—\x20progress\x20is\x20already\x20bound\x20(frozen).','constraints':['Check\x20context\x20to\x20disambiguate','Same\x20code,\x20opposite\x20meanings']},{'element_type':'error','type_name':'E_ORDER_ALREADY_CLAIMED\x20(code\x207)','semantic_explanation':'claimed_by\x20is\x20already\x20Some.\x20Cannot\x20file\x20new\x20disputes,\x20claim\x20again,\x20or\x20call\x20compensate.','constraints':['IRREVERSIBLE\x20—\x20no\x20way\x20to\x20reset\x20claimed_by']},{'element_type':'error','type_name':'E_MAX_AGENT_COUNT\x20(code\x202)','semantic_explanation':'agent\x20list\x20exceeds\x20MAX_AGENT_COUNT\x20(10).\x20⚠️\x20Actual\x20boundary\x20uses\x20<=\x20so\x20allows\x2011\x20(bug).','constraints':['Doc\x20limit:\x20'+MAX_AGENT_COUNT,'Actual\x20limit:\x2011\x20(boundary\x20bug)']},{'element_type':'error','type_name':'E_MAX_DISPUTE_COUNT\x20(code\x206)','semantic_explanation':'dispute\x20vector\x20at\x20MAX_DISPUTE_COUNT\x20(10).\x20Next\x20dispute()\x20call\x20aborts.','constraints':['Max:\x20'+MAX_DISPUTE_COUNT]},{'element_type':'error','type_name':'E_ALLOCATION_NOT_SPECIFIED\x20(code\x208)','semantic_explanation':'order::create\x20with\x20amount\x20>\x200\x20but\x20allocation\x20is\x20None.','constraints':['If\x20amount\x20>\x200,\x20allocation\x20must\x20be\x20set']},{'element_type':'error','type_name':'E_ALLOCATION_ALREADY_SPECIFIED\x20(code\x209)','semantic_explanation':'on_allocation\x20called\x20twice.\x20Allocation\x20is\x20one-time\x20set.','constraints':['One-time\x20only']},{'element_type':'error','type_name':'E_PROGRESS_ALREADY_SPECIFIED\x20(code\x2010)','semantic_explanation':'on_progress\x20called\x20twice.\x20Progress\x20is\x20one-time\x20set.','constraints':['One-time\x20only']}];export const ORDER_CONSTRAINT_RULES=[{'id':'MC-O-01','category':'structural','rule':'Order\x20has\x2014\x20fields;\x20SDK\x20uses\x20\x27builder\x27\x20for\x20Move\x27s\x20\x27owner\x27\x20(only\x20naming\x20deviation\x20in\x2022\x20objects)','applies_to':['object.owner','object.builder']},{'id':'MC-O-02','category':'structural','rule':'agent\x20count\x20<=\x20MAX_AGENT_COUNT\x20('+MAX_AGENT_COUNT+')\x20per\x20docs;\x20⚠️\x20actual\x20allows\x2011\x20due\x20to\x20<=\x20bug','applies_to':['agent']},{'id':'MC-O-03','category':'structural','rule':'dispute\x20count\x20<=\x20MAX_DISPUTE_COUNT\x20('+MAX_DISPUTE_COUNT+');\x20frozen\x20when\x20claimed_by.is_some()','applies_to':['dispute']},{'id':'MC-O-04','category':'structural','rule':'Order\x20creation\x20is\x20COMPOSITE\x20via\x20service::buy\x20—\x20order::create\x20is\x20package-only','applies_to':['(creation\x20flow)']},{'id':'MC-O-05','category':'semantic','rule':'order.machine\x20is\x20a\x20SNAPSHOT\x20copied\x20from\x20service.machine\x20at\x20buy\x20time\x20(not\x20a\x20reference)','applies_to':['machine']},{'id':'MC-O-06','category':'semantic','rule':'E_PROGRESS_NOT_SPECIFIED\x20has\x20DUAL\x20semantics:\x20(a)\x20create:\x20machine\x20Some\x20+\x20progress\x20None;\x20(b)\x20agent_set/owner_change:\x20progress\x20already\x20bound','applies_to':['error\x20code\x203']},{'id':'MC-O-07','category':'semantic','rule':'Only\x20NewOrderEvent\x20is\x20actually\x20emitted;\x2010\x20other\x20lifecycle\x20events\x20must\x20be\x20inferred\x20from\x20field\x20changes','applies_to':['events']},{'id':'MC-O-08','category':'semantic','rule':'SaleItem.item\x20↔\x20PurchasedItem.name\x20(different\x20field\x20names\x20for\x20same\x20concept)','applies_to':['items.item','purchased_items.name']},{'id':'MC-O-09','category':'authority','rule':'L1\x20owner-only\x20operations:\x20receive,\x20transfer_to,\x20owner_change,\x20agent_set\x20(assert_owner)','applies_to':['receive','transfer_to','agent']},{'id':'MC-O-10','category':'authority','rule':'L2\x20owner-or-agent\x20operations:\x20required_info,\x20progress,\x20arb_confirm,\x20arb_objection,\x20arb_claim_compensation\x20(has_op_permission)','applies_to':['required_info','progress','arb_confirm','arb_objection','arb_claim_compensation']},{'id':'MC-O-11','category':'authority','rule':'L3\x20package-only\x20operations:\x20on_progress,\x20on_allocation,\x20dispute,\x20compensate\x20(no\x20external\x20access)','applies_to':['(package-only\x20functions)']},{'id':'MC-O-12','category':'authority','rule':'Agent\x20CANNOT\x20receive\x20payments\x20—\x20only\x20owner\x20can\x20call\x20owner_receive\x20/\x20owner_receive_object','applies_to':['receive']},{'id':'MC-O-13','category':'lifecycle','rule':'Progress\x20binding\x20FREEZES\x20owner\x20and\x20agent\x20—\x20agent_set/owner_change\x20abort\x20E_PROGRESS_NOT_SPECIFIED\x20after\x20binding','applies_to':['agent','transfer_to\x20(pre-progress)','owner_change']},{'id':'MC-O-14','category':'lifecycle','rule':'claimed_by\x20is\x20ONE-TIME,\x20IRREVERSIBLE\x20—\x20blocks\x20future\x20dispute(),\x20compensate(),\x20and\x20arb_claim_compensation','applies_to':['claimed_by','arb_claim_compensation','dispute']},{'id':'MC-O-15','category':'cross_object','rule':'Order\x20+\x20Allocation\x20+\x20Progress\x20are\x201:1:1\x20bound\x20at\x20creation;\x20cannot\x20rebind\x20or\x20detach','applies_to':['progress','allocation']}];export const ORDER_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase']();return SEMANTIC_TO_SCHEMA_RULES['filter'](c=>c['match_keywords']['some'](d=>b['includes'](d['toLowerCase']())));}export function explainOrderCallData(b){const c=[];if(!b['object'])return c['push']('Operation:\x20⚠️\x20INVALID\x20—\x20Order\x20object\x20address\x20required\x20(Order\x20creation\x20goes\x20through\x20service::buy,\x20not\x20CallOrder_Data)'),c['join']('\x0a');c['push']('Operation:\x20MODIFY\x20existing\x20Order\x20at\x20'+b['object']);b['agent']&&(c['push']('-\x20⚠️\x20Set\x20agent\x20list\x20('+b['agent']['length']+'\x20agent(s)):\x20['+b['agent']['join'](',\x20')+']'),c['push']('\x20\x20Owner-only\x20(L1).\x20Frozen\x20after\x20Progress\x20binding.\x20Boundary\x20bug\x20allows\x20max\x2011\x20(not\x2010).'));b['required_info']!==undefined&&(b['required_info']===null?c['push']('-\x20Clear\x20required_info\x20(L2\x20—\x20owner\x20or\x20agent)'):c['push']('-\x20Set\x20required_info:\x20'+b['required_info']+'\x20(Contact\x20or\x20WTS\x20Proof;\x20L2\x20—\x20owner\x20or\x20agent)'));if(b['progress']){const d=b['progress'];c['push']('-\x20Advance\x20Progress\x20(L2\x20—\x20owner\x20or\x20agent)');if(d['next_node_name'])c['push']('\x20\x20Next\x20node:\x20'+d['next_node_name']);if(d['forward'])c['push']('\x20\x20Forward:\x20'+d['forward']['name']+(d['forward']['operator']?'\x20(operator:\x20'+d['forward']['operator']+')':''));if(d['op'])c['push']('\x20\x20Op:\x20'+d['op']);if(d['message'])c['push']('\x20\x20Message:\x20\x22'+d['message']+'\x22');}if(b['arb_confirm']){const e=b['arb_confirm'];c['push']('-\x20⚠️\x20Apply\x20for\x20arbitration\x20(L2\x20—\x20owner\x20or\x20agent,\x20IRREVERSIBLE)'),c['push']('\x20\x20Arb:\x20'+e['arb']),c['push']('\x20\x20Confirm:\x20'+(e['confirm']?'valid\x20materials':'deny\x20materials'));if(e['description'])c['push']('\x20\x20Description:\x20\x22'+e['description']+'\x22');e['proposition']&&e['proposition']['length']>0x0&&c['push']('\x20\x20Propositions:\x20'+e['proposition']['length']+'\x20claim(s)');}if(b['arb_objection']){const f=b['arb_objection'];c['push']('-\x20⚠️\x20Object\x20to\x20Arb\x20ruling\x20(L2\x20—\x20owner\x20or\x20agent,\x20IRREVERSIBLE)'),c['push']('\x20\x20Arb:\x20'+f['arb']),c['push']('\x20\x20Objection:\x20\x22'+f['objection']+'\x22');}if(b['arb_claim_compensation']){const g=b['arb_claim_compensation'];c['push']('-\x20⚠️⚠️\x20CLAIM\x20COMPENSATION\x20(L2\x20—\x20owner\x20or\x20agent,\x20ONE-TIME,\x20IRREVERSIBLE)'),c['push']('\x20\x20Arb:\x20'+g['arb']),c['push']('\x20\x20After\x20claim:\x20NO\x20new\x20disputes\x20can\x20be\x20filed\x20(E_ORDER_ALREADY_CLAIMED)');}return b['receive']&&(c['push']('-\x20Receive\x20(L1\x20—\x20OWNER-ONLY,\x20agent\x20CANNOT)'),c['push']('\x20\x20Received\x20object:\x20'+b['receive']['received']),c['push']('\x20\x20Funds/objects\x20forwarded\x20to\x20owner\x20address')),b['transfer_to']&&(c['push']('-\x20⚠️⚠️\x20TRANSFER\x20OWNERSHIP\x20to\x20'+b['transfer_to']+'\x20(L1\x20—\x20OWNER-ONLY,\x20IRREVERSIBLE)'),c['push']('\x20\x20New\x20owner\x20takes\x20over\x20ALL\x20permissions'),c['push']('\x20\x20Can\x20be\x20called\x20even\x20after\x20Progress\x20binding\x20(unlike\x20agent_set)')),c['join']('\x0a');}export function explainField(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='field'&&b['type_name']===a);}export function explainOp(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='op'&&b['type_name']===a);}export function explainOrderError(a){const b=String(a);return SCHEMA_TO_SEMANTIC_RULES['find'](c=>c['element_type']==='error'&&(c['type_name']===b||c['type_name']['startsWith'](b+'\x20')||c['type_name']['includes'](b)));}export function getConstraintsByCategory(a){return ORDER_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainPermissionLayer(a){const b={'L1_owner_only':'L1\x20—\x20Owner-only\x20(assert_owner).\x20Aborts\x20E_OWNER\x20(code\x201)\x20if\x20sender\x20!=\x20owner.\x20Agent\x20CANNOT\x20perform\x20L1\x20ops.','L2_owner_or_agent':'L2\x20—\x20Owner\x20or\x20agent\x20(has_op_permission).\x20Aborts\x20E_PERMISSION\x20(code\x205)\x20if\x20sender\x20is\x20neither\x20owner\x20nor\x20in\x20agent[].','L3_package_only':'L3\x20—\x20Package-only\x20(no\x20external\x20access).\x20Called\x20by\x20other\x20wow-framework\x20modules\x20(progress,\x20allocation,\x20arbitration).'};return b[a];}export function resolveFieldName(a){if(a==='builder'||a==='owner')return{'sdk_name':'builder','move_name':'owner','is_deviation':!![]};return{'sdk_name':a,'move_name':a,'is_deviation':![]};}export function matchSceneFromOperation(a){const b=ORDER_SCENES['filter'](c=>c['operation_field']===a);return b['length']>0x0?b[0x0]:undefined;}export function explainOrderIntent(a){const b=inferSceneFromIntent(a),c=matchSemanticPattern(a),d=b?ORDER_CONSTRAINT_RULES['filter'](e=>{if(b['permission_layer']==='L1_owner_only')return e['category']==='authority'||e['category']==='lifecycle';if(b['permission_layer']==='L2_owner_or_agent')return e['category']==='authority'||e['category']==='semantic';return e['category']==='structural'||e['category']==='cross_object';}):ORDER_CONSTRAINT_RULES;return{'matched_scene':b,'matched_patterns':c,'relevant_constraints':d};}