@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,198 +1 @@
1
- export const TRUST_METRICS_VERSION = 1;
2
- const TRUST_LEVELS = [
3
- { min: 75, level: "trusted", label: "High trust" },
4
- { min: 50, level: "moderate", label: "Moderate trust" },
5
- { min: 25, level: "caution", label: "Needs attention" },
6
- { min: 0, level: "high_risk", label: "High risk" },
7
- ];
8
- export function computeServiceTrustScore(metrics) {
9
- const breakdown = [];
10
- const warnings = [];
11
- const arbScore = computeArbitrationDimension(metrics);
12
- breakdown.push(arbScore);
13
- if (arbScore.score < arbScore.maxScore * 0.3) {
14
- warnings.push("Arbitration trust score is low; recommend checking arbitration records");
15
- }
16
- const reviewScore = computeReviewDimension(metrics);
17
- breakdown.push(reviewScore);
18
- if (reviewScore.score < reviewScore.maxScore * 0.3 && metrics.reviewStats) {
19
- warnings.push(`Low like rate (${metrics.reviewStats.likes}/${metrics.reviewStats.totalReviews})`);
20
- }
21
- const fulfillmentScore = computeFulfillmentDimension(metrics);
22
- breakdown.push(fulfillmentScore);
23
- if (metrics.completedRate !== undefined && metrics.completedRate < 0.7) {
24
- warnings.push(`Completion rate only ${Math.round(metrics.completedRate * 100)}%`);
25
- }
26
- const fundScore = computeFundDimension(metrics);
27
- breakdown.push(fundScore);
28
- if (metrics.compensationFundBalance === undefined || metrics.compensationFundBalance === 0n) {
29
- warnings.push("No compensation fund; insufficient protection of customer rights");
30
- }
31
- const transparencyScore = computeTransparencyDimension(metrics);
32
- breakdown.push(transparencyScore);
33
- const totalScore = breakdown.reduce((sum, d) => sum + d.score, 0);
34
- const level = TRUST_LEVELS.find((l) => totalScore >= l.min)?.level ?? "high_risk";
35
- const label = TRUST_LEVELS.find((l) => totalScore >= l.min)?.label ?? "High risk";
36
- const summary = buildSummary(totalScore, label, metrics, breakdown);
37
- return { score: totalScore, level, breakdown, summary, warnings };
38
- }
39
- function computeArbitrationDimension(metrics) {
40
- const maxScore = 30;
41
- if (metrics.arbitrationScore === undefined && metrics.arbitrationVotingGuardCount === undefined) {
42
- return {
43
- name: "arbitration",
44
- score: maxScore * 0.25,
45
- maxScore,
46
- description: "Arbitration trust score (no data; default low because arbitration is critical)",
47
- humanReadable: "Arbitration: no data (default low — critical missing)",
48
- };
49
- }
50
- let score = 0;
51
- const parts = [];
52
- if (metrics.arbitrationScore !== undefined) {
53
- const baseScore = Math.round((metrics.arbitrationScore / 100) * 10);
54
- score += baseScore;
55
- parts.push(`score ${metrics.arbitrationScore}/100`);
56
- }
57
- else {
58
- score += 3;
59
- }
60
- if (metrics.arbitrationVotingGuardCount !== undefined && metrics.arbitrationVotingGuardCount > 0) {
61
- score += 5;
62
- parts.push(`${metrics.arbitrationVotingGuardCount} voting_guard(s)`);
63
- }
64
- if (metrics.arbitrationFeeBalance !== undefined && metrics.arbitrationFeeBalance > 0n) {
65
- score += 5;
66
- parts.push("fee funded");
67
- }
68
- if (metrics.arbitrationPaused === false) {
69
- score += 5;
70
- parts.push("active");
71
- }
72
- else if (metrics.arbitrationPaused === true) {
73
- parts.push("paused");
74
- }
75
- if (metrics.arbitrationCases !== undefined && metrics.arbitrationCases > 0) {
76
- score += 5;
77
- parts.push(`${metrics.arbitrationCases} case(s)`);
78
- }
79
- score = Math.min(maxScore, score);
80
- return {
81
- name: "arbitration",
82
- score,
83
- maxScore,
84
- description: `Arbitration config: ${parts.join(", ")}`,
85
- humanReadable: `Arbitration: ${parts.join(", ")}`,
86
- };
87
- }
88
- function computeReviewDimension(metrics) {
89
- const maxScore = 25;
90
- if (!metrics.reviewStats || metrics.reviewStats.totalReviews === 0) {
91
- return { name: "reviews", score: maxScore * 0.5, maxScore, description: "Review reputation (no review data)", humanReadable: "Reviews: no data" };
92
- }
93
- const { likes, dislikes, verifiedReviews, totalReviews } = metrics.reviewStats;
94
- const likeRate = likes / Math.max(1, totalReviews);
95
- const verifiedBoost = Math.min(5, verifiedReviews);
96
- const score = Math.round(likeRate * (maxScore - 5) + verifiedBoost);
97
- return {
98
- name: "reviews",
99
- score: Math.min(maxScore, score),
100
- maxScore,
101
- description: `Like rate ${Math.round(likeRate * 100)}% (${totalReviews} reviews, ${verifiedReviews} verified)`,
102
- humanReadable: `Like rate ${Math.round(likeRate * 100)}% (${totalReviews} reviews)`,
103
- };
104
- }
105
- function computeFulfillmentDimension(metrics) {
106
- const maxScore = 20;
107
- if (metrics.orderCount === undefined) {
108
- return { name: "fulfillment", score: maxScore * 0.5, maxScore, description: "Fulfillment record (no order data)", humanReadable: "Fulfillment: no data" };
109
- }
110
- let score = 0;
111
- const orderScore = Math.min(10, Math.floor(metrics.orderCount / 5));
112
- score += orderScore;
113
- if (metrics.completedRate !== undefined) {
114
- score += Math.round(metrics.completedRate * 10);
115
- }
116
- else {
117
- score += 5;
118
- }
119
- return {
120
- name: "fulfillment",
121
- score: Math.min(maxScore, score),
122
- maxScore,
123
- description: `Completed ${metrics.orderCount} orders, completion rate ${metrics.completedRate !== undefined ? Math.round(metrics.completedRate * 100) + "%" : "unknown"}`,
124
- humanReadable: `Fulfillment: ${metrics.orderCount} orders${metrics.avgCompletionTime !== undefined ? `, avg ${metrics.avgCompletionTime}h` : ""}`,
125
- };
126
- }
127
- function computeFundDimension(metrics) {
128
- const maxScore = 15;
129
- if (metrics.compensationFundBalance === undefined || metrics.compensationFundBalance === 0n) {
130
- return { name: "fund_safety", score: 0, maxScore, description: "No compensation fund", humanReadable: "Compensation fund: none" };
131
- }
132
- const fund = metrics.compensationFundBalance;
133
- if (metrics.typicalOrderAmount !== undefined && metrics.typicalOrderAmount > 0n) {
134
- const ratio = Number((fund * 100n) / metrics.typicalOrderAmount) / 100;
135
- let score;
136
- let humanReadable;
137
- if (ratio >= 10) {
138
- score = maxScore;
139
- humanReadable = `Compensation fund: ${ratio.toFixed(1)}x order amount (excellent)`;
140
- }
141
- else if (ratio >= 1) {
142
- score = 10 + Math.round((ratio - 1) / 9 * 5);
143
- humanReadable = `Compensation fund: ${ratio.toFixed(1)}x order amount (covers ≥1 payout)`;
144
- }
145
- else {
146
- score = Math.round(ratio * 10);
147
- humanReadable = `Compensation fund: ${ratio.toFixed(1)}x order amount (insufficient)`;
148
- }
149
- return {
150
- name: "fund_safety",
151
- score: Math.min(maxScore, score),
152
- maxScore,
153
- description: `Fund ${fund.toString()} / typical order ${metrics.typicalOrderAmount.toString()} = ${ratio.toFixed(2)}x`,
154
- humanReadable,
155
- };
156
- }
157
- const threshold = 1000000000000n;
158
- const ratio = Number(metrics.compensationFundBalance * 100n / threshold) / 100;
159
- const score = Math.min(maxScore, Math.round(ratio * maxScore));
160
- return {
161
- name: "fund_safety",
162
- score,
163
- maxScore,
164
- description: `Compensation fund ${metrics.compensationFundBalance} smallest unit (absolute threshold fallback)`,
165
- humanReadable: `Compensation fund: ${ratio.toFixed(2)}x absolute threshold`,
166
- };
167
- }
168
- function computeTransparencyDimension(metrics) {
169
- const maxScore = 10;
170
- let score = 0;
171
- if (metrics.hasPublishedEvents)
172
- score += 4;
173
- if (metrics.hasMachineBound)
174
- score += 3;
175
- if (metrics.hasBuyGuard)
176
- score += 3;
177
- return {
178
- name: "transparency",
179
- score: Math.min(maxScore, score),
180
- maxScore,
181
- description: `On-chain events ${metrics.hasPublishedEvents ? "✓" : "✗"}, Machine ${metrics.hasMachineBound ? "✓" : "✗"}, Guard ${metrics.hasBuyGuard ? "✓" : "✗"}`,
182
- humanReadable: `Transparency: ${["Events", "Machine", "Guard"].filter((_, i) => [metrics.hasPublishedEvents, metrics.hasMachineBound, metrics.hasBuyGuard][i]).join("+") || "none"}`,
183
- };
184
- }
185
- function buildSummary(score, label, metrics, breakdown) {
186
- const parts = [`Trust score ${score}/100 (${label})`];
187
- for (const d of breakdown) {
188
- parts.push(`${d.humanReadable}`);
189
- }
190
- return parts.join("; ");
191
- }
192
- export function quickTrustCheck(metrics) {
193
- const result = computeServiceTrustScore(metrics);
194
- if (result.score < 25) {
195
- return { pass: false, reason: `Trust score ${result.score}/100, high risk: ${result.warnings.join("; ")}` };
196
- }
197
- return { pass: true, reason: `Trust score ${result.score}/100 (${result.level})` };
198
- }
1
+ export const TRUST_METRICS_VERSION=0x1;const TRUST_LEVELS=[{'min':0x4b,'level':'trusted','label':'High\x20trust'},{'min':0x32,'level':'moderate','label':'Moderate\x20trust'},{'min':0x19,'level':'caution','label':'Needs\x20attention'},{'min':0x0,'level':'high_risk','label':'High\x20risk'}];export function computeServiceTrustScore(a){const b=[],c=[],d=computeArbitrationDimension(a);b['push'](d);d['score']<d['maxScore']*0.3&&c['push']('Arbitration\x20trust\x20score\x20is\x20low;\x20recommend\x20checking\x20arbitration\x20records');const e=computeReviewDimension(a);b['push'](e);e['score']<e['maxScore']*0.3&&a['reviewStats']&&c['push']('Low\x20like\x20rate\x20('+a['reviewStats']['likes']+'/'+a['reviewStats']['totalReviews']+')');const f=computeFulfillmentDimension(a);b['push'](f);a['completedRate']!==undefined&&a['completedRate']<0.7&&c['push']('Completion\x20rate\x20only\x20'+Math['round'](a['completedRate']*0x64)+'%');const g=computeFundDimension(a);b['push'](g);(a['compensationFundBalance']===undefined||a['compensationFundBalance']===0x0n)&&c['push']('No\x20compensation\x20fund;\x20insufficient\x20protection\x20of\x20customer\x20rights');const h=computeTransparencyDimension(a);b['push'](h);const i=b['reduce']((m,n)=>m+n['score'],0x0),j=TRUST_LEVELS['find'](m=>i>=m['min'])?.['level']??'high_risk',k=TRUST_LEVELS['find'](m=>i>=m['min'])?.['label']??'High\x20risk',l=buildSummary(i,k,a,b);return{'score':i,'level':j,'breakdown':b,'summary':l,'warnings':c};}function computeArbitrationDimension(a){const b=0x1e;if(a['arbitrationScore']===undefined&&a['arbitrationVotingGuardCount']===undefined)return{'name':'arbitration','score':b*0.25,'maxScore':b,'description':'Arbitration\x20trust\x20score\x20(no\x20data;\x20default\x20low\x20because\x20arbitration\x20is\x20critical)','humanReadable':'Arbitration:\x20no\x20data\x20(default\x20low\x20—\x20critical\x20missing)'};let c=0x0;const d=[];if(a['arbitrationScore']!==undefined){const e=Math['round'](a['arbitrationScore']/0x64*0xa);c+=e,d['push']('score\x20'+a['arbitrationScore']+'/100');}else c+=0x3;a['arbitrationVotingGuardCount']!==undefined&&a['arbitrationVotingGuardCount']>0x0&&(c+=0x5,d['push'](a['arbitrationVotingGuardCount']+'\x20voting_guard(s)'));a['arbitrationFeeBalance']!==undefined&&a['arbitrationFeeBalance']>0x0n&&(c+=0x5,d['push']('fee\x20funded'));if(a['arbitrationPaused']===![])c+=0x5,d['push']('active');else a['arbitrationPaused']===!![]&&d['push']('paused');return a['arbitrationCases']!==undefined&&a['arbitrationCases']>0x0&&(c+=0x5,d['push'](a['arbitrationCases']+'\x20case(s)')),c=Math['min'](b,c),{'name':'arbitration','score':c,'maxScore':b,'description':'Arbitration\x20config:\x20'+d['join'](',\x20'),'humanReadable':'Arbitration:\x20'+d['join'](',\x20')};}function computeReviewDimension(a){const b=0x19;if(!a['reviewStats']||a['reviewStats']['totalReviews']===0x0)return{'name':'reviews','score':b*0.5,'maxScore':b,'description':'Review\x20reputation\x20(no\x20review\x20data)','humanReadable':'Reviews:\x20no\x20data'};const {likes:c,dislikes:d,verifiedReviews:e,totalReviews:f}=a['reviewStats'],g=c/Math['max'](0x1,f),h=Math['min'](0x5,e),i=Math['round'](g*(b-0x5)+h);return{'name':'reviews','score':Math['min'](b,i),'maxScore':b,'description':'Like\x20rate\x20'+Math['round'](g*0x64)+'%\x20('+f+'\x20reviews,\x20'+e+'\x20verified)','humanReadable':'Like\x20rate\x20'+Math['round'](g*0x64)+'%\x20('+f+'\x20reviews)'};}function computeFulfillmentDimension(a){const b=0x14;if(a['orderCount']===undefined)return{'name':'fulfillment','score':b*0.5,'maxScore':b,'description':'Fulfillment\x20record\x20(no\x20order\x20data)','humanReadable':'Fulfillment:\x20no\x20data'};let c=0x0;const d=Math['min'](0xa,Math['floor'](a['orderCount']/0x5));return c+=d,a['completedRate']!==undefined?c+=Math['round'](a['completedRate']*0xa):c+=0x5,{'name':'fulfillment','score':Math['min'](b,c),'maxScore':b,'description':'Completed\x20'+a['orderCount']+'\x20orders,\x20completion\x20rate\x20'+(a['completedRate']!==undefined?Math['round'](a['completedRate']*0x64)+'%':'unknown'),'humanReadable':'Fulfillment:\x20'+a['orderCount']+'\x20orders'+(a['avgCompletionTime']!==undefined?',\x20avg\x20'+a['avgCompletionTime']+'h':'')};}function computeFundDimension(a){const b=0xf;if(a['compensationFundBalance']===undefined||a['compensationFundBalance']===0x0n)return{'name':'fund_safety','score':0x0,'maxScore':b,'description':'No\x20compensation\x20fund','humanReadable':'Compensation\x20fund:\x20none'};const c=a['compensationFundBalance'];if(a['typicalOrderAmount']!==undefined&&a['typicalOrderAmount']>0x0n){const g=Number(c*0x64n/a['typicalOrderAmount'])/0x64;let h,i;if(g>=0xa)h=b,i='Compensation\x20fund:\x20'+g['toFixed'](0x1)+'x\x20order\x20amount\x20(excellent)';else g>=0x1?(h=0xa+Math['round']((g-0x1)/0x9*0x5),i='Compensation\x20fund:\x20'+g['toFixed'](0x1)+'x\x20order\x20amount\x20(covers\x20≥1\x20payout)'):(h=Math['round'](g*0xa),i='Compensation\x20fund:\x20'+g['toFixed'](0x1)+'x\x20order\x20amount\x20(insufficient)');return{'name':'fund_safety','score':Math['min'](b,h),'maxScore':b,'description':'Fund\x20'+c['toString']()+'\x20/\x20typical\x20order\x20'+a['typicalOrderAmount']['toString']()+'\x20=\x20'+g['toFixed'](0x2)+'x','humanReadable':i};}const d=0xe8d4a51000n,e=Number(a['compensationFundBalance']*0x64n/d)/0x64,f=Math['min'](b,Math['round'](e*b));return{'name':'fund_safety','score':f,'maxScore':b,'description':'Compensation\x20fund\x20'+a['compensationFundBalance']+'\x20smallest\x20unit\x20(absolute\x20threshold\x20fallback)','humanReadable':'Compensation\x20fund:\x20'+e['toFixed'](0x2)+'x\x20absolute\x20threshold'};}function computeTransparencyDimension(a){const b=0xa;let c=0x0;if(a['hasPublishedEvents'])c+=0x4;if(a['hasMachineBound'])c+=0x3;if(a['hasBuyGuard'])c+=0x3;return{'name':'transparency','score':Math['min'](b,c),'maxScore':b,'description':'On-chain\x20events\x20'+(a['hasPublishedEvents']?'✓':'✗')+',\x20Machine\x20'+(a['hasMachineBound']?'✓':'✗')+',\x20Guard\x20'+(a['hasBuyGuard']?'✓':'✗'),'humanReadable':'Transparency:\x20'+(['Events','Machine','Guard']['filter']((d,e)=>[a['hasPublishedEvents'],a['hasMachineBound'],a['hasBuyGuard']][e])['join']('+')||'none')};}function buildSummary(a,b,c,e){const f=['Trust\x20score\x20'+a+'/100\x20('+b+')'];for(const g of e){f['push'](''+g['humanReadable']);}return f['join'](';\x20');}export function quickTrustCheck(a){const b=computeServiceTrustScore(a);if(b['score']<0x19)return{'pass':![],'reason':'Trust\x20score\x20'+b['score']+'/100,\x20high\x20risk:\x20'+b['warnings']['join'](';\x20')};return{'pass':!![],'reason':'Trust\x20score\x20'+b['score']+'/100\x20('+b['level']+')'};}
@@ -0,0 +1,22 @@
1
+ export interface AntiCheatBaseline {
2
+ enabled: boolean;
3
+ rules: string[];
4
+ }
5
+ export interface UniversalTemplate {
6
+ template: "universal";
7
+ version: string;
8
+ anti_cheat_baseline: {
9
+ fake_orders: AntiCheatBaseline;
10
+ fake_reviews: AntiCheatBaseline;
11
+ shell_merchant: AntiCheatBaseline;
12
+ reputation_trade: AntiCheatBaseline;
13
+ };
14
+ pricing_redlines: string[];
15
+ governance_redlines: string[];
16
+ quality_signals: string[];
17
+ consumer_journey: string[];
18
+ north_star_metric: string;
19
+ revenue_boundary: string;
20
+ }
21
+ export declare const UNIVERSAL_TEMPLATE: UniversalTemplate;
22
+ export declare function getUniversalTemplate(): UniversalTemplate;
@@ -0,0 +1 @@
1
+ export const UNIVERSAL_TEMPLATE={'template':'universal','version':'1.0.0','anti_cheat_baseline':{'fake_orders':{'enabled':!![],'rules':['self_trade','mutual_brush','no_fund_closure']},'fake_reviews':{'enabled':!![],'rules':['no_order_no_review','amount_weighted','small_order_decay']},'shell_merchant':{'enabled':!![],'rules':['no_arbitration','no_machine']},'reputation_trade':{'enabled':!![],'rules':['immune']}},'pricing_redlines':['profile_pricing','hidden_surcharge','post_order_price_change'],'governance_redlines':['no_bid_ranking','no_default_charge','no_take_rate','no_personal_info_on_chain'],'quality_signals':['trust_score','fund_visibility','fulfillment','review_reputation','tenure'],'consumer_journey':['awareness','diligence','compare','decide','fulfill','review','retain','repurchase'],'north_star_metric':'weekly_completed_orders','revenue_boundary':'no_take_rate'};export function getUniversalTemplate(){return UNIVERSAL_TEMPLATE;}
@@ -0,0 +1,24 @@
1
+ export declare const UTIL_CONFIRM_VERSION = "1.0.0";
2
+ export type ConfirmSeverity = "block" | "warn" | "info";
3
+ export interface UtilConfirmItem {
4
+ id: string;
5
+ severity: ConfirmSeverity;
6
+ title: string;
7
+ description: string;
8
+ passed: boolean;
9
+ evidence?: string;
10
+ fix_hint?: string;
11
+ }
12
+ export interface UtilCallCheckInput {
13
+ uses_typo_function_name?: boolean;
14
+ assumes_stable_address_bytes?: boolean;
15
+ bcs_manually_synced?: boolean;
16
+ }
17
+ export declare function preCheckUtilCall(input: UtilCallCheckInput): UtilConfirmItem[];
18
+ export declare function canProceedUtilCall(input: UtilCallCheckInput): {
19
+ canProceed: boolean;
20
+ blockers: UtilConfirmItem[];
21
+ warnings: UtilConfirmItem[];
22
+ info: UtilConfirmItem[];
23
+ };
24
+ export declare function formatUtilCallSummary(input: UtilCallCheckInput): string;
@@ -0,0 +1 @@
1
+ export const UTIL_CONFIRM_VERSION='1.0.0';function checkTypo(a){const b=!!a['uses_typo_function_name'];return{'id':'C-UTIL-01','severity':b?'info':'info','title':'Typo\x27d\x20function\x20name\x20is\x20handled\x20(is_chiild_object_address_byte)','description':'util.move\x20defines\x20is_chiild_object_address_byte\x20with\x20a\x20\x27chiild\x27\x20typo;\x20it\x20cannot\x20be\x20renamed\x20post-publish.\x20The\x20SDK\x20should\x20expose\x20a\x20correct\x20alias.','passed':!![],'evidence':b?'uses_typo_function_name=true\x20(must\x20use\x20\x27chiild\x27)':'typo\x20handled\x20via\x20alias'};}function checkAddressBytes(a){const b=!!a['assumes_stable_address_bytes'];return{'id':'C-UTIL-02','severity':b?'warn':'info','title':'Address-byte\x20thresholds\x20are\x20hardcoded','description':'util.move\x20classifies\x20addresses\x20by\x20first\x20byte\x20(user\x20≤0x06,\x20object\x200xf1,\x20child_object\x200xf0).\x20A\x20Wow\x20protocol\x20upgrade\x20could\x20invalidate\x20them.','passed':!b,'evidence':b?'assumes_stable_address_bytes=true':'upgrade\x20coupling\x20understood','fix_hint':'Track\x20Wow\x20address-layout\x20upgrades;\x20ship\x20util.move\x20+\x20SDK\x20in\x20lockstep.'};}function checkBcs(a){const b=a['bcs_manually_synced']===!![];return{'id':'C-UTIL-03','severity':b?'warn':'info','title':'SDK\x20BCS\x20structures\x20stay\x20in\x20sync\x20with\x20Move\x20structs','description':'util.ts\x20defines\x20BCS\x20query\x20structures\x20that\x20must\x20match\x20Move\x20layouts\x20byte-for-byte;\x20drift\x20breaks\x20queries\x20silently.','passed':!b,'evidence':b?'bcs_manually_synced=true\x20(drift\x20risk)':'BCS\x20sync\x20safe','fix_hint':'Generate\x20BCS\x20from\x20Move\x20via\x20codegen,\x20or\x20run\x20a\x20layout\x20sync\x20test.'};}export function preCheckUtilCall(a){return[checkTypo(a),checkAddressBytes(a),checkBcs(a)];}export function canProceedUtilCall(a){const b=preCheckUtilCall(a);return{'canProceed':b['every'](c=>c['severity']!=='block'||c['passed']),'blockers':b['filter'](c=>c['severity']==='block'&&!c['passed']),'warnings':b['filter'](c=>c['severity']==='warn'&&!c['passed']),'info':b['filter'](c=>c['severity']==='info')};}export function formatUtilCallSummary(a){const {canProceed:b,warnings:c}=canProceedUtilCall(a),d=[b?'✓\x20Util\x20call\x20pre-check\x20PASSED':'✗\x20Util\x20call\x20pre-check\x20FAILED',''];return c['length']>0x0&&(d['push']('WARNINGS:'),c['forEach'](e=>d['push']('\x20\x20['+e['id']+']\x20'+e['title']+'\x20—\x20'+(e['evidence']??'')))),d['join']('\x0a');}
@@ -1,135 +1 @@
1
- const USER_ADDRESS_BYTE_MAX = 0x06;
2
- const OBJECT_ADDRESS_BYTE = 0xf1;
3
- const CHILD_OBJECT_ADDRESS_BYTE = 0xf0;
4
- const R_U_01 = {
5
- rule: {
6
- id: "R-UTIL-01",
7
- level: "LOW",
8
- category: "semantic",
9
- title: "is_chiild_object_address_byte has a typo ('chiild') — cannot be renamed post-publish",
10
- description: "util.move:30 defines is_chiild_object_address_byte (note the 'chiild' typo). The " +
11
- "function is already published on mainnet, so the name cannot be fixed without a " +
12
- "breaking package upgrade. Callers must use the misspelled name exactly; SDK wrappers " +
13
- "should expose a correctly-spelled alias and route to the typo function.",
14
- affected_stakeholders: ["caller"],
15
- scenario: "Caller writes is_child_object_address_byte; Move linker cannot resolve the symbol",
16
- mitigation: "SDK should expose isChildObjectAddressByte as the public API and internally call the " +
17
- "typo'd Move function. Document the typo so future maintainers don't 'fix' it.",
18
- auto_fixable: false,
19
- },
20
- check: (ctx) => {
21
- if (!ctx.uses_typo_function_name)
22
- return null;
23
- return { ...R_U_01.rule, evidence: "uses_typo_function_name=true (must use 'chiild')" };
24
- },
25
- };
26
- const R_U_02 = {
27
- rule: {
28
- id: "R-UTIL-02",
29
- level: "MEDIUM",
30
- category: "semantic",
31
- title: "Address-byte thresholds are hardcoded — Wow protocol upgrades could invalidate them",
32
- description: `util.move classifies addresses by first byte: user (≤ ${USER_ADDRESS_BYTE_MAX}), ` +
33
- `object (${OBJECT_ADDRESS_BYTE}), child_object (${CHILD_OBJECT_ADDRESS_BYTE}). ` +
34
- `These thresholds are hardcoded as Move constants, not configurable. If a future Wow ` +
35
- `protocol upgrade changes the address byte layout (e.g. reserves a new prefix), Util ` +
36
- `would silently misclassify addresses until the Move code is upgraded.`,
37
- affected_stakeholders: ["caller", "system"],
38
- scenario: "Wow protocol upgrade introduces a new address prefix; Util misclassifies it as user",
39
- mitigation: "Track Wow protocol upgrades that touch address layout. When a change ships, upgrade " +
40
- "util.move and the SDK in lockstep. Add a sync test that asserts the byte values.",
41
- auto_fixable: false,
42
- },
43
- check: (ctx) => {
44
- if (!ctx.assumes_stable_address_bytes)
45
- return null;
46
- return { ...R_U_02.rule, evidence: `assumes_stable_address_bytes=true (hardcoded ${USER_ADDRESS_BYTE_MAX}/${OBJECT_ADDRESS_BYTE}/${CHILD_OBJECT_ADDRESS_BYTE})` };
47
- },
48
- };
49
- const R_U_03 = {
50
- rule: {
51
- id: "R-UTIL-03",
52
- level: "LOW",
53
- category: "structural",
54
- title: "util.ts is ~50KB — over-concentrated, hard to navigate",
55
- description: "The SDK util.ts is ~50428 bytes, mixing BCS structure definitions, query condition " +
56
- "builders, Guard query helpers, and address utilities. The size makes it hard to " +
57
- "navigate and increases the risk of accidental circular imports. New contributors " +
58
- "often import the wrong symbol because so many are exported from one file.",
59
- affected_stakeholders: ["caller", "system"],
60
- scenario: "Developer imports ProgressHistoryFindConditionsBCS and accidentally pulls in unrelated code",
61
- mitigation: "Consider splitting util.ts into focused sub-modules (bcs.ts, query.ts, address.ts). " +
62
- "Until then, prefer named imports over namespace imports to keep bundles lean.",
63
- auto_fixable: false,
64
- },
65
- check: (ctx) => {
66
- if (!ctx.large_util_import)
67
- return null;
68
- return { ...R_U_03.rule, evidence: "large_util_import=true (consider sub-modules)" };
69
- },
70
- };
71
- const R_U_04 = {
72
- rule: {
73
- id: "R-UTIL-04",
74
- level: "LOW",
75
- category: "lifecycle",
76
- title: "Util emits no events — tool-call observability is caller's responsibility",
77
- description: "Util functions are pure: they neither emit nor consume events. Callers cannot rely on " +
78
- "an event stream to trace Util invocations. For audit and debugging, the calling " +
79
- "module must record its own log entries around Util calls.",
80
- affected_stakeholders: ["caller"],
81
- scenario: "Auditor expects Util-call events; none exist, the call chain is invisible",
82
- mitigation: "Callers should emit their own events or write logs around Util calls when auditability " +
83
- "is required. Treat Util as an opaque library function.",
84
- auto_fixable: false,
85
- },
86
- check: (ctx) => {
87
- if (!ctx.expects_util_events)
88
- return null;
89
- return { ...R_U_04.rule, evidence: "expects_util_events=true (none emitted)" };
90
- },
91
- };
92
- const R_U_05 = {
93
- rule: {
94
- id: "R-UTIL-05",
95
- level: "MEDIUM",
96
- category: "cross_object",
97
- title: "SDK BCS structures must stay in sync with Move structs — drift breaks queries",
98
- description: "util.ts defines BCS structures for Progress History / Session / Forward / Record " +
99
- "query conditions. These must match the Move struct layouts byte-for-byte. If a Move " +
100
- "struct adds a field and the SDK BCS is not regenerated, query submissions will " +
101
- "deserialize incorrectly on-chain, producing silent failures or aborts.",
102
- affected_stakeholders: ["caller", "system"],
103
- scenario: "Progress struct adds a field; SDK BCS is stale; queries return wrong results",
104
- mitigation: "Generate BCS structures from Move source via codegen, or run a sync test that " +
105
- "compares SDK BCS layouts against Move structs on every release.",
106
- auto_fixable: false,
107
- },
108
- check: (ctx) => {
109
- if (ctx.bcs_manually_synced === undefined)
110
- return null;
111
- if (!ctx.bcs_manually_synced)
112
- return null;
113
- return { ...R_U_05.rule, evidence: "bcs_manually_synced=true (drift risk)" };
114
- },
115
- };
116
- export const UTIL_RISK_RULES = [
117
- R_U_01,
118
- R_U_02,
119
- R_U_03,
120
- R_U_04,
121
- R_U_05,
122
- ];
123
- export const UTIL_RISK_VERSION = "1.0.0";
124
- export function checkUtilRisks(ctx) {
125
- const risks = [];
126
- for (const rule of UTIL_RISK_RULES) {
127
- const r = rule.check(ctx);
128
- if (r)
129
- risks.push(r);
130
- }
131
- return risks;
132
- }
133
- export function getUtilRiskById(id) {
134
- return UTIL_RISK_RULES.find(r => r.rule.id === id)?.rule;
135
- }
1
+ const USER_ADDRESS_BYTE_MAX=0x6,OBJECT_ADDRESS_BYTE=0xf1,CHILD_OBJECT_ADDRESS_BYTE=0xf0,R_U_01={'rule':{'id':'R-UTIL-01','level':'LOW','category':'semantic','title':'is_chiild_object_address_byte\x20has\x20a\x20typo\x20(\x27chiild\x27)\x20—\x20cannot\x20be\x20renamed\x20post-publish','description':'util.move:30\x20defines\x20is_chiild_object_address_byte\x20(note\x20the\x20\x27chiild\x27\x20typo).\x20The\x20'+'function\x20is\x20already\x20published\x20on\x20mainnet,\x20so\x20the\x20name\x20cannot\x20be\x20fixed\x20without\x20a\x20'+'breaking\x20package\x20upgrade.\x20Callers\x20must\x20use\x20the\x20misspelled\x20name\x20exactly;\x20SDK\x20wrappers\x20'+'should\x20expose\x20a\x20correctly-spelled\x20alias\x20and\x20route\x20to\x20the\x20typo\x20function.','affected_stakeholders':['caller'],'scenario':'Caller\x20writes\x20is_child_object_address_byte;\x20Move\x20linker\x20cannot\x20resolve\x20the\x20symbol','mitigation':'SDK\x20should\x20expose\x20isChildObjectAddressByte\x20as\x20the\x20public\x20API\x20and\x20internally\x20call\x20the\x20'+'typo\x27d\x20Move\x20function.\x20Document\x20the\x20typo\x20so\x20future\x20maintainers\x20don\x27t\x20\x27fix\x27\x20it.','auto_fixable':![]},'check':a=>{if(!a['uses_typo_function_name'])return null;return{...R_U_01['rule'],'evidence':'uses_typo_function_name=true\x20(must\x20use\x20\x27chiild\x27)'};}},R_U_02={'rule':{'id':'R-UTIL-02','level':'MEDIUM','category':'semantic','title':'Address-byte\x20thresholds\x20are\x20hardcoded\x20—\x20Wow\x20protocol\x20upgrades\x20could\x20invalidate\x20them','description':'util.move\x20classifies\x20addresses\x20by\x20first\x20byte:\x20user\x20(≤\x20'+USER_ADDRESS_BYTE_MAX+'),\x20'+('object\x20('+OBJECT_ADDRESS_BYTE+'),\x20child_object\x20('+CHILD_OBJECT_ADDRESS_BYTE+').\x20')+'These\x20thresholds\x20are\x20hardcoded\x20as\x20Move\x20constants,\x20not\x20configurable.\x20If\x20a\x20future\x20Wow\x20'+'protocol\x20upgrade\x20changes\x20the\x20address\x20byte\x20layout\x20(e.g.\x20reserves\x20a\x20new\x20prefix),\x20Util\x20'+'would\x20silently\x20misclassify\x20addresses\x20until\x20the\x20Move\x20code\x20is\x20upgraded.','affected_stakeholders':['caller','system'],'scenario':'Wow\x20protocol\x20upgrade\x20introduces\x20a\x20new\x20address\x20prefix;\x20Util\x20misclassifies\x20it\x20as\x20user','mitigation':'Track\x20Wow\x20protocol\x20upgrades\x20that\x20touch\x20address\x20layout.\x20When\x20a\x20change\x20ships,\x20upgrade\x20'+'util.move\x20and\x20the\x20SDK\x20in\x20lockstep.\x20Add\x20a\x20sync\x20test\x20that\x20asserts\x20the\x20byte\x20values.','auto_fixable':![]},'check':a=>{if(!a['assumes_stable_address_bytes'])return null;return{...R_U_02['rule'],'evidence':'assumes_stable_address_bytes=true\x20(hardcoded\x20'+USER_ADDRESS_BYTE_MAX+'/'+OBJECT_ADDRESS_BYTE+'/'+CHILD_OBJECT_ADDRESS_BYTE+')'};}},R_U_03={'rule':{'id':'R-UTIL-03','level':'LOW','category':'structural','title':'util.ts\x20is\x20~50KB\x20—\x20over-concentrated,\x20hard\x20to\x20navigate','description':'The\x20SDK\x20util.ts\x20is\x20~50428\x20bytes,\x20mixing\x20BCS\x20structure\x20definitions,\x20query\x20condition\x20'+'builders,\x20Guard\x20query\x20helpers,\x20and\x20address\x20utilities.\x20The\x20size\x20makes\x20it\x20hard\x20to\x20'+'navigate\x20and\x20increases\x20the\x20risk\x20of\x20accidental\x20circular\x20imports.\x20New\x20contributors\x20'+'often\x20import\x20the\x20wrong\x20symbol\x20because\x20so\x20many\x20are\x20exported\x20from\x20one\x20file.','affected_stakeholders':['caller','system'],'scenario':'Developer\x20imports\x20ProgressHistoryFindConditionsBCS\x20and\x20accidentally\x20pulls\x20in\x20unrelated\x20code','mitigation':'Consider\x20splitting\x20util.ts\x20into\x20focused\x20sub-modules\x20(bcs.ts,\x20query.ts,\x20address.ts).\x20'+'Until\x20then,\x20prefer\x20named\x20imports\x20over\x20namespace\x20imports\x20to\x20keep\x20bundles\x20lean.','auto_fixable':![]},'check':a=>{if(!a['large_util_import'])return null;return{...R_U_03['rule'],'evidence':'large_util_import=true\x20(consider\x20sub-modules)'};}},R_U_04={'rule':{'id':'R-UTIL-04','level':'LOW','category':'lifecycle','title':'Util\x20emits\x20no\x20events\x20—\x20tool-call\x20observability\x20is\x20caller\x27s\x20responsibility','description':'Util\x20functions\x20are\x20pure:\x20they\x20neither\x20emit\x20nor\x20consume\x20events.\x20Callers\x20cannot\x20rely\x20on\x20'+'an\x20event\x20stream\x20to\x20trace\x20Util\x20invocations.\x20For\x20audit\x20and\x20debugging,\x20the\x20calling\x20'+'module\x20must\x20record\x20its\x20own\x20log\x20entries\x20around\x20Util\x20calls.','affected_stakeholders':['caller'],'scenario':'Auditor\x20expects\x20Util-call\x20events;\x20none\x20exist,\x20the\x20call\x20chain\x20is\x20invisible','mitigation':'Callers\x20should\x20emit\x20their\x20own\x20events\x20or\x20write\x20logs\x20around\x20Util\x20calls\x20when\x20auditability\x20'+'is\x20required.\x20Treat\x20Util\x20as\x20an\x20opaque\x20library\x20function.','auto_fixable':![]},'check':a=>{if(!a['expects_util_events'])return null;return{...R_U_04['rule'],'evidence':'expects_util_events=true\x20(none\x20emitted)'};}},R_U_05={'rule':{'id':'R-UTIL-05','level':'MEDIUM','category':'cross_object','title':'SDK\x20BCS\x20structures\x20must\x20stay\x20in\x20sync\x20with\x20Move\x20structs\x20—\x20drift\x20breaks\x20queries','description':'util.ts\x20defines\x20BCS\x20structures\x20for\x20Progress\x20History\x20/\x20Session\x20/\x20Forward\x20/\x20Record\x20'+'query\x20conditions.\x20These\x20must\x20match\x20the\x20Move\x20struct\x20layouts\x20byte-for-byte.\x20If\x20a\x20Move\x20'+'struct\x20adds\x20a\x20field\x20and\x20the\x20SDK\x20BCS\x20is\x20not\x20regenerated,\x20query\x20submissions\x20will\x20'+'deserialize\x20incorrectly\x20on-chain,\x20producing\x20silent\x20failures\x20or\x20aborts.','affected_stakeholders':['caller','system'],'scenario':'Progress\x20struct\x20adds\x20a\x20field;\x20SDK\x20BCS\x20is\x20stale;\x20queries\x20return\x20wrong\x20results','mitigation':'Generate\x20BCS\x20structures\x20from\x20Move\x20source\x20via\x20codegen,\x20or\x20run\x20a\x20sync\x20test\x20that\x20'+'compares\x20SDK\x20BCS\x20layouts\x20against\x20Move\x20structs\x20on\x20every\x20release.','auto_fixable':![]},'check':a=>{if(a['bcs_manually_synced']===undefined)return null;if(!a['bcs_manually_synced'])return null;return{...R_U_05['rule'],'evidence':'bcs_manually_synced=true\x20(drift\x20risk)'};}};export const UTIL_RISK_RULES=[R_U_01,R_U_02,R_U_03,R_U_04,R_U_05];export const UTIL_RISK_VERSION='1.0.0';export function checkUtilRisks(a){const b=[];for(const c of UTIL_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return b;}export function getUtilRiskById(a){return UTIL_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
@@ -0,0 +1,38 @@
1
+ export declare const UTIL_TRANSLATION_VERSION = "1.0.0";
2
+ export declare const UTIL_ADDRESS_BYTES: {
3
+ readonly USER_MAX: 6;
4
+ readonly OBJECT: 241;
5
+ readonly CHILD_OBJECT: 240;
6
+ };
7
+ export interface SemanticToUtilSchemaRule {
8
+ id: string;
9
+ pattern_name: string;
10
+ semantic_intent: string;
11
+ match_keywords: string[];
12
+ example: Record<string, unknown>;
13
+ }
14
+ export declare const SEMANTIC_TO_UTIL_SCHEMA_RULES: SemanticToUtilSchemaRule[];
15
+ export interface UtilFieldTranslation {
16
+ field_name: string;
17
+ value_type: string;
18
+ semantic: string;
19
+ format_example: string;
20
+ validation_rules: string[];
21
+ }
22
+ export declare const UTIL_FIELD_TRANSLATIONS: UtilFieldTranslation[];
23
+ export interface UtilConstraintRule {
24
+ id: string;
25
+ name: string;
26
+ description: string;
27
+ related_field: string;
28
+ }
29
+ export declare const UTIL_CONSTRAINT_RULES: UtilConstraintRule[];
30
+ export interface UtilExplainInput {
31
+ first_byte?: number;
32
+ }
33
+ export interface UtilExplanation {
34
+ summary: string;
35
+ classification: string;
36
+ warnings: string[];
37
+ }
38
+ export declare function explainUtil(input: UtilExplainInput): UtilExplanation;
@@ -0,0 +1 @@
1
+ export const UTIL_TRANSLATION_VERSION='1.0.0';export const UTIL_ADDRESS_BYTES={'USER_MAX':0x6,'OBJECT':0xf1,'CHILD_OBJECT':0xf0};export const SEMANTIC_TO_UTIL_SCHEMA_RULES=[{'id':'P-UTIL-01','pattern_name':'Classify\x20address','semantic_intent':'Determine\x20whether\x20an\x20address\x20is\x20a\x20user,\x20object,\x20or\x20child-object.','match_keywords':['is\x20user\x20address','is\x20object\x20address','classify\x20address'],'example':{'addr':'0x...'}}];export const UTIL_FIELD_TRANSLATIONS=[{'field_name':'first_byte','value_type':'u8','semantic':'Address\x20classification\x20byte:\x20user\x20≤\x200x06,\x20object\x200xf1,\x20child_object\x200xf0.','format_example':'0xf1\x20(object)','validation_rules':['hardcoded\x20in\x20util.move']}];export const UTIL_CONSTRAINT_RULES=[{'id':'UTIL_C_01','name':'typo\x20function','description':'is_chiild_object_address_byte\x20has\x20a\x20\x27chiild\x27\x20typo;\x20cannot\x20rename\x20post-publish.','related_field':'first_byte'},{'id':'UTIL_C_02','name':'address-byte\x20stability','description':'byte\x20thresholds\x20are\x20hardcoded;\x20Wow\x20upgrade\x20could\x20invalidate\x20them.','related_field':'first_byte'},{'id':'UTIL_C_03','name':'BCS\x20sync','description':'SDK\x20BCS\x20structures\x20must\x20match\x20Move\x20layouts\x20byte-for-byte.','related_field':'first_byte'}];export function explainUtil(a){const b=[];let c='unknown';if(a['first_byte']!==undefined){if(a['first_byte']<=UTIL_ADDRESS_BYTES['USER_MAX'])c='user\x20address';else{if(a['first_byte']===UTIL_ADDRESS_BYTES['OBJECT'])c='object\x20address';else{if(a['first_byte']===UTIL_ADDRESS_BYTES['CHILD_OBJECT'])c='child\x20object\x20address';else b['push']('first\x20byte\x200x'+a['first_byte']['toString'](0x10)+'\x20not\x20in\x20known\x20classification\x20range');}}}return{'summary':'Util\x20address\x20classification:\x20'+c+'.','classification':c,'warnings':b};}
@@ -0,0 +1,116 @@
1
+ export interface ParsedForward {
2
+ name: string;
3
+ weight: number;
4
+ namedOperator?: string | null;
5
+ permissionIndex?: number | null;
6
+ guard?: string;
7
+ }
8
+ export interface ParsedPair {
9
+ prev_node: string;
10
+ threshold: number;
11
+ forwards: ParsedForward[];
12
+ }
13
+ export interface ParsedMachineNode {
14
+ name: string;
15
+ pairs: ParsedPair[];
16
+ }
17
+ export type NameResolver = (addr: string | undefined | null) => string | undefined;
18
+ export declare function resolvePermissionRole(index: number | undefined | null, permissionDescription?: string): string;
19
+ export declare function fetchMachineNodes(machine: string, network?: string, noCache?: boolean): Promise<ParsedMachineNode[]>;
20
+ export interface GuidanceInput {
21
+ current: string;
22
+ nodes: ParsedMachineNode[];
23
+ caller?: string;
24
+ orderHolderAddresses?: string[];
25
+ permissionDescription?: string;
26
+ nameResolver?: NameResolver;
27
+ }
28
+ export interface OperatorInfo {
29
+ kind: "order_holder" | "permission_index" | "named_operator";
30
+ permission_index?: number;
31
+ role_name?: string;
32
+ account_name?: string;
33
+ named_operator?: string;
34
+ }
35
+ export interface OptionInfo {
36
+ next_node: string;
37
+ forward: string;
38
+ weight: number;
39
+ operator: OperatorInfo;
40
+ guard?: string;
41
+ business_meaning: string;
42
+ gains: string[];
43
+ risks: string[];
44
+ consistency: number;
45
+ recommended: boolean;
46
+ }
47
+ export interface GuidanceResult {
48
+ current_node: string;
49
+ caller?: string;
50
+ options: OptionInfo[];
51
+ recommendation?: {
52
+ best?: string;
53
+ rationale?: string;
54
+ caveat?: string;
55
+ };
56
+ note?: string;
57
+ }
58
+ export declare function buildWorkflowGuidance(input: GuidanceInput): GuidanceResult;
59
+ export interface ReceiptInput extends GuidanceInput {
60
+ callerName: string;
61
+ forward: string;
62
+ targetNode: string;
63
+ op?: string;
64
+ session?: Array<{
65
+ next_node?: string;
66
+ forwards?: Array<{
67
+ forward?: string;
68
+ accomplished?: boolean;
69
+ }>;
70
+ weights?: number;
71
+ threshold?: number;
72
+ }>;
73
+ }
74
+ export interface WaitingInfo {
75
+ forward: string;
76
+ operator: OperatorInfo;
77
+ }
78
+ export interface ReceiptResult {
79
+ account: string;
80
+ action: string;
81
+ forward: string;
82
+ target_node: string;
83
+ op?: string;
84
+ migrated: boolean;
85
+ current_node: string;
86
+ threshold?: number;
87
+ accumulated_weight?: number;
88
+ remaining?: number;
89
+ waiting_on?: WaitingInfo[];
90
+ next_guidance?: GuidanceResult;
91
+ note?: string;
92
+ }
93
+ export declare function buildWorkflowReceipt(input: ReceiptInput): ReceiptResult;
94
+ export declare function renderGuidanceText(g: GuidanceResult): string;
95
+ export declare function renderReceiptText(r: ReceiptResult): string;
96
+ export interface EnrichOptions {
97
+ progressRef: string;
98
+ network?: string;
99
+ accountName?: string;
100
+ operate?: {
101
+ forward?: string;
102
+ next_node_name?: string;
103
+ op?: string;
104
+ };
105
+ noCache?: boolean;
106
+ }
107
+ export interface EnrichResult {
108
+ guidance?: GuidanceResult;
109
+ receipt?: ReceiptResult;
110
+ text?: string;
111
+ }
112
+ export declare function enrichWorkflowGuidance(opts: EnrichOptions): Promise<EnrichResult | undefined>;
113
+ export declare function mergeGuidanceIntoOutput<T extends {
114
+ content: any[];
115
+ structuredContent: any;
116
+ }>(output: T, enrichment: EnrichResult | undefined): T;
@@ -0,0 +1 @@
1
+ import{query_objects,query_table,LocalMark,GetLocalNamesByAddresses}from'@wowok/wowok';import{REPOSITORY_PERMISSIONS,REWARD_PERMISSIONS,MACHINE_PERMISSIONS,PROGRESS_PERMISSIONS,TREASURY_PERMISSIONS,SERVICE_PERMISSIONS,ARBITRATION_PERMISSIONS,DEMAND_PERMISSIONS,CONTACT_PERMISSIONS}from'./permission-ledger.js';const BUILTIN_PERMISSION_MAP=new Map();for(const entry of[...REPOSITORY_PERMISSIONS,...REWARD_PERMISSIONS,...MACHINE_PERMISSIONS,...PROGRESS_PERMISSIONS,...TREASURY_PERMISSIONS,...SERVICE_PERMISSIONS,...ARBITRATION_PERMISSIONS,...DEMAND_PERMISSIONS,...CONTACT_PERMISSIONS]){BUILTIN_PERMISSION_MAP['set'](entry['index'],entry['name']);}export function resolvePermissionRole(a,b){if(a===undefined||a===null)return'unknown\x20role';if(b){const d=/([A-Za-z][A-Za-z0-9_]*)\s*=\s*(\d+)/g;let e;while((e=d['exec'](b))!==null){if(Number(e[0x2])===a)return e[0x1]+'\x20(permission\x20'+a+')';}}const c=BUILTIN_PERMISSION_MAP['get'](a);if(c)return c+'\x20(permission\x20'+a+')';return'permission\x20'+a;}export async function fetchMachineNodes(a,b,c){const d=await query_objects({'objects':[a],'no_cache':c,'network':b}),e=d?.['objects']?.[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const g=await query_table({'parent':f,'no_cache':c,'network':b}),h=(g?.['items']??[])['map'](j=>j?.['object'])['filter'](j=>typeof j==='string');if(h['length']===0x0)return[];const i=await query_objects({'objects':h,'no_cache':c,'network':b});return(i?.['objects']??[])['filter'](j=>j?.['type']==='TableItem_MachineNode')['map'](j=>{const k=j?.['data']??j,l=typeof k?.['name']==='string'?k['name']:'',m=Array['isArray'](k?.['value'])?k['value']:Array['isArray'](k?.['pairs'])?k['pairs']:[];if(!l)return null;return{'name':l,'pairs':m['map'](n=>({'prev_node':String(n?.['prev_node']??''),'threshold':Number(n?.['threshold']??0x0),'forwards':Array['isArray'](n?.['forwards'])?n['forwards']['map'](q=>{const r=typeof q?.['guard']==='object'&&q?.['guard']!==null?q['guard']['guard']??undefined:typeof q?.['guard']==='string'?q['guard']:undefined;return{'name':String(q?.['name']??''),'weight':Number(q?.['weight']??0x0),'namedOperator':q?.['namedOperator']!==undefined&&q?.['namedOperator']!==null?String(q['namedOperator']):undefined,'permissionIndex':q?.['permissionIndex']!==undefined&&q?.['permissionIndex']!==null?Number(q['permissionIndex']):undefined,'guard':r};}):[]}))};})['filter'](j=>j!==null);}const COMPLETE_RE=/(^|_)(completed?|done|finished|received|delivered|accepted|confirmed|finalized|success|approved)(_|$)/i,REFUND_RE=/(^|_)(cancel(led)?|refund(ed)?|return(ed|_approved)?)(_|$)/i,EXCEPTION_RE=/(^|_)(interrupt(ed)?|exception|dispute(d)?|fail(ed)?|abort(ed)?|reject(ed)?)(_|$)/i;function classifyNode(a){if(COMPLETE_RE['test'](a))return'complete';if(REFUND_RE['test'](a))return'refund';if(EXCEPTION_RE['test'](a))return'exception';return'advance';}function businessMeaning(a,b){switch(b){case'complete':return'Service/deliverable\x20accepted\x20at\x20\x22'+a+'\x22\x20—\x20triggers\x20settlement\x20allocation\x20(funds\x20released\x20to\x20the\x20provider)';case'refund':return'Order\x20cancelled/returned\x20at\x20\x22'+a+'\x22\x20—\x20triggers\x20refund\x20allocation\x20(funds\x20back\x20to\x20the\x20customer)';case'exception':return'Exception\x20path\x20at\x20\x22'+a+'\x22\x20—\x20typically\x20routes\x20to\x20arbitration\x20or\x20partial-refund\x20handling';default:return'Progress\x20to\x20\x22'+a+'\x22';}}function shortAddr(a){if(!a)return undefined;if(a['length']>0xe)return a['slice'](0x0,0x8)+'...'+a['slice'](-0x4);return a;}function callerIsOrderHolder(a,b){if(!a||!b?.['length'])return![];const d=a['toLowerCase']();return b['some'](e=>e?.['toLowerCase']()===d);}function resolveOperator(a,b,c,d){if(a['namedOperator']===''){const e=b?.[0x0];return{'kind':'order_holder','role_name':'order\x20holder\x20(customer)','account_name':d?d(e):shortAddr(e)};}if(typeof a['namedOperator']==='string'&&a['namedOperator']['length']>0x0)return{'kind':'named_operator','named_operator':a['namedOperator'],'role_name':'named\x20operator\x20\x22'+a['namedOperator']+'\x22'};if(a['permissionIndex']!==undefined&&a['permissionIndex']!==null)return{'kind':'permission_index','permission_index':a['permissionIndex'],'role_name':resolvePermissionRole(a['permissionIndex'],c)};return{'kind':'order_holder','role_name':'unknown\x20operator'};}function gainsRisksFor(a,b,c){if(!c)return{'gains':[],'risks':[]};if(b)switch(a){case'complete':return{'gains':['Flow\x20advances','Settlement\x20triggered\x20(funds\x20released)'],'risks':['Funds\x20released\x20to\x20provider','Refund\x20leverage\x20lost\x20—\x20confirm\x20only\x20if\x20service\x20verified']};case'refund':return{'gains':['Funds\x20returned\x20to\x20you'],'risks':['If\x20service\x20was\x20already\x20rendered,\x20cancellation\x20may\x20be\x20disputed']};case'exception':return{'gains':['Avoids\x20stalemate'],'risks':['May\x20trigger\x20arbitration\x20/\x20reputation\x20impact']};default:return{'gains':['Flow\x20advances'],'risks':[]};}switch(a){case'complete':return{'gains':['Settlement\x20triggered\x20—\x20funds\x20released\x20to\x20provider'],'risks':[]};case'refund':return{'gains':['Clean\x20closure'],'risks':['Lost\x20revenue\x20for\x20this\x20order']};case'exception':return{'gains':['Avoids\x20stalemate'],'risks':['May\x20trigger\x20arbitration\x20/\x20compensation\x20fund']};default:return{'gains':['Flow\x20advances'],'risks':[]};}}function consistencyFor(a,b,c,d,e){let f;if(!e)f=a==='exception'?0x2d:0x32;else b?f=a==='refund'?0x46:a==='complete'?0x37:a==='exception'?0x23:0x32:f=a==='complete'?0x4b:a==='refund'?0x1e:a==='exception'?0x23:0x32;if(e&&c)f+=0x14;if(d)f-=0xa;return Math['max'](0x0,Math['min'](0x64,f));}export function buildWorkflowGuidance(a){const b=[];for(const i of a['nodes']){for(const j of i['pairs']){if(j['prev_node']!==a['current'])continue;for(const k of j['forwards']){if(!k['name'])continue;const l=resolveOperator(k,a['orderHolderAddresses'],a['permissionDescription'],a['nameResolver']),m=callerIsOrderHolder(a['caller'],a['orderHolderAddresses']);let n=![];if(l['kind']==='order_holder'&&a['caller']){const u=a['caller']['toLowerCase']();n=!!a['orderHolderAddresses']?.['some'](v=>v?.['toLowerCase']()===u)||u===(l['account_name']??'')['toLowerCase']();}else{if(l['kind']==='named_operator')n=!![];else l['kind']==='permission_index'&&(n=!![]);}const p=classifyNode(i['name']),q=!!a['caller'],{gains:r,risks:s}=gainsRisksFor(p,m,q),t=consistencyFor(p,m,n,!!k['guard'],q);b['push']({'next_node':i['name'],'forward':k['name'],'weight':k['weight'],'operator':l,'guard':k['guard'],'business_meaning':businessMeaning(i['name'],p),'gains':r,'risks':s,'consistency':t,'recommended':![]});}}}if(b['length']===0x0)return{'current_node':a['current'],'caller':a['caller'],'options':[],'note':'Node\x20\x22'+a['current']+'\x22\x20has\x20no\x20outgoing\x20forwards\x20—\x20it\x20is\x20a\x20terminal\x20node\x20(or\x20the\x20workflow\x20is\x20stuck).\x20No\x20further\x20progress\x20operation\x20is\x20available\x20here.'};b['sort']((v,w)=>w['consistency']-v['consistency']);const c=b[0x0];b[0x0]={...c,'recommended':!![]};const d=[];for(const v of b){v!==c&&v['consistency']>0x0&&v['forward']!==c['forward']&&d['push']('Choosing\x20\x22'+v['forward']+'\x20→\x20'+v['next_node']+'\x22\x20forfeits\x20the\x20faster/more\x20aligned\x20path\x20\x22'+c['forward']+'\x20→\x20'+c['next_node']+'\x22');}const e=[],g=b['filter'](w=>w['operator']['kind']==='order_holder'&&w['forward']!==c['forward']&&c['forward']!==w['forward']),h=b['filter'](w=>w['operator']['account_name']&&w['operator']['account_name']!==a['caller']);return h['length']>0x0&&!b['some'](w=>w['recommended']&&w['operator']['account_name']===a['caller'])&&e['push']('The\x20recommended\x20action\x20is\x20executed\x20by\x20another\x20account\x20('+h[0x0]['operator']['account_name']+');\x20switch\x20the\x20signing\x20account\x20(env.account)\x20before\x20operating.'),{'current_node':a['current'],'caller':a['caller'],'options':b,'recommendation':{'best':c['forward']+'\x20→\x20'+c['next_node'],'rationale':'Highest\x20consistency\x20('+c['consistency']+'/100)\x20with\x20the\x20caller\x27s\x20interests.\x20Gains:\x20'+(c['gains']['join'](';\x20')||'none')+'.\x20Risks:\x20'+(c['risks']['join'](';\x20')||'none')+'.\x20Operator:\x20'+(c['operator']['role_name']??c['operator']['kind'])+(c['operator']['account_name']?'\x20('+c['operator']['account_name']+')':'')+'.'+(c['guard']?'\x20Guard\x20to\x20satisfy:\x20'+c['guard']+'.':''),'caveat':d['length']?d['join']('.\x20'):undefined},'note':e['length']?e['join']('\x20'):undefined};}export function buildWorkflowReceipt(a){const b=a['current']===a['targetNode'],c={'account':a['callerName'],'action':a['callerName']+'\x20executed\x20'+a['forward']+'\x20(→\x20'+a['targetNode']+')','forward':a['forward'],'target_node':a['targetNode'],'op':a['op'],'migrated':b,'current_node':a['current']};if(!b){const e=a['nodes']['filter'](j=>j['name']===a['targetNode'])['flatMap'](j=>j['pairs'])['find'](j=>j['prev_node']===a['current']),g=a['session']?.['slice'](-0x1)[0x0],h=g?.['threshold']??e?.['threshold']??0x0,i=g?.['weights']??0x0;if(h>0x0){c['threshold']=h,c['accumulated_weight']=i,c['remaining']=Math['max'](0x0,h-i);const j=new Set((g?.['forwards']??[])['filter'](l=>l?.['accomplished']!==![])['map'](l=>l?.['forward'])['filter'](l=>!!l)),k=[];for(const l of e?.['forwards']??[]){if(!l['name']||j['has'](l['name']))continue;k['push']({'forward':l['name'],'operator':resolveOperator(l,a['orderHolderAddresses'],a['permissionDescription'],a['nameResolver'])});}if(k['length'])c['waiting_on']=k;c['note']='Node\x20did\x20not\x20migrate:\x20threshold\x20'+h+',\x20accumulated\x20weight\x20'+i+',\x20remaining\x20'+Math['max'](0x0,h-i)+'.\x20'+(k['length']?'Waiting\x20for:\x20'+k['map'](m=>m['forward']+'\x20('+(m['operator']['role_name']??m['operator']['kind'])+')')['join'](';\x20'):'All\x20forwards\x20on\x20this\x20pair\x20are\x20accomplished\x20—\x20the\x20node\x20should\x20migrate\x20on\x20the\x20next\x20operation.');}else c['note']='Node\x20did\x20not\x20migrate\x20(threshold\x200)\x20—\x20no\x20further\x20weight\x20cooperation\x20required;\x20verify\x20the\x20operation\x20outcome.';}const d=buildWorkflowGuidance({'current':a['current'],'nodes':a['nodes'],'caller':a['caller'],'orderHolderAddresses':a['orderHolderAddresses'],'permissionDescription':a['permissionDescription'],'nameResolver':a['nameResolver']});if(d['options']['length']>0x0)c['next_guidance']=d;return c;}function operatorText(a){const b=[a['role_name']??a['kind']];if(a['account_name'])b['push'](a['account_name']);return b['join']('\x20/\x20');}export function renderGuidanceText(a){const b=['[WORKFLOW\x20GUIDANCE]\x20current\x20node:\x20\x22'+a['current_node']+'\x22'+(a['caller']?'\x20(caller:\x20'+a['caller']+')':'')];if(a['options']['length']===0x0)return b['push']('\x20\x20•\x20'+(a['note']??'No\x20reachable\x20next\x20nodes.')),b['join']('\x0a');for(const c of a['options']){const d=['\x22'+c['forward']+'\x22\x20→\x20\x22'+c['next_node']+'\x22','operator:\x20'+operatorText(c['operator']),'weight:\x20'+c['weight'],'consistency:\x20'+c['consistency']+'/100'+(c['recommended']?'\x20[RECOMMENDED]':'')];if(c['guard'])d['push']('guard:\x20'+c['guard']);d['push']('meaning:\x20'+c['business_meaning']);if(c['gains']['length'])d['push']('gains:\x20'+c['gains']['join'](';\x20'));if(c['risks']['length'])d['push']('risks:\x20'+c['risks']['join'](';\x20'));b['push']('\x20\x20•\x20'+d['join']('\x20|\x20'));}if(a['recommendation']?.['best']){b['push']('\x20\x20RECOMMENDED:\x20'+a['recommendation']['best']+'.\x20'+(a['recommendation']['rationale']??''));if(a['recommendation']['caveat'])b['push']('\x20\x20CAVEAT\x20(opportunity\x20cost):\x20'+a['recommendation']['caveat']);}if(a['note'])b['push']('\x20\x20NOTE:\x20'+a['note']);return b['push']('\x20\x20(AI\x20recommendation\x20only\x20—\x20the\x20account\x20decides;\x20switch\x20env.account\x20if\x20another\x20operator\x20must\x20act.)'),b['join']('\x0a');}export function renderReceiptText(a){const b=['[WORKFLOW\x20RECEIPT]\x20'+a['action']];b['push']('\x20\x20•\x20node\x20migrated:\x20'+(a['migrated']?'yes\x20→\x20current:\x20\x22'+a['current_node']+'\x22':'no\x20→\x20current:\x20\x22'+a['current_node']+'\x22'));if(!a['migrated']){a['threshold']!==undefined&&a['threshold']>0x0&&(b['push']('\x20\x20•\x20threshold:\x20'+a['threshold']+'\x20|\x20accumulated\x20weight:\x20'+(a['accumulated_weight']??0x0)+'\x20|\x20remaining:\x20'+(a['remaining']??0x0)),a['waiting_on']?.['length']&&b['push']('\x20\x20•\x20waiting\x20on:\x20'+a['waiting_on']['map'](c=>'\x22'+c['forward']+'\x22\x20('+operatorText(c['operator'])+')')['join'](';\x20')));if(a['note'])b['push']('\x20\x20•\x20note:\x20'+a['note']);}return a['next_guidance']&&a['next_guidance']['options']['length']>0x0&&b['push'](renderGuidanceText(a['next_guidance'])),b['join']('\x0a');}async function makeNameResolver(a){const b=[...new Set(a['filter'](d=>!!d))],c=new Map();if(b['length'])try{const d=await GetLocalNamesByAddresses(b);for(const e of d){const f=e?.['account']??e?.['local_mark'];if(f)c['set'](e['address']['toLowerCase'](),f);}}catch{}return g=>{if(!g)return undefined;const h=c['get'](g['toLowerCase']());return h??shortAddr(g);};}export async function enrichWorkflowGuidance(a){try{let b;if(a['progressRef']['startsWith']('0x'))b=a['progressRef'];else b=await LocalMark['Instance']()['get_address'](a['progressRef'])??undefined;if(!b)return undefined;const c=await query_objects({'objects':[b],'no_cache':a['noCache'],'network':a['network']}),d=c?.['objects']?.[0x0],e=d?.['data']??d;if((d?.['type']??e?.['type'])!=='Progress')return undefined;const f=e['current']??'',g=e['machine'],h=Array['isArray'](e['session'])?e['session']:[],i=(Array['isArray'](e['namedOperator'])?e['namedOperator']['find'](q=>q?.['name']==='')?.['operators']:undefined)??[];if(!g)return undefined;const j=await fetchMachineNodes(g,a['network'],a['noCache']);let k;try{const q=await query_objects({'objects':[g],'no_cache':a['noCache'],'network':a['network']}),r=q?.['objects']?.[0x0],s=r?.['data']??r,t=s?.['permission'];if(t){const u=await query_objects({'objects':[t],'no_cache':a['noCache'],'network':a['network']}),v=u?.['objects']?.[0x0];k=(v?.['data']??v)?.['description']??undefined;}}catch{}const l=await makeNameResolver([a['accountName'],...i]),m={'current':f,'nodes':j,'caller':a['accountName'],'orderHolderAddresses':i,'permissionDescription':k,'nameResolver':l},n=buildWorkflowGuidance(m);let o;a['operate']?.['forward']&&a['operate']?.['next_node_name']&&(o=buildWorkflowReceipt({...m,'callerName':a['accountName']??b,'forward':a['operate']['forward'],'targetNode':a['operate']['next_node_name'],'op':a['operate']['op'],'session':h}));const p=[o?renderReceiptText(o):undefined,n['options']['length']?renderGuidanceText(n):undefined]['filter'](w=>!!w)['join']('\x0a\x0a');return{'guidance':n,'receipt':o,'text':p};}catch{return undefined;}}export function mergeGuidanceIntoOutput(a,b){if(!b)return a;try{const c=a?.['structuredContent'];if(c&&typeof c==='object'){const d=c['semantic'];if(d&&typeof d==='object'){if(b['guidance'])d['workflow_guidance']=b['guidance'];if(b['receipt'])d['workflow_receipt']=b['receipt'];}}b['text']&&Array['isArray'](a?.['content'])&&a['content'][0x0]?.['text']!==undefined&&(a['content'][0x0]['text']=b['text']+'\x0a\x0a'+a['content'][0x0]['text']);}catch{}return a;}