@wowok/agent-mcp 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/account-events.d.ts +32 -0
  4. package/dist/customer/account-events.js +1 -0
  5. package/dist/customer/customer-advice.d.ts +1 -0
  6. package/dist/customer/customer-advice.js +1 -130
  7. package/dist/customer/index.js +1 -11
  8. package/dist/customer/industry-risks.js +1 -438
  9. package/dist/customer/info-puzzle.js +1 -681
  10. package/dist/customer/order-monitor.js +1 -328
  11. package/dist/customer/order-strategy.d.ts +1 -1
  12. package/dist/customer/order-strategy.js +1 -373
  13. package/dist/customer/post-purchase.js +1 -351
  14. package/dist/customer/preorder-compare.js +1 -34
  15. package/dist/customer/reminder-system.d.ts +2 -0
  16. package/dist/customer/reminder-system.js +1 -316
  17. package/dist/customer/risk-assessment.d.ts +1 -0
  18. package/dist/customer/risk-assessment.js +1 -397
  19. package/dist/customer/types.d.ts +2 -0
  20. package/dist/customer/types.js +1 -13
  21. package/dist/customer/user-preferences.js +1 -460
  22. package/dist/evaluation/arbitration-game.d.ts +9 -2
  23. package/dist/evaluation/arbitration-game.js +1 -48
  24. package/dist/evaluation/builtins/arbitration-score.d.ts +41 -0
  25. package/dist/evaluation/builtins/arbitration-score.js +1 -0
  26. package/dist/evaluation/builtins/demand-match.js +1 -153
  27. package/dist/evaluation/builtins/index.d.ts +1 -0
  28. package/dist/evaluation/builtins/index.js +1 -10
  29. package/dist/evaluation/builtins/service-risk.js +1 -55
  30. package/dist/evaluation/capability.js +1 -13
  31. package/dist/evaluation/category-match-rules.d.ts +30 -0
  32. package/dist/evaluation/category-match-rules.js +1 -0
  33. package/dist/evaluation/composer.js +1 -40
  34. package/dist/evaluation/engine.js +1 -175
  35. package/dist/evaluation/extract.js +1 -115
  36. package/dist/evaluation/game-strategy.d.ts +27 -0
  37. package/dist/evaluation/game-strategy.js +1 -0
  38. package/dist/evaluation/gap.js +1 -100
  39. package/dist/evaluation/index.d.ts +2 -0
  40. package/dist/evaluation/index.js +1 -11
  41. package/dist/evaluation/location-match.d.ts +42 -0
  42. package/dist/evaluation/location-match.js +1 -0
  43. package/dist/evaluation/node-game.d.ts +31 -3
  44. package/dist/evaluation/node-game.js +1 -57
  45. package/dist/evaluation/path-reasoning.d.ts +35 -0
  46. package/dist/evaluation/path-reasoning.js +1 -0
  47. package/dist/evaluation/region.d.ts +6 -0
  48. package/dist/evaluation/region.js +1 -36
  49. package/dist/evaluation/types.d.ts +18 -0
  50. package/dist/evaluation/types.js +1 -1
  51. package/dist/evaluation/user-injection.js +1 -27
  52. package/dist/experience/experience-reuse.js +1 -103
  53. package/dist/experience/index.js +1 -5
  54. package/dist/experience/intent-distill.js +1 -83
  55. package/dist/experience/realtime-feedback.js +1 -94
  56. package/dist/experience/types.js +1 -1
  57. package/dist/experience/user-profile.d.ts +1 -1
  58. package/dist/experience/user-profile.js +1 -171
  59. package/dist/extensions/business-modules.js +1 -287
  60. package/dist/extensions/capability-manifest.js +1 -781
  61. package/dist/extensions/constraint-registry.js +1 -198
  62. package/dist/extensions/index.d.ts +6 -0
  63. package/dist/extensions/index.js +1 -6
  64. package/dist/extensions/industry-layers.d.ts +75 -0
  65. package/dist/extensions/industry-layers.js +1 -0
  66. package/dist/extensions/industry-pack.d.ts +105 -0
  67. package/dist/extensions/industry-pack.js +1 -0
  68. package/dist/extensions/metric-registry.js +1 -257
  69. package/dist/extensions/mode-evaluator.d.ts +1 -1
  70. package/dist/extensions/mode-evaluator.js +1 -170
  71. package/dist/extensions/modes.js +1 -499
  72. package/dist/extensions/registry.d.ts +1 -0
  73. package/dist/extensions/registry.js +1 -717
  74. package/dist/extensions/types.js +1 -1
  75. package/dist/graph/base.d.ts +8 -0
  76. package/dist/graph/base.js +1 -0
  77. package/dist/harness/auto-escalation.js +1 -68
  78. package/dist/harness/checkpoint.js +1 -129
  79. package/dist/harness/index.d.ts +1 -0
  80. package/dist/harness/index.js +1 -78
  81. package/dist/harness/plan.d.ts +2 -0
  82. package/dist/harness/plan.js +1 -315
  83. package/dist/harness/recover.d.ts +1 -1
  84. package/dist/harness/recover.js +1 -139
  85. package/dist/harness/types.d.ts +2 -3
  86. package/dist/harness/types.js +1 -1
  87. package/dist/harness/verify.js +1 -237
  88. package/dist/index.js +1 -273
  89. package/dist/intent/enrich.js +1 -67
  90. package/dist/intent/index.js +1 -60
  91. package/dist/intent/matcher.js +1 -81
  92. package/dist/intent/store.js +1 -55
  93. package/dist/intent/types.js +1 -10
  94. package/dist/knowledge/acquisition-flywheel.js +1 -192
  95. package/dist/knowledge/allocation-confirm.js +1 -534
  96. package/dist/knowledge/allocation-context.js +1 -249
  97. package/dist/knowledge/allocation-ledger.js +1 -463
  98. package/dist/knowledge/allocation-puzzle.js +1 -298
  99. package/dist/knowledge/allocation-risk.js +1 -568
  100. package/dist/knowledge/allocation-templates.js +1 -970
  101. package/dist/knowledge/allocation-translation.js +1 -585
  102. package/dist/knowledge/anti-cheat.d.ts +37 -0
  103. package/dist/knowledge/anti-cheat.js +1 -0
  104. package/dist/knowledge/arb-confirm.d.ts +28 -0
  105. package/dist/knowledge/arb-confirm.js +1 -0
  106. package/dist/knowledge/arb-risk.js +1 -210
  107. package/dist/knowledge/arb-translation.d.ts +48 -0
  108. package/dist/knowledge/arb-translation.js +1 -0
  109. package/dist/knowledge/arbitration-confirm.js +1 -559
  110. package/dist/knowledge/arbitration-context.js +1 -505
  111. package/dist/knowledge/arbitration-ledger.js +1 -521
  112. package/dist/knowledge/arbitration-puzzle.js +1 -304
  113. package/dist/knowledge/arbitration-risk.js +1 -423
  114. package/dist/knowledge/arbitration-templates.js +1 -276
  115. package/dist/knowledge/arbitration-translation.js +1 -487
  116. package/dist/knowledge/audit-rules.js +1 -141
  117. package/dist/knowledge/bridge-confirm.d.ts +26 -0
  118. package/dist/knowledge/bridge-confirm.js +1 -0
  119. package/dist/knowledge/bridge-risk.js +1 -263
  120. package/dist/knowledge/bridge-translation.d.ts +37 -0
  121. package/dist/knowledge/bridge-translation.js +1 -0
  122. package/dist/knowledge/contact-confirm.d.ts +27 -0
  123. package/dist/knowledge/contact-confirm.js +1 -0
  124. package/dist/knowledge/contact-risk.js +1 -200
  125. package/dist/knowledge/contact-templates.js +1 -60
  126. package/dist/knowledge/contact-translation.d.ts +39 -0
  127. package/dist/knowledge/contact-translation.js +1 -0
  128. package/dist/knowledge/demand-confirm.js +1 -206
  129. package/dist/knowledge/demand-context.d.ts +17 -0
  130. package/dist/knowledge/demand-context.js +1 -0
  131. package/dist/knowledge/demand-ledger.d.ts +26 -0
  132. package/dist/knowledge/demand-ledger.js +1 -0
  133. package/dist/knowledge/demand-matching.js +1 -132
  134. package/dist/knowledge/demand-puzzle.d.ts +29 -0
  135. package/dist/knowledge/demand-puzzle.js +1 -0
  136. package/dist/knowledge/demand-risk.js +1 -240
  137. package/dist/knowledge/demand-templates.d.ts +12 -0
  138. package/dist/knowledge/demand-templates.js +1 -0
  139. package/dist/knowledge/demand-translation.js +1 -354
  140. package/dist/knowledge/deployment-scanner.js +1 -823
  141. package/dist/knowledge/dynamic-pricing.js +1 -87
  142. package/dist/knowledge/evidence-review.d.ts +12 -0
  143. package/dist/knowledge/evidence-review.js +1 -0
  144. package/dist/knowledge/examples-scanner-cli.js +1 -26
  145. package/dist/knowledge/examples-scanner.js +1 -843
  146. package/dist/knowledge/flywheel-loop.d.ts +0 -1
  147. package/dist/knowledge/flywheel-loop.js +1 -404
  148. package/dist/knowledge/fund-layer.js +1 -973
  149. package/dist/knowledge/glossary.js +1 -211
  150. package/dist/knowledge/guard-confirm.js +1 -406
  151. package/dist/knowledge/guard-context.js +1 -287
  152. package/dist/knowledge/guard-design-patterns.js +1 -360
  153. package/dist/knowledge/guard-ledger.js +1 -260
  154. package/dist/knowledge/guard-lint.js +1 -670
  155. package/dist/knowledge/guard-migration.d.ts +1 -1
  156. package/dist/knowledge/guard-migration.js +1 -228
  157. package/dist/knowledge/guard-puzzle.js +1 -805
  158. package/dist/knowledge/guard-render.js +1 -700
  159. package/dist/knowledge/guard-risk.js +1 -1879
  160. package/dist/knowledge/guard-submission-prompt.js +1 -171
  161. package/dist/knowledge/guard-templates.js +1 -1105
  162. package/dist/knowledge/guard-translation.js +1 -1119
  163. package/dist/knowledge/index.d.ts +71 -3
  164. package/dist/knowledge/index.js +1 -436
  165. package/dist/knowledge/industry-evolution.js +1 -323
  166. package/dist/knowledge/industry-generalizer.js +1 -381
  167. package/dist/knowledge/industry-registry.js +1 -174
  168. package/dist/knowledge/intent-metrics.d.ts +4 -3
  169. package/dist/knowledge/intent-metrics.js +1 -566
  170. package/dist/knowledge/machine-confirm.js +1 -559
  171. package/dist/knowledge/machine-context.js +1 -833
  172. package/dist/knowledge/machine-ledger.js +1 -338
  173. package/dist/knowledge/machine-puzzle.js +1 -494
  174. package/dist/knowledge/machine-render.js +1 -565
  175. package/dist/knowledge/machine-risk.js +1 -669
  176. package/dist/knowledge/machine-templates.js +1 -1597
  177. package/dist/knowledge/machine-topology.js +1 -234
  178. package/dist/knowledge/machine-translation.js +1 -513
  179. package/dist/knowledge/market-metrics.d.ts +12 -0
  180. package/dist/knowledge/market-metrics.js +1 -0
  181. package/dist/knowledge/market-operations.d.ts +46 -0
  182. package/dist/knowledge/market-operations.js +1 -0
  183. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  184. package/dist/knowledge/mcp-schema-audit.d.ts +22 -22
  185. package/dist/knowledge/mcp-schema-audit.js +1 -777
  186. package/dist/knowledge/onchain-constants.js +1 -35
  187. package/dist/knowledge/order-confirm.js +1 -573
  188. package/dist/knowledge/order-context.js +1 -390
  189. package/dist/knowledge/order-ledger.js +1 -341
  190. package/dist/knowledge/order-puzzle.js +1 -255
  191. package/dist/knowledge/order-risk.js +1 -653
  192. package/dist/knowledge/order-templates.js +1 -368
  193. package/dist/knowledge/order-translation.js +1 -550
  194. package/dist/knowledge/overrides-loader.js +1 -65
  195. package/dist/knowledge/passport-confirm.js +1 -531
  196. package/dist/knowledge/passport-context.js +1 -306
  197. package/dist/knowledge/passport-ledger.js +1 -282
  198. package/dist/knowledge/passport-puzzle.js +1 -333
  199. package/dist/knowledge/passport-risk.js +1 -450
  200. package/dist/knowledge/passport-templates.js +1 -568
  201. package/dist/knowledge/passport-translation.js +1 -516
  202. package/dist/knowledge/payment-confirm.d.ts +26 -0
  203. package/dist/knowledge/payment-confirm.js +1 -0
  204. package/dist/knowledge/payment-risk.js +1 -249
  205. package/dist/knowledge/payment-translation.d.ts +37 -0
  206. package/dist/knowledge/payment-translation.js +1 -0
  207. package/dist/knowledge/permission-confirm.js +1 -426
  208. package/dist/knowledge/permission-context.js +1 -224
  209. package/dist/knowledge/permission-ledger.d.ts +11 -0
  210. package/dist/knowledge/permission-ledger.js +1 -403
  211. package/dist/knowledge/permission-puzzle.js +1 -173
  212. package/dist/knowledge/permission-risk.js +1 -411
  213. package/dist/knowledge/permission-templates.js +1 -234
  214. package/dist/knowledge/permission-translation.js +1 -350
  215. package/dist/knowledge/personal-confirm.d.ts +29 -0
  216. package/dist/knowledge/personal-confirm.js +1 -0
  217. package/dist/knowledge/personal-risk.js +1 -212
  218. package/dist/knowledge/personal-translation.d.ts +37 -0
  219. package/dist/knowledge/personal-translation.js +1 -0
  220. package/dist/knowledge/process-model.d.ts +1 -11
  221. package/dist/knowledge/process-model.js +1 -160
  222. package/dist/knowledge/progress-confirm.js +1 -456
  223. package/dist/knowledge/progress-context.js +1 -452
  224. package/dist/knowledge/progress-ledger.js +1 -330
  225. package/dist/knowledge/progress-puzzle.js +1 -219
  226. package/dist/knowledge/progress-risk.js +1 -461
  227. package/dist/knowledge/progress-templates.js +1 -228
  228. package/dist/knowledge/progress-translation.js +1 -405
  229. package/dist/knowledge/proof-confirm.js +1 -187
  230. package/dist/knowledge/proof-context.d.ts +17 -0
  231. package/dist/knowledge/proof-context.js +1 -0
  232. package/dist/knowledge/proof-ledger.d.ts +34 -0
  233. package/dist/knowledge/proof-ledger.js +1 -0
  234. package/dist/knowledge/proof-puzzle.d.ts +35 -0
  235. package/dist/knowledge/proof-puzzle.js +1 -0
  236. package/dist/knowledge/proof-risk.js +1 -207
  237. package/dist/knowledge/proof-templates.d.ts +22 -0
  238. package/dist/knowledge/proof-templates.js +1 -0
  239. package/dist/knowledge/proof-translation.js +1 -283
  240. package/dist/knowledge/registrar-confirm.d.ts +26 -0
  241. package/dist/knowledge/registrar-confirm.js +1 -0
  242. package/dist/knowledge/registrar-risk.js +1 -217
  243. package/dist/knowledge/registrar-translation.d.ts +37 -0
  244. package/dist/knowledge/registrar-translation.js +1 -0
  245. package/dist/knowledge/repository-confirm.js +1 -286
  246. package/dist/knowledge/repository-context.d.ts +12 -0
  247. package/dist/knowledge/repository-context.js +1 -0
  248. package/dist/knowledge/repository-ledger.d.ts +25 -0
  249. package/dist/knowledge/repository-ledger.js +1 -0
  250. package/dist/knowledge/repository-puzzle.d.ts +30 -0
  251. package/dist/knowledge/repository-puzzle.js +1 -0
  252. package/dist/knowledge/repository-risk.js +1 -373
  253. package/dist/knowledge/repository-templates.d.ts +14 -0
  254. package/dist/knowledge/repository-templates.js +1 -0
  255. package/dist/knowledge/repository-translation.js +1 -445
  256. package/dist/knowledge/reputation-rules.js +1 -99
  257. package/dist/knowledge/resource-confirm.d.ts +25 -0
  258. package/dist/knowledge/resource-confirm.js +1 -0
  259. package/dist/knowledge/resource-risk.js +1 -157
  260. package/dist/knowledge/resource-translation.d.ts +37 -0
  261. package/dist/knowledge/resource-translation.js +1 -0
  262. package/dist/knowledge/reward-confirm.js +1 -526
  263. package/dist/knowledge/reward-context.d.ts +2 -2
  264. package/dist/knowledge/reward-context.js +1 -504
  265. package/dist/knowledge/reward-ledger.js +1 -502
  266. package/dist/knowledge/reward-puzzle.js +1 -300
  267. package/dist/knowledge/reward-risk.js +1 -627
  268. package/dist/knowledge/reward-templates.js +1 -197
  269. package/dist/knowledge/reward-translation.js +1 -501
  270. package/dist/knowledge/safety-rules.d.ts +1 -0
  271. package/dist/knowledge/safety-rules.js +1 -404
  272. package/dist/knowledge/scenario-modes.js +1 -321
  273. package/dist/knowledge/service-confirm.js +1 -807
  274. package/dist/knowledge/service-context.js +1 -403
  275. package/dist/knowledge/service-ledger.js +1 -609
  276. package/dist/knowledge/service-puzzle.js +1 -236
  277. package/dist/knowledge/service-risk.d.ts +1 -1
  278. package/dist/knowledge/service-risk.js +1 -651
  279. package/dist/knowledge/service-templates.js +1 -456
  280. package/dist/knowledge/service-translation.js +1 -622
  281. package/dist/knowledge/template-registry.js +1 -353
  282. package/dist/knowledge/tool-constraints.js +1 -195
  283. package/dist/knowledge/tools-reference.js +1 -178
  284. package/dist/knowledge/treasury-confirm.js +1 -512
  285. package/dist/knowledge/treasury-context.js +1 -363
  286. package/dist/knowledge/treasury-ledger.js +1 -300
  287. package/dist/knowledge/treasury-puzzle.js +1 -216
  288. package/dist/knowledge/treasury-risk.js +1 -440
  289. package/dist/knowledge/treasury-templates.js +1 -358
  290. package/dist/knowledge/treasury-translation.js +1 -498
  291. package/dist/knowledge/trust-metrics.js +1 -198
  292. package/dist/knowledge/universal-template.d.ts +22 -0
  293. package/dist/knowledge/universal-template.js +1 -0
  294. package/dist/knowledge/util-confirm.d.ts +24 -0
  295. package/dist/knowledge/util-confirm.js +1 -0
  296. package/dist/knowledge/util-risk.js +1 -135
  297. package/dist/knowledge/util-translation.d.ts +38 -0
  298. package/dist/knowledge/util-translation.js +1 -0
  299. package/dist/knowledge/workflow-guidance.d.ts +116 -0
  300. package/dist/knowledge/workflow-guidance.js +1 -0
  301. package/dist/loop-engineering/aggregate.js +1 -132
  302. package/dist/loop-engineering/context-collect.js +1 -83
  303. package/dist/loop-engineering/diagnose.js +1 -273
  304. package/dist/loop-engineering/improve.js +1 -405
  305. package/dist/loop-engineering/index.js +1 -4
  306. package/dist/loop-engineering/pipeline.js +1 -56
  307. package/dist/mode-market/index.js +1 -3
  308. package/dist/mode-market/registry.js +1 -124
  309. package/dist/mode-market/review.js +1 -214
  310. package/dist/mode-market/submission.js +1 -85
  311. package/dist/participation/collaborator-interest.d.ts +23 -0
  312. package/dist/participation/collaborator-interest.js +1 -0
  313. package/dist/participation/customer-interest.d.ts +25 -0
  314. package/dist/participation/customer-interest.js +1 -0
  315. package/dist/participation/employee-kpi.d.ts +25 -0
  316. package/dist/participation/employee-kpi.js +1 -0
  317. package/dist/participation/employee-store.d.ts +16 -0
  318. package/dist/participation/employee-store.js +1 -0
  319. package/dist/participation/index.d.ts +2 -0
  320. package/dist/participation/index.js +1 -0
  321. package/dist/participation/merchant-interest.js +1 -100
  322. package/dist/participation/radar-core.d.ts +13 -3
  323. package/dist/participation/radar-core.js +1 -269
  324. package/dist/participation/supplier-interest.d.ts +25 -0
  325. package/dist/participation/supplier-interest.js +1 -0
  326. package/dist/persona/analyzer.js +1 -66
  327. package/dist/persona/bridge.js +1 -86
  328. package/dist/persona/defaults.js +1 -195
  329. package/dist/persona/experience-bridge.js +1 -23
  330. package/dist/persona/index.d.ts +9 -2
  331. package/dist/persona/index.js +1 -71
  332. package/dist/persona/local-region.d.ts +20 -0
  333. package/dist/persona/local-region.js +1 -0
  334. package/dist/persona/model.js +1 -111
  335. package/dist/persona/overrides.d.ts +10 -0
  336. package/dist/persona/overrides.js +1 -0
  337. package/dist/persona/pack-personae.d.ts +11 -0
  338. package/dist/persona/pack-personae.js +1 -0
  339. package/dist/persona/store.js +1 -62
  340. package/dist/persona/strategy-intent.d.ts +20 -0
  341. package/dist/persona/strategy-intent.js +1 -0
  342. package/dist/persona/types.d.ts +6 -2
  343. package/dist/persona/types.js +1 -5
  344. package/dist/project/business-puzzle.d.ts +1 -1
  345. package/dist/project/business-puzzle.js +1 -383
  346. package/dist/project/context-assembly.js +1 -254
  347. package/dist/project/deployment-bridge.js +1 -120
  348. package/dist/project/deployment-doc.js +1 -1126
  349. package/dist/project/edit-planner.js +1 -1342
  350. package/dist/project/evaluation.d.ts +37 -1
  351. package/dist/project/evaluation.js +1 -2011
  352. package/dist/project/game-theory.js +1 -177
  353. package/dist/project/graph-builder.js +1 -656
  354. package/dist/project/graph.d.ts +3 -6
  355. package/dist/project/graph.js +1 -340
  356. package/dist/project/handlers.d.ts +33 -2
  357. package/dist/project/handlers.js +1 -1784
  358. package/dist/project/index.d.ts +2 -0
  359. package/dist/project/index.js +1 -301
  360. package/dist/project/intent-analyzer.js +1 -149
  361. package/dist/project/machine-nodes.js +1 -36
  362. package/dist/project/merchant-guide.d.ts +19 -0
  363. package/dist/project/merchant-guide.js +1 -264
  364. package/dist/project/migration.js +1 -125
  365. package/dist/project/mode-actions.js +1 -309
  366. package/dist/project/namespace.js +1 -206
  367. package/dist/project/participation-radar.js +1 -428
  368. package/dist/project/pipeline-actions.js +1 -109
  369. package/dist/project/project-store.js +1 -422
  370. package/dist/project/query.js +1 -153
  371. package/dist/project/reverse-mapping.d.ts +34 -0
  372. package/dist/project/reverse-mapping.js +1 -0
  373. package/dist/project/risk-aggregator.js +1 -295
  374. package/dist/project/rollback-policy.js +1 -290
  375. package/dist/project/semantic-assembler.js +1 -345
  376. package/dist/project/semantic-graph.d.ts +3 -5
  377. package/dist/project/semantic-graph.js +1 -292
  378. package/dist/project/stage-gate.js +1 -369
  379. package/dist/project/substep-trace.js +1 -332
  380. package/dist/project/task-tracker.js +1 -78
  381. package/dist/project/workflow-design-assessment.d.ts +24 -0
  382. package/dist/project/workflow-design-assessment.js +1 -0
  383. package/dist/role/derivation.d.ts +18 -0
  384. package/dist/role/derivation.js +1 -0
  385. package/dist/role/index.d.ts +5 -0
  386. package/dist/role/index.js +1 -0
  387. package/dist/role/model.d.ts +8 -0
  388. package/dist/role/model.js +1 -0
  389. package/dist/role/resolution.d.ts +11 -0
  390. package/dist/role/resolution.js +1 -0
  391. package/dist/role/types.d.ts +11 -0
  392. package/dist/role/types.js +1 -0
  393. package/dist/rules.js +1 -52
  394. package/dist/safety/confirm-gate.d.ts +1 -1
  395. package/dist/safety/confirm-gate.js +1 -88
  396. package/dist/safety/index.js +1 -3
  397. package/dist/safety/preview.js +1 -52
  398. package/dist/schema/call/allocation.d.ts +186 -1385
  399. package/dist/schema/call/allocation.js +1 -34
  400. package/dist/schema/call/arbitration.d.ts +272 -1871
  401. package/dist/schema/call/arbitration.js +1 -113
  402. package/dist/schema/call/base.d.ts +1831 -9076
  403. package/dist/schema/call/base.js +1 -370
  404. package/dist/schema/call/bridge.d.ts +911 -3171
  405. package/dist/schema/call/bridge.js +1 -458
  406. package/dist/schema/call/contact.d.ts +135 -931
  407. package/dist/schema/call/contact.js +1 -37
  408. package/dist/schema/call/demand.d.ts +164 -1194
  409. package/dist/schema/call/demand.js +1 -47
  410. package/dist/schema/call/guard.d.ts +298 -1140
  411. package/dist/schema/call/guard.js +1 -161
  412. package/dist/schema/call/handler.js +1 -322
  413. package/dist/schema/call/index.js +1 -20
  414. package/dist/schema/call/machine.d.ts +459 -5403
  415. package/dist/schema/call/machine.js +1 -193
  416. package/dist/schema/call/order.d.ts +137 -844
  417. package/dist/schema/call/order.js +1 -35
  418. package/dist/schema/call/payment.d.ts +74 -561
  419. package/dist/schema/call/payment.js +1 -37
  420. package/dist/schema/call/permission-handler.js +1 -54
  421. package/dist/schema/call/permission.d.ts +335 -2791
  422. package/dist/schema/call/permission.js +1 -105
  423. package/dist/schema/call/personal.d.ts +227 -1814
  424. package/dist/schema/call/personal.js +1 -78
  425. package/dist/schema/call/progress.d.ts +140 -843
  426. package/dist/schema/call/progress.js +1 -47
  427. package/dist/schema/call/proof.d.ts +42 -258
  428. package/dist/schema/call/proof.js +1 -33
  429. package/dist/schema/call/repository.d.ts +324 -2222
  430. package/dist/schema/call/repository.js +1 -77
  431. package/dist/schema/call/reward.d.ts +153 -1183
  432. package/dist/schema/call/reward.js +1 -30
  433. package/dist/schema/call/semantic.js +1 -1679
  434. package/dist/schema/call/service.d.ts +376 -3431
  435. package/dist/schema/call/service.js +1 -184
  436. package/dist/schema/call/treasury.d.ts +252 -2158
  437. package/dist/schema/call/treasury.js +1 -71
  438. package/dist/schema/common/index.d.ts +222 -697
  439. package/dist/schema/common/index.js +1 -407
  440. package/dist/schema/config/index.d.ts +18 -161
  441. package/dist/schema/config/index.js +1 -68
  442. package/dist/schema/employee/index.d.ts +99 -0
  443. package/dist/schema/employee/index.js +1 -0
  444. package/dist/schema/evaluation/index.d.ts +1062 -3748
  445. package/dist/schema/evaluation/index.js +1 -356
  446. package/dist/schema/index.d.ts +3 -0
  447. package/dist/schema/index.js +1 -17
  448. package/dist/schema/industry-pack/index.d.ts +132 -0
  449. package/dist/schema/industry-pack/index.js +1 -0
  450. package/dist/schema/intent-radar/index.d.ts +92 -245
  451. package/dist/schema/intent-radar/index.js +1 -89
  452. package/dist/schema/local/index.d.ts +2045 -18080
  453. package/dist/schema/local/index.js +1 -927
  454. package/dist/schema/local/wip.d.ts +61 -651
  455. package/dist/schema/local/wip.js +1 -187
  456. package/dist/schema/messenger/index.d.ts +949 -5557
  457. package/dist/schema/messenger/index.js +1 -475
  458. package/dist/schema/operations.d.ts +2969 -26518
  459. package/dist/schema/operations.js +1 -520
  460. package/dist/schema/persona/index.d.ts +469 -1820
  461. package/dist/schema/persona/index.js +1 -148
  462. package/dist/schema/project/index.d.ts +1027 -8408
  463. package/dist/schema/project/index.js +1 -2057
  464. package/dist/schema/query/index.d.ts +12041 -75261
  465. package/dist/schema/query/index.js +1 -1646
  466. package/dist/schema/schema-query/index.d.ts +35 -98
  467. package/dist/schema/schema-query/index.js +1 -104
  468. package/dist/schema/schema-version.js +1 -76
  469. package/dist/schema/task-status.d.ts +26 -132
  470. package/dist/schema/task-status.js +1 -36
  471. package/dist/schema/trust/index.d.ts +194 -1290
  472. package/dist/schema/trust/index.js +1 -314
  473. package/dist/schema/utils/guard-parser.js +1 -419
  474. package/dist/schema/utils/guard-query-utils.js +1 -46
  475. package/dist/schema/utils/node-parser.js +1 -369
  476. package/dist/schema/utils/object-type-utils.js +1 -35
  477. package/dist/schema/utils/permission-index-utils.js +1 -7
  478. package/dist/schema/utils/permission-machine-check.js +1 -121
  479. package/dist/schema/utils/skills-recommendation.d.ts +1 -0
  480. package/dist/schema/utils/skills-recommendation.js +1 -77
  481. package/dist/schema/workspace/index.d.ts +69 -0
  482. package/dist/schema/workspace/index.js +1 -0
  483. package/dist/schema-query-impl/index.js +1 -0
  484. package/dist/schemas/account_operation.output.json +3147 -1652
  485. package/dist/schemas/account_operation.schema.json +225 -218
  486. package/dist/schemas/bridge_operation.output.json +1168 -650
  487. package/dist/schemas/bridge_operation.schema.json +736 -504
  488. package/dist/schemas/config_operation.output.json +185 -179
  489. package/dist/schemas/config_operation.schema.json +21 -26
  490. package/dist/schemas/employee_operation.output.json +207 -0
  491. package/dist/schemas/employee_operation.schema.json +176 -0
  492. package/dist/schemas/evaluation_operation.output.json +2329 -557
  493. package/dist/schemas/evaluation_operation.schema.json +2939 -720
  494. package/dist/schemas/guard2file.output.json +58 -64
  495. package/dist/schemas/guard2file.schema.json +79 -81
  496. package/dist/schemas/index.json +29 -11
  497. package/dist/schemas/industry_pack_operation.output.json +594 -0
  498. package/dist/schemas/industry_pack_operation.schema.json +55 -0
  499. package/dist/schemas/intent_radar.output.json +275 -200
  500. package/dist/schemas/intent_radar.schema.json +124 -123
  501. package/dist/schemas/local_info_operation.output.json +1174 -657
  502. package/dist/schemas/local_info_operation.schema.json +119 -125
  503. package/dist/schemas/local_mark_operation.output.json +1239 -689
  504. package/dist/schemas/local_mark_operation.schema.json +91 -96
  505. package/dist/schemas/machineNode2file.output.json +63 -69
  506. package/dist/schemas/machineNode2file.schema.json +79 -81
  507. package/dist/schemas/messenger_operation.output.json +2722 -1528
  508. package/dist/schemas/messenger_operation.schema.json +1482 -1264
  509. package/dist/schemas/onchain_events.output.json +2590 -975
  510. package/dist/schemas/onchain_events.schema.json +117 -99
  511. package/dist/schemas/onchain_operations.output.json +3957 -2309
  512. package/dist/schemas/onchain_operations.schema.json +20799 -9285
  513. package/dist/schemas/onchain_operations_allocation.schema.json +172 -108
  514. package/dist/schemas/onchain_operations_arbitration.schema.json +233 -146
  515. package/dist/schemas/onchain_operations_contact.schema.json +129 -90
  516. package/dist/schemas/onchain_operations_demand.schema.json +170 -112
  517. package/dist/schemas/onchain_operations_gen_passport.schema.json +61 -646
  518. package/dist/schemas/onchain_operations_gen_proof.schema.json +40 -172
  519. package/dist/schemas/onchain_operations_guard.schema.json +3765 -294
  520. package/dist/schemas/onchain_operations_machine.schema.json +537 -164
  521. package/dist/schemas/onchain_operations_order.schema.json +126 -96
  522. package/dist/schemas/onchain_operations_payment.schema.json +82 -67
  523. package/dist/schemas/onchain_operations_permission.schema.json +331 -93
  524. package/dist/schemas/onchain_operations_personal.schema.json +636 -96
  525. package/dist/schemas/onchain_operations_progress.schema.json +125 -92
  526. package/dist/schemas/onchain_operations_proof.schema.json +76 -69
  527. package/dist/schemas/onchain_operations_repository.schema.json +636 -249
  528. package/dist/schemas/onchain_operations_reward.schema.json +218 -108
  529. package/dist/schemas/onchain_operations_service.schema.json +679 -221
  530. package/dist/schemas/onchain_operations_treasury.schema.json +401 -135
  531. package/dist/schemas/onchain_table_data.output.json +6018 -2430
  532. package/dist/schemas/onchain_table_data.schema.json +544 -430
  533. package/dist/schemas/persona_operation.output.json +1568 -265
  534. package/dist/schemas/persona_operation.schema.json +346 -202
  535. package/dist/schemas/project_operation.output.json +6957 -5147
  536. package/dist/schemas/project_operation.schema.json +1050 -1020
  537. package/dist/schemas/query_task_status.output.json +195 -99
  538. package/dist/schemas/query_task_status.schema.json +12 -18
  539. package/dist/schemas/query_toolkit.output.json +18870 -14566
  540. package/dist/schemas/query_toolkit.schema.json +614 -522
  541. package/dist/schemas/schema_query.output.json +127 -129
  542. package/dist/schemas/schema_query.schema.json +64 -69
  543. package/dist/schemas/trust_score.output.json +678 -587
  544. package/dist/schemas/trust_score.schema.json +289 -277
  545. package/dist/schemas/wip_file.output.json +116 -124
  546. package/dist/schemas/wip_file.schema.json +142 -143
  547. package/dist/schemas/workspace_operation.output.json +277 -0
  548. package/dist/schemas/workspace_operation.schema.json +45 -0
  549. package/dist/schemas/wowok_buildin_info.output.json +1693 -723
  550. package/dist/schemas/wowok_buildin_info.schema.json +576 -512
  551. package/dist/telemetry/index.js +1 -112
  552. package/dist/telemetry/redact.js +1 -23
  553. package/dist/telemetry/storage.js +1 -80
  554. package/dist/tools/handlers/bridge.d.ts +8 -1
  555. package/dist/tools/handlers/bridge.js +1 -1
  556. package/dist/tools/handlers/config.js +1 -74
  557. package/dist/tools/handlers/employee.d.ts +2 -0
  558. package/dist/tools/handlers/employee.js +1 -0
  559. package/dist/tools/handlers/evaluation.js +1 -123
  560. package/dist/tools/handlers/file-export.js +1 -90
  561. package/dist/tools/handlers/industry-pack.d.ts +2 -0
  562. package/dist/tools/handlers/industry-pack.js +1 -0
  563. package/dist/tools/handlers/intent-radar.js +1 -76
  564. package/dist/tools/handlers/local.js +1 -53
  565. package/dist/tools/handlers/messenger.js +1 -188
  566. package/dist/tools/handlers/onchain.js +1 -1180
  567. package/dist/tools/handlers/persona.js +1 -89
  568. package/dist/tools/handlers/project.js +1 -211
  569. package/dist/tools/handlers/query.js +1 -434
  570. package/dist/tools/handlers/schema-query.js +1 -176
  571. package/dist/tools/handlers/task-status.js +1 -26
  572. package/dist/tools/handlers/trust.js +1 -380
  573. package/dist/tools/handlers/wip.js +1 -90
  574. package/dist/tools/handlers/workspace.d.ts +2 -0
  575. package/dist/tools/handlers/workspace.js +1 -0
  576. package/dist/tools/index.d.ts +2 -1
  577. package/dist/tools/index.js +1 -1382
  578. package/dist/tools/retry.js +1 -85
  579. package/dist/tools/rules-hook.d.ts +1 -1
  580. package/dist/tools/rules-hook.js +1 -23
  581. package/dist/tools/shared.d.ts +1 -1
  582. package/dist/tools/shared.js +1 -130
  583. package/dist/tools/types.d.ts +2 -1
  584. package/dist/tools/types.js +1 -1
  585. package/dist/tools/upgrade-check.d.ts +19 -0
  586. package/dist/tools/upgrade-check.js +1 -0
  587. package/dist/tools/wip-deploy-assist.js +1 -306
  588. package/dist/tools/wrap.js +1 -500
  589. package/package.json +7 -6
  590. package/dist/knowledge/arbitration-trust.d.ts +0 -24
  591. package/dist/knowledge/arbitration-trust.js +0 -117
  592. package/dist/schema/call/bridge-handler.d.ts +0 -8
  593. package/dist/schema/call/bridge-handler.js +0 -265
  594. package/dist/schema/sync-layer4.d.ts +0 -21
  595. package/dist/schema/sync-layer4.js +0 -286
  596. package/dist/schema-query/index.js +0 -810
  597. /package/dist/{schema-query → schema-query-impl}/index.d.ts +0 -0
@@ -1,573 +1 @@
1
- import { MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, } from "@wowok/wowok";
2
- import { assessOrderRisks, } from "./order-risk.js";
3
- export const ORDER_PUBLISH_CHECKLIST = [
4
- { id: "C-O-01", description: "Order object address is valid (must start with 0x, length >= 40)", passed: false, message: "" },
5
- { id: "C-O-02", description: "Operation is NOT direct order::create (Order created via service::buy)", passed: false, message: "" },
6
- { id: "C-O-03", description: `agent count <= MAX_AGENT_COUNT (${MAX_AGENT_COUNT}) — ⚠️ actual allows 11 due to <= bug`, passed: false, message: "" },
7
- { id: "C-O-04", description: `dispute count < MAX_DISPUTE_COUNT (${MAX_DISPUTE_COUNT}) — cannot file 11th dispute`, passed: false, message: "" },
8
- { id: "C-O-05", description: "claimed_by is None (no terminal claim state) — required for arb_confirm/arb_objection/arb_claim_compensation", passed: false, message: "" },
9
- { id: "C-O-06", description: "L1 operations (receive/transfer_to/agent_set) called by OWNER only", passed: false, message: "" },
10
- { id: "C-O-07", description: "L2 operations (required_info/progress/arb_*) called by owner OR agent", passed: false, message: "" },
11
- { id: "C-O-08", description: "agent_set / owner_change called BEFORE Progress binding (frozen after)", passed: false, message: "" },
12
- { id: "C-O-09", description: "receive called only when Progress is at terminal node (not delivering)", passed: false, message: "" },
13
- { id: "C-O-10", description: "transfer_to / arb_claim_compensation / arb_objection are IRREVERSIBLE — double-confirm", passed: false, message: "" },
14
- { id: "C-O-11", description: "required_info is Contact object OR WTS Proof object OR null (clear)", passed: false, message: "" },
15
- { id: "C-O-12", description: "Service is published AND not paused (for service::buy flow)", passed: false, message: "" },
16
- { id: "C-O-13", description: "Agent CANNOT receive payments — only owner can call receive", passed: false, message: "" },
17
- { id: "C-O-14", description: "arb_claim_compensation requires Arb in Arbitrated state", passed: false, message: "" },
18
- { id: "C-O-15", description: "Order has 14 fields — SDK uses 'builder' for Move's 'owner' (naming deviation)", passed: false, message: "" },
19
- ];
20
- function isValidAddress(addr) {
21
- return typeof addr === "string" && addr.startsWith("0x") && addr.length >= 40;
22
- }
23
- function runStaticChecklist(input) {
24
- const items = ORDER_PUBLISH_CHECKLIST.map(c => ({ ...c }));
25
- const data = input.order_json;
26
- const state = input.current_state ?? {};
27
- const caller = input.caller ?? {};
28
- const co01 = items.find(i => i.id === "C-O-01");
29
- if (!data.object) {
30
- co01.passed = false;
31
- co01.message = "Order object address is required (creation goes via service::buy, not here)";
32
- }
33
- else if (!isValidAddress(data.object)) {
34
- co01.passed = false;
35
- co01.message = `Invalid Order address: ${data.object}`;
36
- }
37
- else {
38
- co01.passed = true;
39
- }
40
- const co02 = items.find(i => i.id === "C-O-02");
41
- co02.passed = true;
42
- co02.message = "CallOrder_Data has no create op — Order creation goes via service::buy";
43
- const co03 = items.find(i => i.id === "C-O-03");
44
- if (data.agent) {
45
- const count = data.agent.length;
46
- const docValid = count <= MAX_AGENT_COUNT;
47
- co03.passed = docValid;
48
- co03.message = docValid
49
- ? (count === MAX_AGENT_COUNT ? `${count} agents (at doc limit; actual allows 11 due to bug)` : `${count} agents`)
50
- : `${count} agents > MAX_AGENT_COUNT (${MAX_AGENT_COUNT}) — will abort E_MAX_AGENT_COUNT (note: actual allows 11 due to <= bug)`;
51
- }
52
- else {
53
- co03.passed = true;
54
- }
55
- const co04 = items.find(i => i.id === "C-O-04");
56
- const disputeCount = state.dispute_count ?? 0;
57
- if (data.arb_confirm) {
58
- const valid = disputeCount < MAX_DISPUTE_COUNT;
59
- co04.passed = valid;
60
- co04.message = valid ? `${disputeCount} existing disputes` : `${disputeCount} disputes already at MAX_DISPUTE_COUNT (${MAX_DISPUTE_COUNT}) — next dispute() will abort E_MAX_DISPUTE_COUNT`;
61
- }
62
- else {
63
- co04.passed = true;
64
- }
65
- const co05 = items.find(i => i.id === "C-O-05");
66
- if (data.arb_confirm || data.arb_objection || data.arb_claim_compensation) {
67
- const valid = !state.claimed_by_set;
68
- co05.passed = valid;
69
- co05.message = valid ? "claimed_by is None — arb operations allowed" : "claimed_by is SET — arb operations blocked (E_ORDER_ALREADY_CLAIMED, IRREVERSIBLE)";
70
- }
71
- else {
72
- co05.passed = true;
73
- }
74
- const co06 = items.find(i => i.id === "C-O-06");
75
- const isL1Op = !!(data.receive || data.transfer_to || data.agent);
76
- if (isL1Op) {
77
- const valid = !!caller.is_owner;
78
- co06.passed = valid;
79
- co06.message = valid ? "Caller is owner — L1 allowed" : "Caller is NOT owner — L1 operation blocked (E_OWNER)";
80
- }
81
- else {
82
- co06.passed = true;
83
- }
84
- const co07 = items.find(i => i.id === "C-O-07");
85
- const isL2Op = !!(data.required_info !== undefined || data.progress || data.arb_confirm || data.arb_objection || data.arb_claim_compensation);
86
- if (isL2Op) {
87
- const valid = !!caller.is_owner || !!caller.is_agent;
88
- co07.passed = valid;
89
- co07.message = valid ? "Caller is owner or agent — L2 allowed" : "Caller is NEITHER owner NOR agent — L2 blocked (E_PERMISSION)";
90
- }
91
- else {
92
- co07.passed = true;
93
- }
94
- const co08 = items.find(i => i.id === "C-O-08");
95
- if (data.agent || (data.transfer_to && !state.progress_bound)) {
96
- if (data.agent) {
97
- const valid = !state.progress_bound;
98
- co08.passed = valid;
99
- co08.message = valid ? "Progress not bound — agent_set allowed" : "Progress BOUND — agent_set aborts E_PROGRESS_NOT_SPECIFIED (frozen)";
100
- }
101
- else {
102
- co08.passed = true;
103
- }
104
- }
105
- else {
106
- co08.passed = true;
107
- }
108
- const co09 = items.find(i => i.id === "C-O-09");
109
- if (data.receive) {
110
- const valid = !!state.progress_at_terminal;
111
- co09.passed = valid;
112
- co09.message = valid ? "Progress at terminal — receive allowed" : "Progress NOT at terminal — receive aborts E_ORDER_DELIVERING";
113
- }
114
- else {
115
- co09.passed = true;
116
- }
117
- const co10 = items.find(i => i.id === "C-O-10");
118
- const isIrreversible = !!(data.transfer_to || data.arb_claim_compensation || data.arb_objection);
119
- if (isIrreversible) {
120
- co10.passed = false;
121
- co10.message = "Pending user confirmation in Layer 3 (irreversible operation)";
122
- }
123
- else {
124
- co10.passed = true;
125
- }
126
- const co11 = items.find(i => i.id === "C-O-11");
127
- if (data.required_info !== undefined) {
128
- const valid = data.required_info === null || isValidAddress(data.required_info);
129
- co11.passed = valid;
130
- co11.message = valid
131
- ? (data.required_info === null ? "required_info = null (clear)" : "required_info is valid address (Contact or WTS Proof)")
132
- : `Invalid required_info: ${data.required_info}`;
133
- }
134
- else {
135
- co11.passed = true;
136
- }
137
- const co12 = items.find(i => i.id === "C-O-12");
138
- co12.passed = true;
139
- co12.message = "Service check applies only to service::buy flow (not CallOrder_Data)";
140
- const co13 = items.find(i => i.id === "C-O-13");
141
- if (data.receive && caller.is_agent && !caller.is_owner) {
142
- co13.passed = false;
143
- co13.message = "Agent CANNOT receive payments — only owner can call receive (L1)";
144
- }
145
- else {
146
- co13.passed = true;
147
- }
148
- const co14 = items.find(i => i.id === "C-O-14");
149
- if (data.arb_claim_compensation) {
150
- co14.passed = true;
151
- co14.message = "Arb Arbitrated state verified in Layer 4 (Environment)";
152
- }
153
- else {
154
- co14.passed = true;
155
- }
156
- const co15 = items.find(i => i.id === "C-O-15");
157
- co15.passed = true;
158
- co15.message = "Informational: SDK ObjectOrder.builder ↔ Move Order.owner (only naming deviation in 22 objects)";
159
- return {
160
- all_passed: items.filter(i => i.id !== "C-O-10").every(i => i.passed),
161
- items,
162
- };
163
- }
164
- function adaptRiskAssessment(input) {
165
- const data = input.order_json;
166
- const state = input.current_state ?? {};
167
- const caller = input.caller ?? {};
168
- let operation;
169
- if (data.agent)
170
- operation = "agent_set";
171
- else if (data.required_info !== undefined)
172
- operation = "required_info_update";
173
- else if (data.progress)
174
- operation = "progress_advance";
175
- else if (data.arb_confirm)
176
- operation = "arb_confirm";
177
- else if (data.arb_objection)
178
- operation = "arb_objection";
179
- else if (data.arb_claim_compensation)
180
- operation = "arb_claim_compensation";
181
- else if (data.receive)
182
- operation = "receive";
183
- else if (data.transfer_to)
184
- operation = "transfer_to";
185
- const ctx = {
186
- object: data.object,
187
- operation,
188
- is_buy_operation: false,
189
- agent_set: data.agent ? { agents: data.agent } : undefined,
190
- current_dispute_count: state.dispute_count,
191
- claimed_by_set: state.claimed_by_set,
192
- progress_bound: state.progress_bound,
193
- progress_at_terminal: state.progress_at_terminal,
194
- service_published: state.service_published,
195
- service_paused: state.service_paused,
196
- current_service_machine: state.current_service_machine,
197
- order_machine_snapshot: state.order_machine_snapshot,
198
- transfer_to_new_owner: data.transfer_to,
199
- caller_is_owner: caller.is_owner,
200
- caller_is_agent: caller.is_agent,
201
- };
202
- return assessOrderRisks(ctx);
203
- }
204
- export const ORDER_CONFIRMATION_QUESTIONS = [
205
- {
206
- id: "QO1",
207
- question: "Is the Order object address correct? Verify it matches the intended Order (check on explorer).",
208
- requires_explicit_yes: true,
209
- },
210
- {
211
- id: "QO2",
212
- question: "If setting agent list: are all agent addresses trusted parties? Agents can advance Progress and file arbitration but CANNOT receive payments.",
213
- requires_explicit_yes: true,
214
- related_risk_ids: ["R-O-3-01"],
215
- },
216
- {
217
- id: "QO3",
218
- question: "If filing arbitration (arb_confirm): have you attached all evidence? This operation is IRREVERSIBLE — once filed, the Arb process cannot be cancelled.",
219
- requires_explicit_yes: true,
220
- related_risk_ids: ["R-O-4-04"],
221
- },
222
- {
223
- id: "QO4",
224
- question: "⚠️⚠️ If claiming compensation (arb_claim_compensation): do you confirm this is the FINAL Arb ruling? After claim, claimed_by is set IRREVERSIBLY — NO new disputes can ever be filed.",
225
- requires_explicit_yes: true,
226
- related_risk_ids: ["R-O-3-03", "R-O-4-04"],
227
- },
228
- {
229
- id: "QO5",
230
- question: "⚠️⚠️ If transferring ownership (transfer_to): do you confirm the new owner address is correct? This is IRREVERSIBLE — new owner takes over ALL permissions including payment receipt.",
231
- requires_explicit_yes: true,
232
- related_risk_ids: ["R-O-4-06"],
233
- },
234
- {
235
- id: "QO6",
236
- question: "If advancing Progress: are you sure about the target node? Node transitions are IRREVERSIBLE — no backward movement is possible.",
237
- requires_explicit_yes: true,
238
- related_risk_ids: ["R-O-4-03"],
239
- },
240
- {
241
- id: "QO7",
242
- question: "If receiving payment: have you verified the receiving object ID and the amount? Funds are forwarded to the owner address immediately.",
243
- requires_explicit_yes: false,
244
- },
245
- {
246
- id: "QO8",
247
- question: "Have you exported the current Order state as a backup before this operation? (Recommended for irreversible ops.)",
248
- requires_explicit_yes: false,
249
- },
250
- ];
251
- function processUserConfirmation(input, assessment) {
252
- const data = input.order_json;
253
- let questions = [...ORDER_CONFIRMATION_QUESTIONS];
254
- if (!data.agent)
255
- questions = questions.filter(q => q.id !== "QO2");
256
- if (!data.arb_confirm)
257
- questions = questions.filter(q => q.id !== "QO3");
258
- if (!data.arb_claim_compensation)
259
- questions = questions.filter(q => q.id !== "QO4");
260
- if (!data.transfer_to)
261
- questions = questions.filter(q => q.id !== "QO5");
262
- if (!data.progress)
263
- questions = questions.filter(q => q.id !== "QO6");
264
- if (!data.receive)
265
- questions = questions.filter(q => q.id !== "QO7");
266
- if (input.skip_user_confirmation) {
267
- return {
268
- questions_asked: questions,
269
- responses: questions.map(q => ({ question_id: q.id, response: "yes" })),
270
- all_confirmed: true,
271
- };
272
- }
273
- return {
274
- questions_asked: questions,
275
- responses: [],
276
- all_confirmed: false,
277
- };
278
- }
279
- function verifyEnvironment(input) {
280
- const checks = [];
281
- const data = input.order_json;
282
- const state = input.current_state ?? {};
283
- const caller = input.caller ?? {};
284
- if (data.object) {
285
- checks.push({
286
- name: "order_exists",
287
- passed: true,
288
- message: `Order ${data.object} assumed to exist (verify via explorer)`,
289
- });
290
- }
291
- const isL1Op = !!(data.receive || data.transfer_to || data.agent);
292
- const isL2Op = !!(data.required_info !== undefined || data.progress || data.arb_confirm || data.arb_objection || data.arb_claim_compensation);
293
- if (isL1Op) {
294
- checks.push({
295
- name: "signer_is_owner",
296
- passed: !!caller.is_owner,
297
- message: caller.is_owner
298
- ? "Signer is owner — L1 allowed"
299
- : "Signer is NOT owner — L1 operation will abort E_OWNER",
300
- });
301
- }
302
- else if (isL2Op) {
303
- const hasPerm = !!caller.is_owner || !!caller.is_agent;
304
- checks.push({
305
- name: "signer_is_owner_or_agent",
306
- passed: hasPerm,
307
- message: hasPerm
308
- ? `Signer is ${caller.is_owner ? "owner" : "agent"} — L2 allowed`
309
- : "Signer is NEITHER owner NOR agent — L2 will abort E_PERMISSION",
310
- });
311
- }
312
- if (data.arb_confirm || data.arb_objection || data.arb_claim_compensation) {
313
- checks.push({
314
- name: "claimed_by_is_none",
315
- passed: !state.claimed_by_set,
316
- message: state.claimed_by_set
317
- ? "claimed_by is SET — arb operations blocked (E_ORDER_ALREADY_CLAIMED, IRREVERSIBLE)"
318
- : "claimed_by is None — arb operations allowed",
319
- });
320
- }
321
- if (data.receive) {
322
- checks.push({
323
- name: "progress_at_terminal",
324
- passed: !!state.progress_at_terminal,
325
- message: state.progress_at_terminal
326
- ? "Progress at terminal — receive allowed"
327
- : "Progress NOT at terminal — receive aborts E_ORDER_DELIVERING",
328
- });
329
- }
330
- if (data.agent) {
331
- checks.push({
332
- name: "progress_not_bound",
333
- passed: !state.progress_bound,
334
- message: state.progress_bound
335
- ? "Progress BOUND — agent_set aborts E_PROGRESS_NOT_SPECIFIED (frozen)"
336
- : "Progress not bound — agent_set allowed",
337
- });
338
- }
339
- if (data.arb_confirm) {
340
- const count = state.dispute_count ?? 0;
341
- const valid = count < MAX_DISPUTE_COUNT;
342
- checks.push({
343
- name: "dispute_count_below_max",
344
- passed: valid,
345
- message: valid
346
- ? `${count} disputes (< MAX_DISPUTE_COUNT ${MAX_DISPUTE_COUNT})`
347
- : `${count} disputes at MAX_DISPUTE_COUNT — next dispute() aborts E_MAX_DISPUTE_COUNT`,
348
- });
349
- }
350
- if (state.service_published === false) {
351
- checks.push({
352
- name: "service_published",
353
- passed: false,
354
- message: "Service is NOT published — service::buy will fail",
355
- });
356
- }
357
- if (state.service_paused === true) {
358
- checks.push({
359
- name: "service_not_paused",
360
- passed: false,
361
- message: "Service is PAUSED — service::buy will fail",
362
- });
363
- }
364
- const allPassed = checks.every(c => c.passed);
365
- return { passed: allPassed, checks };
366
- }
367
- export const ORDER_CONFIRM_VERSION = "1.0.0";
368
- export function runOrderConfirmGate(input) {
369
- const layersPassed = [];
370
- const layersFailed = [];
371
- const checklist = runStaticChecklist(input);
372
- if (!checklist.all_passed) {
373
- layersFailed.push("L1_checklist");
374
- return {
375
- status: "blocked_checklist",
376
- checklist_result: checklist,
377
- confirmation_text: generateConfirmationText(input, checklist),
378
- block_reason: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
379
- decision_record: {
380
- timestamp: new Date().toISOString(),
381
- gate_version: ORDER_CONFIRM_VERSION,
382
- final_status: "blocked_checklist",
383
- layers_passed: layersPassed,
384
- layers_failed: layersFailed,
385
- },
386
- };
387
- }
388
- layersPassed.push("L1_checklist");
389
- const assessment = adaptRiskAssessment(input);
390
- const hasCritical = assessment.risks.some(r => r.level === "CRITICAL");
391
- if (hasCritical) {
392
- layersFailed.push("L2_risk");
393
- return {
394
- status: "blocked_risk",
395
- checklist_result: checklist,
396
- risk_result: assessment,
397
- confirmation_text: generateConfirmationText(input, checklist, assessment),
398
- block_reason: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
399
- decision_record: {
400
- timestamp: new Date().toISOString(),
401
- gate_version: ORDER_CONFIRM_VERSION,
402
- final_status: "blocked_risk",
403
- layers_passed: layersPassed,
404
- layers_failed: layersFailed,
405
- },
406
- };
407
- }
408
- layersPassed.push("L2_risk");
409
- const userConf = processUserConfirmation(input, assessment);
410
- if (!userConf.all_confirmed) {
411
- const isIrreversible = !!(input.order_json.transfer_to || input.order_json.arb_claim_compensation || input.order_json.arb_objection);
412
- if (isIrreversible) {
413
- const co10 = checklist.items.find(i => i.id === "C-O-10");
414
- if (co10) {
415
- const relevantQIds = [];
416
- if (input.order_json.transfer_to)
417
- relevantQIds.push("QO5");
418
- if (input.order_json.arb_claim_compensation)
419
- relevantQIds.push("QO4");
420
- if (input.order_json.arb_objection)
421
- relevantQIds.push("QO3");
422
- const confirmed = relevantQIds.every(qid => {
423
- const r = userConf.responses.find(r => r.question_id === qid);
424
- return r?.response === "yes";
425
- });
426
- co10.passed = confirmed;
427
- co10.message = confirmed ? "" : "Irreversible operation not confirmed by user";
428
- }
429
- }
430
- if (isIrreversible) {
431
- const co10 = checklist.items.find(i => i.id === "C-O-10");
432
- if (co10 && !co10.passed) {
433
- layersFailed.push("L3_user");
434
- return {
435
- status: "blocked_user",
436
- checklist_result: checklist,
437
- risk_result: assessment,
438
- user_confirmation: userConf,
439
- confirmation_text: generateConfirmationText(input, checklist, assessment),
440
- block_reason: "User did not confirm irreversible operation",
441
- decision_record: {
442
- timestamp: new Date().toISOString(),
443
- gate_version: ORDER_CONFIRM_VERSION,
444
- final_status: "blocked_user",
445
- layers_passed: layersPassed,
446
- layers_failed: layersFailed,
447
- },
448
- };
449
- }
450
- }
451
- }
452
- layersPassed.push("L3_user");
453
- if (input.skip_environment_check) {
454
- layersPassed.push("L4_environment");
455
- }
456
- else {
457
- const env = verifyEnvironment(input);
458
- if (!env.passed) {
459
- layersFailed.push("L4_environment");
460
- return {
461
- status: "blocked_environment",
462
- checklist_result: checklist,
463
- risk_result: assessment,
464
- user_confirmation: userConf,
465
- environment_result: env,
466
- confirmation_text: generateConfirmationText(input, checklist, assessment),
467
- block_reason: `Environment check failed: ${env.checks.filter(c => !c.passed).map(c => c.name).join(", ")}`,
468
- decision_record: {
469
- timestamp: new Date().toISOString(),
470
- gate_version: ORDER_CONFIRM_VERSION,
471
- final_status: "blocked_environment",
472
- layers_passed: layersPassed,
473
- layers_failed: layersFailed,
474
- },
475
- };
476
- }
477
- layersPassed.push("L4_environment");
478
- }
479
- return {
480
- status: "approved",
481
- checklist_result: checklist,
482
- risk_result: assessment,
483
- user_confirmation: userConf,
484
- confirmation_text: generateConfirmationText(input, checklist, assessment),
485
- decision_record: {
486
- timestamp: new Date().toISOString(),
487
- gate_version: ORDER_CONFIRM_VERSION,
488
- final_status: "approved",
489
- layers_passed: layersPassed,
490
- layers_failed: layersFailed,
491
- },
492
- };
493
- }
494
- function generateConfirmationText(input, checklist, assessment) {
495
- const lines = [];
496
- const data = input.order_json;
497
- lines.push("═══ Order Confirmation ═══");
498
- lines.push("");
499
- if (data.object) {
500
- lines.push(`Order: ${data.object}`);
501
- }
502
- else {
503
- lines.push("Order: (no address — invalid for CallOrder_Data)");
504
- }
505
- lines.push("");
506
- lines.push("─ Operations ──────────────────");
507
- if (data.agent)
508
- lines.push(`- ⚠️ Set agent list: ${data.agent.length} agent(s) [L1, owner-only, frozen after progress]`);
509
- if (data.required_info !== undefined)
510
- lines.push(`- required_info: ${data.required_info === null ? "(clear)" : data.required_info} [L2]`);
511
- if (data.progress)
512
- lines.push(`- Advance Progress: ${data.progress.next_node_name ?? "?"} [L2, irreversible]`);
513
- if (data.arb_confirm)
514
- lines.push(`- ⚠️ File arbitration: ${data.arb_confirm.arb} [L2, irreversible]`);
515
- if (data.arb_objection)
516
- lines.push(`- ⚠️ Object to Arb: ${data.arb_objection.arb} [L2, irreversible]`);
517
- if (data.arb_claim_compensation)
518
- lines.push(`- ⚠️⚠️ Claim compensation: ${data.arb_claim_compensation.arb} [L2, ONE-TIME, IRREVERSIBLE]`);
519
- if (data.receive)
520
- lines.push(`- Receive: ${data.receive.received} [L1, owner-only]`);
521
- if (data.transfer_to)
522
- lines.push(`- ⚠️⚠️ Transfer ownership to: ${data.transfer_to} [L1, IRREVERSIBLE]`);
523
- lines.push("");
524
- lines.push("─ Checklist ──────────────────");
525
- for (const item of checklist.items) {
526
- const mark = item.passed ? "✓" : "✗";
527
- lines.push(` ${mark} ${item.id}: ${item.description}${item.message ? " — " + item.message : ""}`);
528
- }
529
- lines.push("");
530
- if (assessment) {
531
- lines.push("─ Risk Assessment ──────────────────");
532
- lines.push(`Overall: ${assessment.overall_risk}`);
533
- lines.push(`Detected: ${assessment.risks.length} risk(s)`);
534
- for (const r of assessment.risks) {
535
- lines.push(` [${r.level}] ${r.id}: ${r.title}`);
536
- }
537
- lines.push("");
538
- }
539
- return lines.join("\n");
540
- }
541
- export function progressiveOrderCheck(input) {
542
- const checklist = runStaticChecklist(input);
543
- if (!checklist.all_passed) {
544
- return {
545
- stage: "checklist",
546
- status: "fail",
547
- message: `Checklist failed: ${checklist.items.filter(i => !i.passed).map(i => i.id).join(", ")}`,
548
- next_action: "Fix failing checklist items",
549
- };
550
- }
551
- const assessment = adaptRiskAssessment(input);
552
- if (assessment.risks.some(r => r.level === "CRITICAL")) {
553
- return {
554
- stage: "risk",
555
- status: "fail",
556
- message: `CRITICAL risks: ${assessment.risks.filter(r => r.level === "CRITICAL").map(r => r.id).join(", ")}`,
557
- next_action: "Resolve CRITICAL risks before proceeding",
558
- };
559
- }
560
- if (assessment.needs_human_review) {
561
- return {
562
- stage: "confirmation",
563
- status: "pending",
564
- message: "Human review required for HIGH risks",
565
- next_action: "Confirm risk acceptance",
566
- };
567
- }
568
- return {
569
- stage: "complete",
570
- status: "pass",
571
- message: "All checks passed",
572
- };
573
- }
1
+ import{MAX_AGENT_COUNT,MAX_DISPUTE_COUNT}from'@wowok/wowok';import{assessOrderRisks}from'./order-risk.js';export const ORDER_PUBLISH_CHECKLIST=[{'id':'C-O-01','description':'Order\x20object\x20address\x20is\x20valid\x20(must\x20start\x20with\x200x,\x20length\x20>=\x2040)','passed':![],'message':''},{'id':'C-O-02','description':'Operation\x20is\x20NOT\x20direct\x20order::create\x20(Order\x20created\x20via\x20service::buy)','passed':![],'message':''},{'id':'C-O-03','description':'agent\x20count\x20<=\x20MAX_AGENT_COUNT\x20('+MAX_AGENT_COUNT+')\x20—\x20⚠️\x20actual\x20allows\x2011\x20due\x20to\x20<=\x20bug','passed':![],'message':''},{'id':'C-O-04','description':'dispute\x20count\x20<\x20MAX_DISPUTE_COUNT\x20('+MAX_DISPUTE_COUNT+')\x20—\x20cannot\x20file\x2011th\x20dispute','passed':![],'message':''},{'id':'C-O-05','description':'claimed_by\x20is\x20None\x20(no\x20terminal\x20claim\x20state)\x20—\x20required\x20for\x20arb_confirm/arb_objection/arb_claim_compensation','passed':![],'message':''},{'id':'C-O-06','description':'L1\x20operations\x20(receive/transfer_to/agent_set)\x20called\x20by\x20OWNER\x20only','passed':![],'message':''},{'id':'C-O-07','description':'L2\x20operations\x20(required_info/progress/arb_*)\x20called\x20by\x20owner\x20OR\x20agent','passed':![],'message':''},{'id':'C-O-08','description':'agent_set\x20/\x20owner_change\x20called\x20BEFORE\x20Progress\x20binding\x20(frozen\x20after)','passed':![],'message':''},{'id':'C-O-09','description':'receive\x20called\x20only\x20when\x20Progress\x20is\x20at\x20terminal\x20node\x20(not\x20delivering)','passed':![],'message':''},{'id':'C-O-10','description':'transfer_to\x20/\x20arb_claim_compensation\x20/\x20arb_objection\x20are\x20IRREVERSIBLE\x20—\x20double-confirm','passed':![],'message':''},{'id':'C-O-11','description':'required_info\x20is\x20Contact\x20object\x20OR\x20WTS\x20Proof\x20object\x20OR\x20null\x20(clear)','passed':![],'message':''},{'id':'C-O-12','description':'Service\x20is\x20published\x20AND\x20not\x20paused\x20(for\x20service::buy\x20flow)','passed':![],'message':''},{'id':'C-O-13','description':'Agent\x20CANNOT\x20receive\x20payments\x20—\x20only\x20owner\x20can\x20call\x20receive','passed':![],'message':''},{'id':'C-O-14','description':'arb_claim_compensation\x20requires\x20Arb\x20in\x20Arbitrated\x20state','passed':![],'message':''},{'id':'C-O-15','description':'Order\x20has\x2014\x20fields\x20—\x20SDK\x20uses\x20\x27builder\x27\x20for\x20Move\x27s\x20\x27owner\x27\x20(naming\x20deviation)','passed':![],'message':''}];function isValidAddress(a){return typeof a==='string'&&a['startsWith']('0x')&&a['length']>=0x28;}function runStaticChecklist(a){const b=ORDER_PUBLISH_CHECKLIST['map'](y=>({...y})),c=a['order_json'],d=a['current_state']??{},e=a['caller']??{},f=b['find'](y=>y['id']==='C-O-01');if(!c['object'])f['passed']=![],f['message']='Order\x20object\x20address\x20is\x20required\x20(creation\x20goes\x20via\x20service::buy,\x20not\x20here)';else!isValidAddress(c['object'])?(f['passed']=![],f['message']='Invalid\x20Order\x20address:\x20'+c['object']):f['passed']=!![];const g=b['find'](y=>y['id']==='C-O-02');g['passed']=!![],g['message']='CallOrder_Data\x20has\x20no\x20create\x20op\x20—\x20Order\x20creation\x20goes\x20via\x20service::buy';const h=b['find'](y=>y['id']==='C-O-03');if(c['agent']){const y=c['agent']['length'],z=y<=MAX_AGENT_COUNT;h['passed']=z,h['message']=z?y===MAX_AGENT_COUNT?y+'\x20agents\x20(at\x20doc\x20limit;\x20actual\x20allows\x2011\x20due\x20to\x20bug)':y+'\x20agents':y+'\x20agents\x20>\x20MAX_AGENT_COUNT\x20('+MAX_AGENT_COUNT+')\x20—\x20will\x20abort\x20E_MAX_AGENT_COUNT\x20(note:\x20actual\x20allows\x2011\x20due\x20to\x20<=\x20bug)';}else h['passed']=!![];const i=b['find'](A=>A['id']==='C-O-04'),j=d['dispute_count']??0x0;if(c['arb_confirm']){const A=j<MAX_DISPUTE_COUNT;i['passed']=A,i['message']=A?j+'\x20existing\x20disputes':j+'\x20disputes\x20already\x20at\x20MAX_DISPUTE_COUNT\x20('+MAX_DISPUTE_COUNT+')\x20—\x20next\x20dispute()\x20will\x20abort\x20E_MAX_DISPUTE_COUNT';}else i['passed']=!![];const k=b['find'](B=>B['id']==='C-O-05');if(c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation']){const B=!d['claimed_by_set'];k['passed']=B,k['message']=B?'claimed_by\x20is\x20None\x20—\x20arb\x20operations\x20allowed':'claimed_by\x20is\x20SET\x20—\x20arb\x20operations\x20blocked\x20(E_ORDER_ALREADY_CLAIMED,\x20IRREVERSIBLE)';}else k['passed']=!![];const l=b['find'](C=>C['id']==='C-O-06'),m=!!(c['receive']||c['transfer_to']||c['agent']);if(m){const C=!!e['is_owner'];l['passed']=C,l['message']=C?'Caller\x20is\x20owner\x20—\x20L1\x20allowed':'Caller\x20is\x20NOT\x20owner\x20—\x20L1\x20operation\x20blocked\x20(E_OWNER)';}else l['passed']=!![];const n=b['find'](D=>D['id']==='C-O-07'),o=!!(c['required_info']!==undefined||c['progress']||c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation']);if(o){const D=!!e['is_owner']||!!e['is_agent'];n['passed']=D,n['message']=D?'Caller\x20is\x20owner\x20or\x20agent\x20—\x20L2\x20allowed':'Caller\x20is\x20NEITHER\x20owner\x20NOR\x20agent\x20—\x20L2\x20blocked\x20(E_PERMISSION)';}else n['passed']=!![];const p=b['find'](E=>E['id']==='C-O-08');if(c['agent']||c['transfer_to']&&!d['progress_bound']){if(c['agent']){const E=!d['progress_bound'];p['passed']=E,p['message']=E?'Progress\x20not\x20bound\x20—\x20agent_set\x20allowed':'Progress\x20BOUND\x20—\x20agent_set\x20aborts\x20E_PROGRESS_NOT_SPECIFIED\x20(frozen)';}else p['passed']=!![];}else p['passed']=!![];const q=b['find'](F=>F['id']==='C-O-09');if(c['receive']){const F=!!d['progress_at_terminal'];q['passed']=F,q['message']=F?'Progress\x20at\x20terminal\x20—\x20receive\x20allowed':'Progress\x20NOT\x20at\x20terminal\x20—\x20receive\x20aborts\x20E_ORDER_DELIVERING';}else q['passed']=!![];const r=b['find'](G=>G['id']==='C-O-10'),s=!!(c['transfer_to']||c['arb_claim_compensation']||c['arb_objection']);s?(r['passed']=![],r['message']='Pending\x20user\x20confirmation\x20in\x20Layer\x203\x20(irreversible\x20operation)'):r['passed']=!![];const t=b['find'](G=>G['id']==='C-O-11');if(c['required_info']!==undefined){const G=c['required_info']===null||isValidAddress(c['required_info']);t['passed']=G,t['message']=G?c['required_info']===null?'required_info\x20=\x20null\x20(clear)':'required_info\x20is\x20valid\x20address\x20(Contact\x20or\x20WTS\x20Proof)':'Invalid\x20required_info:\x20'+c['required_info'];}else t['passed']=!![];const u=b['find'](H=>H['id']==='C-O-12');u['passed']=!![],u['message']='Service\x20check\x20applies\x20only\x20to\x20service::buy\x20flow\x20(not\x20CallOrder_Data)';const v=b['find'](H=>H['id']==='C-O-13');c['receive']&&e['is_agent']&&!e['is_owner']?(v['passed']=![],v['message']='Agent\x20CANNOT\x20receive\x20payments\x20—\x20only\x20owner\x20can\x20call\x20receive\x20(L1)'):v['passed']=!![];const w=b['find'](H=>H['id']==='C-O-14');c['arb_claim_compensation']?(w['passed']=!![],w['message']='Arb\x20Arbitrated\x20state\x20verified\x20in\x20Layer\x204\x20(Environment)'):w['passed']=!![];const x=b['find'](H=>H['id']==='C-O-15');return x['passed']=!![],x['message']='Informational:\x20SDK\x20ObjectOrder.builder\x20↔\x20Move\x20Order.owner\x20(only\x20naming\x20deviation\x20in\x2022\x20objects)',{'all_passed':b['filter'](H=>H['id']!=='C-O-10')['every'](H=>H['passed']),'items':b};}function adaptRiskAssessment(a){const b=a['order_json'],c=a['current_state']??{},d=a['caller']??{};let e;if(b['agent'])e='agent_set';else{if(b['required_info']!==undefined)e='required_info_update';else{if(b['progress'])e='progress_advance';else{if(b['arb_confirm'])e='arb_confirm';else{if(b['arb_objection'])e='arb_objection';else{if(b['arb_claim_compensation'])e='arb_claim_compensation';else{if(b['receive'])e='receive';else{if(b['transfer_to'])e='transfer_to';}}}}}}}const f={'object':b['object'],'operation':e,'is_buy_operation':![],'agent_set':b['agent']?{'agents':b['agent']}:undefined,'current_dispute_count':c['dispute_count'],'claimed_by_set':c['claimed_by_set'],'progress_bound':c['progress_bound'],'progress_at_terminal':c['progress_at_terminal'],'service_published':c['service_published'],'service_paused':c['service_paused'],'current_service_machine':c['current_service_machine'],'order_machine_snapshot':c['order_machine_snapshot'],'transfer_to_new_owner':b['transfer_to'],'caller_is_owner':d['is_owner'],'caller_is_agent':d['is_agent']};return assessOrderRisks(f);}export const ORDER_CONFIRMATION_QUESTIONS=[{'id':'QO1','question':'Is\x20the\x20Order\x20object\x20address\x20correct?\x20Verify\x20it\x20matches\x20the\x20intended\x20Order\x20(check\x20on\x20explorer).','requires_explicit_yes':!![]},{'id':'QO2','question':'If\x20setting\x20agent\x20list:\x20are\x20all\x20agent\x20addresses\x20trusted\x20parties?\x20Agents\x20can\x20advance\x20Progress\x20and\x20file\x20arbitration\x20but\x20CANNOT\x20receive\x20payments.','requires_explicit_yes':!![],'related_risk_ids':['R-O-3-01']},{'id':'QO3','question':'If\x20filing\x20arbitration\x20(arb_confirm):\x20have\x20you\x20attached\x20all\x20evidence?\x20This\x20operation\x20is\x20IRREVERSIBLE\x20—\x20once\x20filed,\x20the\x20Arb\x20process\x20cannot\x20be\x20cancelled.','requires_explicit_yes':!![],'related_risk_ids':['R-O-4-04']},{'id':'QO4','question':'⚠️⚠️\x20If\x20claiming\x20compensation\x20(arb_claim_compensation):\x20do\x20you\x20confirm\x20this\x20is\x20the\x20FINAL\x20Arb\x20ruling?\x20After\x20claim,\x20claimed_by\x20is\x20set\x20IRREVERSIBLY\x20—\x20NO\x20new\x20disputes\x20can\x20ever\x20be\x20filed.','requires_explicit_yes':!![],'related_risk_ids':['R-O-3-03','R-O-4-04']},{'id':'QO5','question':'⚠️⚠️\x20If\x20transferring\x20ownership\x20(transfer_to):\x20do\x20you\x20confirm\x20the\x20new\x20owner\x20address\x20is\x20correct?\x20This\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20takes\x20over\x20ALL\x20permissions\x20including\x20payment\x20receipt.','requires_explicit_yes':!![],'related_risk_ids':['R-O-4-06']},{'id':'QO6','question':'If\x20advancing\x20Progress:\x20are\x20you\x20sure\x20about\x20the\x20target\x20node?\x20Node\x20transitions\x20are\x20IRREVERSIBLE\x20—\x20no\x20backward\x20movement\x20is\x20possible.','requires_explicit_yes':!![],'related_risk_ids':['R-O-4-03']},{'id':'QO7','question':'If\x20receiving\x20payment:\x20have\x20you\x20verified\x20the\x20receiving\x20object\x20ID\x20and\x20the\x20amount?\x20Funds\x20are\x20forwarded\x20to\x20the\x20owner\x20address\x20immediately.','requires_explicit_yes':![]},{'id':'QO8','question':'Have\x20you\x20exported\x20the\x20current\x20Order\x20state\x20as\x20a\x20backup\x20before\x20this\x20operation?\x20(Recommended\x20for\x20irreversible\x20ops.)','requires_explicit_yes':![]}];function processUserConfirmation(a,b){const c=a['order_json'];let d=[...ORDER_CONFIRMATION_QUESTIONS];if(!c['agent'])d=d['filter'](e=>e['id']!=='QO2');if(!c['arb_confirm'])d=d['filter'](e=>e['id']!=='QO3');if(!c['arb_claim_compensation'])d=d['filter'](e=>e['id']!=='QO4');if(!c['transfer_to'])d=d['filter'](e=>e['id']!=='QO5');if(!c['progress'])d=d['filter'](e=>e['id']!=='QO6');if(!c['receive'])d=d['filter'](e=>e['id']!=='QO7');if(a['skip_user_confirmation'])return{'questions_asked':d,'responses':d['map'](e=>({'question_id':e['id'],'response':'yes'})),'all_confirmed':!![]};return{'questions_asked':d,'responses':[],'all_confirmed':![]};}function verifyEnvironment(a){const b=[],c=a['order_json'],d=a['current_state']??{},e=a['caller']??{};c['object']&&b['push']({'name':'order_exists','passed':!![],'message':'Order\x20'+c['object']+'\x20assumed\x20to\x20exist\x20(verify\x20via\x20explorer)'});const f=!!(c['receive']||c['transfer_to']||c['agent']),g=!!(c['required_info']!==undefined||c['progress']||c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation']);if(f)b['push']({'name':'signer_is_owner','passed':!!e['is_owner'],'message':e['is_owner']?'Signer\x20is\x20owner\x20—\x20L1\x20allowed':'Signer\x20is\x20NOT\x20owner\x20—\x20L1\x20operation\x20will\x20abort\x20E_OWNER'});else{if(g){const i=!!e['is_owner']||!!e['is_agent'];b['push']({'name':'signer_is_owner_or_agent','passed':i,'message':i?'Signer\x20is\x20'+(e['is_owner']?'owner':'agent')+'\x20—\x20L2\x20allowed':'Signer\x20is\x20NEITHER\x20owner\x20NOR\x20agent\x20—\x20L2\x20will\x20abort\x20E_PERMISSION'});}}(c['arb_confirm']||c['arb_objection']||c['arb_claim_compensation'])&&b['push']({'name':'claimed_by_is_none','passed':!d['claimed_by_set'],'message':d['claimed_by_set']?'claimed_by\x20is\x20SET\x20—\x20arb\x20operations\x20blocked\x20(E_ORDER_ALREADY_CLAIMED,\x20IRREVERSIBLE)':'claimed_by\x20is\x20None\x20—\x20arb\x20operations\x20allowed'});c['receive']&&b['push']({'name':'progress_at_terminal','passed':!!d['progress_at_terminal'],'message':d['progress_at_terminal']?'Progress\x20at\x20terminal\x20—\x20receive\x20allowed':'Progress\x20NOT\x20at\x20terminal\x20—\x20receive\x20aborts\x20E_ORDER_DELIVERING'});c['agent']&&b['push']({'name':'progress_not_bound','passed':!d['progress_bound'],'message':d['progress_bound']?'Progress\x20BOUND\x20—\x20agent_set\x20aborts\x20E_PROGRESS_NOT_SPECIFIED\x20(frozen)':'Progress\x20not\x20bound\x20—\x20agent_set\x20allowed'});if(c['arb_confirm']){const j=d['dispute_count']??0x0,k=j<MAX_DISPUTE_COUNT;b['push']({'name':'dispute_count_below_max','passed':k,'message':k?j+'\x20disputes\x20(<\x20MAX_DISPUTE_COUNT\x20'+MAX_DISPUTE_COUNT+')':j+'\x20disputes\x20at\x20MAX_DISPUTE_COUNT\x20—\x20next\x20dispute()\x20aborts\x20E_MAX_DISPUTE_COUNT'});}d['service_published']===![]&&b['push']({'name':'service_published','passed':![],'message':'Service\x20is\x20NOT\x20published\x20—\x20service::buy\x20will\x20fail'});d['service_paused']===!![]&&b['push']({'name':'service_not_paused','passed':![],'message':'Service\x20is\x20PAUSED\x20—\x20service::buy\x20will\x20fail'});const h=b['every'](l=>l['passed']);return{'passed':h,'checks':b};}export const ORDER_CONFIRM_VERSION='1.0.0';export function runOrderConfirmGate(a){const b=[],c=[],d=runStaticChecklist(a);if(!d['all_passed'])return c['push']('L1_checklist'),{'status':'blocked_checklist','checklist_result':d,'confirmation_text':generateConfirmationText(a,d),'block_reason':'Checklist\x20failed:\x20'+d['items']['filter'](h=>!h['passed'])['map'](h=>h['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_checklist','layers_passed':b,'layers_failed':c}};b['push']('L1_checklist');const e=adaptRiskAssessment(a),f=e['risks']['some'](h=>h['level']==='CRITICAL');if(f)return c['push']('L2_risk'),{'status':'blocked_risk','checklist_result':d,'risk_result':e,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'CRITICAL\x20risks:\x20'+e['risks']['filter'](h=>h['level']==='CRITICAL')['map'](h=>h['id'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_risk','layers_passed':b,'layers_failed':c}};b['push']('L2_risk');const g=processUserConfirmation(a,e);if(!g['all_confirmed']){const h=!!(a['order_json']['transfer_to']||a['order_json']['arb_claim_compensation']||a['order_json']['arb_objection']);if(h){const i=d['items']['find'](j=>j['id']==='C-O-10');if(i){const j=[];if(a['order_json']['transfer_to'])j['push']('QO5');if(a['order_json']['arb_claim_compensation'])j['push']('QO4');if(a['order_json']['arb_objection'])j['push']('QO3');const k=j['every'](l=>{const m=g['responses']['find'](n=>n['question_id']===l);return m?.['response']==='yes';});i['passed']=k,i['message']=k?'':'Irreversible\x20operation\x20not\x20confirmed\x20by\x20user';}}if(h){const l=d['items']['find'](m=>m['id']==='C-O-10');if(l&&!l['passed'])return c['push']('L3_user'),{'status':'blocked_user','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'User\x20did\x20not\x20confirm\x20irreversible\x20operation','decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_user','layers_passed':b,'layers_failed':c}};}}b['push']('L3_user');if(a['skip_environment_check'])b['push']('L4_environment');else{const m=verifyEnvironment(a);if(!m['passed'])return c['push']('L4_environment'),{'status':'blocked_environment','checklist_result':d,'risk_result':e,'user_confirmation':g,'environment_result':m,'confirmation_text':generateConfirmationText(a,d,e),'block_reason':'Environment\x20check\x20failed:\x20'+m['checks']['filter'](n=>!n['passed'])['map'](n=>n['name'])['join'](',\x20'),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'blocked_environment','layers_passed':b,'layers_failed':c}};b['push']('L4_environment');}return{'status':'approved','checklist_result':d,'risk_result':e,'user_confirmation':g,'confirmation_text':generateConfirmationText(a,d,e),'decision_record':{'timestamp':new Date()['toISOString'](),'gate_version':ORDER_CONFIRM_VERSION,'final_status':'approved','layers_passed':b,'layers_failed':c}};}function generateConfirmationText(a,b,c){const d=[],e=a['order_json'];d['push']('═══\x20Order\x20Confirmation\x20═══'),d['push']('');e['object']?d['push']('Order:\x20'+e['object']):d['push']('Order:\x20(no\x20address\x20—\x20invalid\x20for\x20CallOrder_Data)');d['push'](''),d['push']('─\x20Operations\x20──────────────────');if(e['agent'])d['push']('-\x20⚠️\x20Set\x20agent\x20list:\x20'+e['agent']['length']+'\x20agent(s)\x20[L1,\x20owner-only,\x20frozen\x20after\x20progress]');if(e['required_info']!==undefined)d['push']('-\x20required_info:\x20'+(e['required_info']===null?'(clear)':e['required_info'])+'\x20[L2]');if(e['progress'])d['push']('-\x20Advance\x20Progress:\x20'+(e['progress']['next_node_name']??'?')+'\x20[L2,\x20irreversible]');if(e['arb_confirm'])d['push']('-\x20⚠️\x20File\x20arbitration:\x20'+e['arb_confirm']['arb']+'\x20[L2,\x20irreversible]');if(e['arb_objection'])d['push']('-\x20⚠️\x20Object\x20to\x20Arb:\x20'+e['arb_objection']['arb']+'\x20[L2,\x20irreversible]');if(e['arb_claim_compensation'])d['push']('-\x20⚠️⚠️\x20Claim\x20compensation:\x20'+e['arb_claim_compensation']['arb']+'\x20[L2,\x20ONE-TIME,\x20IRREVERSIBLE]');if(e['receive'])d['push']('-\x20Receive:\x20'+e['receive']['received']+'\x20[L1,\x20owner-only]');if(e['transfer_to'])d['push']('-\x20⚠️⚠️\x20Transfer\x20ownership\x20to:\x20'+e['transfer_to']+'\x20[L1,\x20IRREVERSIBLE]');d['push'](''),d['push']('─\x20Checklist\x20──────────────────');for(const f of b['items']){const g=f['passed']?'✓':'✗';d['push']('\x20\x20'+g+'\x20'+f['id']+':\x20'+f['description']+(f['message']?'\x20—\x20'+f['message']:''));}d['push']('');if(c){d['push']('─\x20Risk\x20Assessment\x20──────────────────'),d['push']('Overall:\x20'+c['overall_risk']),d['push']('Detected:\x20'+c['risks']['length']+'\x20risk(s)');for(const h of c['risks']){d['push']('\x20\x20['+h['level']+']\x20'+h['id']+':\x20'+h['title']);}d['push']('');}return d['join']('\x0a');}export function progressiveOrderCheck(a){const b=runStaticChecklist(a);if(!b['all_passed'])return{'stage':'checklist','status':'fail','message':'Checklist\x20failed:\x20'+b['items']['filter'](d=>!d['passed'])['map'](d=>d['id'])['join'](',\x20'),'next_action':'Fix\x20failing\x20checklist\x20items'};const c=adaptRiskAssessment(a);if(c['risks']['some'](d=>d['level']==='CRITICAL'))return{'stage':'risk','status':'fail','message':'CRITICAL\x20risks:\x20'+c['risks']['filter'](d=>d['level']==='CRITICAL')['map'](d=>d['id'])['join'](',\x20'),'next_action':'Resolve\x20CRITICAL\x20risks\x20before\x20proceeding'};if(c['needs_human_review'])return{'stage':'confirmation','status':'pending','message':'Human\x20review\x20required\x20for\x20HIGH\x20risks','next_action':'Confirm\x20risk\x20acceptance'};return{'stage':'complete','status':'pass','message':'All\x20checks\x20passed'};}