@wowok/agent-mcp 2.7.1 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/dist/config/index.js +1 -1
  2. package/dist/config/runtime.js +1 -238
  3. package/dist/customer/customer-advice.js +1 -130
  4. package/dist/customer/index.js +1 -11
  5. package/dist/customer/industry-risks.js +1 -438
  6. package/dist/customer/info-puzzle.js +1 -681
  7. package/dist/customer/order-monitor.js +1 -328
  8. package/dist/customer/order-strategy.js +1 -373
  9. package/dist/customer/post-purchase.js +1 -351
  10. package/dist/customer/preorder-compare.js +1 -34
  11. package/dist/customer/reminder-system.js +1 -316
  12. package/dist/customer/risk-assessment.js +1 -397
  13. package/dist/customer/types.js +1 -13
  14. package/dist/customer/user-preferences.js +1 -460
  15. package/dist/evaluation/arbitration-game.d.ts +9 -2
  16. package/dist/evaluation/arbitration-game.js +1 -48
  17. package/dist/evaluation/builtins/demand-match.js +1 -153
  18. package/dist/evaluation/builtins/index.js +1 -10
  19. package/dist/evaluation/builtins/service-risk.js +1 -55
  20. package/dist/evaluation/capability.js +1 -13
  21. package/dist/evaluation/composer.js +1 -40
  22. package/dist/evaluation/engine.js +1 -175
  23. package/dist/evaluation/extract.js +1 -115
  24. package/dist/evaluation/game-strategy.d.ts +27 -0
  25. package/dist/evaluation/game-strategy.js +1 -0
  26. package/dist/evaluation/gap.js +1 -100
  27. package/dist/evaluation/index.d.ts +1 -0
  28. package/dist/evaluation/index.js +1 -11
  29. package/dist/evaluation/node-game.d.ts +31 -3
  30. package/dist/evaluation/node-game.js +1 -57
  31. package/dist/evaluation/region.js +1 -36
  32. package/dist/evaluation/types.d.ts +1 -0
  33. package/dist/evaluation/types.js +1 -1
  34. package/dist/evaluation/user-injection.js +1 -27
  35. package/dist/experience/experience-reuse.js +1 -103
  36. package/dist/experience/index.js +1 -5
  37. package/dist/experience/intent-distill.js +1 -83
  38. package/dist/experience/realtime-feedback.js +1 -94
  39. package/dist/experience/types.js +1 -1
  40. package/dist/experience/user-profile.js +1 -171
  41. package/dist/extensions/business-modules.js +1 -287
  42. package/dist/extensions/capability-manifest.js +1 -781
  43. package/dist/extensions/constraint-registry.js +1 -198
  44. package/dist/extensions/index.js +1 -6
  45. package/dist/extensions/metric-registry.js +1 -257
  46. package/dist/extensions/mode-evaluator.js +1 -170
  47. package/dist/extensions/modes.js +1 -499
  48. package/dist/extensions/registry.js +1 -717
  49. package/dist/extensions/types.js +1 -1
  50. package/dist/harness/auto-escalation.js +1 -68
  51. package/dist/harness/checkpoint.js +1 -129
  52. package/dist/harness/index.js +1 -78
  53. package/dist/harness/plan.js +1 -315
  54. package/dist/harness/recover.js +1 -139
  55. package/dist/harness/types.js +1 -1
  56. package/dist/harness/verify.js +1 -237
  57. package/dist/index.js +1 -273
  58. package/dist/intent/enrich.js +1 -67
  59. package/dist/intent/index.js +1 -60
  60. package/dist/intent/matcher.js +1 -81
  61. package/dist/intent/store.js +1 -55
  62. package/dist/intent/types.js +1 -10
  63. package/dist/knowledge/acquisition-flywheel.js +1 -192
  64. package/dist/knowledge/allocation-confirm.js +1 -534
  65. package/dist/knowledge/allocation-context.js +1 -249
  66. package/dist/knowledge/allocation-ledger.js +1 -463
  67. package/dist/knowledge/allocation-puzzle.js +1 -298
  68. package/dist/knowledge/allocation-risk.js +1 -568
  69. package/dist/knowledge/allocation-templates.js +1 -970
  70. package/dist/knowledge/allocation-translation.js +1 -585
  71. package/dist/knowledge/arb-risk.js +1 -210
  72. package/dist/knowledge/arbitration-confirm.js +1 -559
  73. package/dist/knowledge/arbitration-context.js +1 -505
  74. package/dist/knowledge/arbitration-ledger.js +1 -521
  75. package/dist/knowledge/arbitration-puzzle.js +1 -304
  76. package/dist/knowledge/arbitration-risk.js +1 -423
  77. package/dist/knowledge/arbitration-templates.js +1 -276
  78. package/dist/knowledge/arbitration-translation.js +1 -487
  79. package/dist/knowledge/arbitration-trust.js +1 -117
  80. package/dist/knowledge/audit-rules.js +1 -141
  81. package/dist/knowledge/bridge-risk.js +1 -263
  82. package/dist/knowledge/contact-risk.js +1 -200
  83. package/dist/knowledge/contact-templates.js +1 -60
  84. package/dist/knowledge/demand-confirm.js +1 -206
  85. package/dist/knowledge/demand-matching.js +1 -132
  86. package/dist/knowledge/demand-risk.js +1 -240
  87. package/dist/knowledge/demand-translation.js +1 -354
  88. package/dist/knowledge/deployment-scanner.js +1 -823
  89. package/dist/knowledge/dynamic-pricing.js +1 -87
  90. package/dist/knowledge/examples-scanner-cli.js +1 -26
  91. package/dist/knowledge/examples-scanner.js +1 -843
  92. package/dist/knowledge/flywheel-loop.js +1 -404
  93. package/dist/knowledge/fund-layer.js +1 -973
  94. package/dist/knowledge/glossary.js +1 -211
  95. package/dist/knowledge/guard-confirm.js +1 -406
  96. package/dist/knowledge/guard-context.js +1 -287
  97. package/dist/knowledge/guard-design-patterns.js +1 -360
  98. package/dist/knowledge/guard-ledger.js +1 -260
  99. package/dist/knowledge/guard-lint.js +1 -670
  100. package/dist/knowledge/guard-migration.js +1 -228
  101. package/dist/knowledge/guard-puzzle.js +1 -805
  102. package/dist/knowledge/guard-render.js +1 -700
  103. package/dist/knowledge/guard-risk.js +1 -1879
  104. package/dist/knowledge/guard-submission-prompt.js +1 -171
  105. package/dist/knowledge/guard-templates.js +1 -1105
  106. package/dist/knowledge/guard-translation.js +1 -1119
  107. package/dist/knowledge/index.js +1 -436
  108. package/dist/knowledge/industry-evolution.js +1 -323
  109. package/dist/knowledge/industry-generalizer.js +1 -381
  110. package/dist/knowledge/industry-registry.js +1 -174
  111. package/dist/knowledge/intent-metrics.d.ts +4 -3
  112. package/dist/knowledge/intent-metrics.js +1 -566
  113. package/dist/knowledge/machine-confirm.js +1 -559
  114. package/dist/knowledge/machine-context.js +1 -833
  115. package/dist/knowledge/machine-ledger.js +1 -338
  116. package/dist/knowledge/machine-puzzle.js +1 -494
  117. package/dist/knowledge/machine-render.js +1 -565
  118. package/dist/knowledge/machine-risk.js +1 -669
  119. package/dist/knowledge/machine-templates.js +1 -1597
  120. package/dist/knowledge/machine-topology.js +1 -234
  121. package/dist/knowledge/machine-translation.js +1 -513
  122. package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
  123. package/dist/knowledge/mcp-schema-audit.js +1 -777
  124. package/dist/knowledge/onchain-constants.js +1 -35
  125. package/dist/knowledge/order-confirm.js +1 -573
  126. package/dist/knowledge/order-context.js +1 -390
  127. package/dist/knowledge/order-ledger.js +1 -341
  128. package/dist/knowledge/order-puzzle.js +1 -255
  129. package/dist/knowledge/order-risk.js +1 -653
  130. package/dist/knowledge/order-templates.js +1 -368
  131. package/dist/knowledge/order-translation.js +1 -550
  132. package/dist/knowledge/overrides-loader.js +1 -65
  133. package/dist/knowledge/passport-confirm.js +1 -531
  134. package/dist/knowledge/passport-context.js +1 -306
  135. package/dist/knowledge/passport-ledger.js +1 -282
  136. package/dist/knowledge/passport-puzzle.js +1 -333
  137. package/dist/knowledge/passport-risk.js +1 -450
  138. package/dist/knowledge/passport-templates.js +1 -568
  139. package/dist/knowledge/passport-translation.js +1 -516
  140. package/dist/knowledge/payment-risk.js +1 -249
  141. package/dist/knowledge/permission-confirm.js +1 -426
  142. package/dist/knowledge/permission-context.js +1 -224
  143. package/dist/knowledge/permission-ledger.js +1 -403
  144. package/dist/knowledge/permission-puzzle.js +1 -173
  145. package/dist/knowledge/permission-risk.js +1 -411
  146. package/dist/knowledge/permission-templates.js +1 -234
  147. package/dist/knowledge/permission-translation.js +1 -350
  148. package/dist/knowledge/personal-risk.js +1 -212
  149. package/dist/knowledge/process-model.js +1 -160
  150. package/dist/knowledge/progress-confirm.js +1 -456
  151. package/dist/knowledge/progress-context.js +1 -452
  152. package/dist/knowledge/progress-ledger.js +1 -330
  153. package/dist/knowledge/progress-puzzle.js +1 -219
  154. package/dist/knowledge/progress-risk.js +1 -461
  155. package/dist/knowledge/progress-templates.js +1 -228
  156. package/dist/knowledge/progress-translation.js +1 -405
  157. package/dist/knowledge/proof-confirm.js +1 -187
  158. package/dist/knowledge/proof-risk.js +1 -207
  159. package/dist/knowledge/proof-translation.js +1 -283
  160. package/dist/knowledge/registrar-risk.js +1 -217
  161. package/dist/knowledge/repository-confirm.js +1 -286
  162. package/dist/knowledge/repository-risk.js +1 -373
  163. package/dist/knowledge/repository-translation.js +1 -445
  164. package/dist/knowledge/reputation-rules.js +1 -99
  165. package/dist/knowledge/resource-risk.js +1 -157
  166. package/dist/knowledge/reward-confirm.js +1 -526
  167. package/dist/knowledge/reward-context.js +1 -504
  168. package/dist/knowledge/reward-ledger.js +1 -502
  169. package/dist/knowledge/reward-puzzle.js +1 -300
  170. package/dist/knowledge/reward-risk.js +1 -627
  171. package/dist/knowledge/reward-templates.js +1 -197
  172. package/dist/knowledge/reward-translation.js +1 -501
  173. package/dist/knowledge/safety-rules.js +1 -404
  174. package/dist/knowledge/scenario-modes.js +1 -321
  175. package/dist/knowledge/service-confirm.js +1 -807
  176. package/dist/knowledge/service-context.js +1 -403
  177. package/dist/knowledge/service-ledger.js +1 -609
  178. package/dist/knowledge/service-puzzle.js +1 -236
  179. package/dist/knowledge/service-risk.js +1 -651
  180. package/dist/knowledge/service-templates.js +1 -456
  181. package/dist/knowledge/service-translation.js +1 -622
  182. package/dist/knowledge/template-registry.js +1 -353
  183. package/dist/knowledge/tool-constraints.js +1 -195
  184. package/dist/knowledge/tools-reference.js +1 -178
  185. package/dist/knowledge/treasury-confirm.js +1 -512
  186. package/dist/knowledge/treasury-context.js +1 -363
  187. package/dist/knowledge/treasury-ledger.js +1 -300
  188. package/dist/knowledge/treasury-puzzle.js +1 -216
  189. package/dist/knowledge/treasury-risk.js +1 -440
  190. package/dist/knowledge/treasury-templates.js +1 -358
  191. package/dist/knowledge/treasury-translation.js +1 -498
  192. package/dist/knowledge/trust-metrics.js +1 -198
  193. package/dist/knowledge/util-risk.js +1 -135
  194. package/dist/loop-engineering/aggregate.js +1 -132
  195. package/dist/loop-engineering/context-collect.js +1 -83
  196. package/dist/loop-engineering/diagnose.js +1 -273
  197. package/dist/loop-engineering/improve.js +1 -405
  198. package/dist/loop-engineering/index.js +1 -4
  199. package/dist/loop-engineering/pipeline.js +1 -56
  200. package/dist/mode-market/index.js +1 -3
  201. package/dist/mode-market/registry.js +1 -124
  202. package/dist/mode-market/review.js +1 -214
  203. package/dist/mode-market/submission.js +1 -85
  204. package/dist/participation/collaborator-interest.d.ts +23 -0
  205. package/dist/participation/collaborator-interest.js +1 -0
  206. package/dist/participation/customer-interest.d.ts +25 -0
  207. package/dist/participation/customer-interest.js +1 -0
  208. package/dist/participation/merchant-interest.js +1 -100
  209. package/dist/participation/radar-core.d.ts +13 -3
  210. package/dist/participation/radar-core.js +1 -269
  211. package/dist/participation/supplier-interest.d.ts +25 -0
  212. package/dist/participation/supplier-interest.js +1 -0
  213. package/dist/persona/analyzer.js +1 -66
  214. package/dist/persona/bridge.js +1 -86
  215. package/dist/persona/defaults.js +1 -195
  216. package/dist/persona/experience-bridge.js +1 -23
  217. package/dist/persona/index.js +1 -71
  218. package/dist/persona/model.js +1 -111
  219. package/dist/persona/store.js +1 -62
  220. package/dist/persona/types.d.ts +3 -1
  221. package/dist/persona/types.js +1 -5
  222. package/dist/project/business-puzzle.js +1 -383
  223. package/dist/project/context-assembly.js +1 -254
  224. package/dist/project/deployment-bridge.js +1 -120
  225. package/dist/project/deployment-doc.js +1 -1126
  226. package/dist/project/edit-planner.js +1 -1342
  227. package/dist/project/evaluation.js +1 -2011
  228. package/dist/project/game-theory.js +1 -177
  229. package/dist/project/graph-builder.js +1 -656
  230. package/dist/project/graph.js +1 -340
  231. package/dist/project/handlers.js +1 -1784
  232. package/dist/project/index.d.ts +1 -0
  233. package/dist/project/index.js +1 -301
  234. package/dist/project/intent-analyzer.js +1 -149
  235. package/dist/project/machine-nodes.js +1 -36
  236. package/dist/project/merchant-guide.js +1 -264
  237. package/dist/project/migration.js +1 -125
  238. package/dist/project/mode-actions.js +1 -309
  239. package/dist/project/namespace.js +1 -206
  240. package/dist/project/participation-radar.js +1 -428
  241. package/dist/project/pipeline-actions.js +1 -109
  242. package/dist/project/project-store.js +1 -422
  243. package/dist/project/query.js +1 -153
  244. package/dist/project/reverse-mapping.d.ts +34 -0
  245. package/dist/project/reverse-mapping.js +1 -0
  246. package/dist/project/risk-aggregator.js +1 -295
  247. package/dist/project/rollback-policy.js +1 -290
  248. package/dist/project/semantic-assembler.js +1 -345
  249. package/dist/project/semantic-graph.js +1 -292
  250. package/dist/project/stage-gate.js +1 -369
  251. package/dist/project/substep-trace.js +1 -332
  252. package/dist/project/task-tracker.js +1 -78
  253. package/dist/role/derivation.d.ts +18 -0
  254. package/dist/role/derivation.js +1 -0
  255. package/dist/role/index.d.ts +5 -0
  256. package/dist/role/index.js +1 -0
  257. package/dist/role/model.d.ts +8 -0
  258. package/dist/role/model.js +1 -0
  259. package/dist/role/resolution.d.ts +11 -0
  260. package/dist/role/resolution.js +1 -0
  261. package/dist/role/types.d.ts +11 -0
  262. package/dist/role/types.js +1 -0
  263. package/dist/rules.js +1 -52
  264. package/dist/safety/confirm-gate.js +1 -88
  265. package/dist/safety/index.js +1 -3
  266. package/dist/safety/preview.js +1 -52
  267. package/dist/schema/call/allocation.js +1 -34
  268. package/dist/schema/call/arbitration.js +1 -113
  269. package/dist/schema/call/base.d.ts +15 -15
  270. package/dist/schema/call/base.js +1 -370
  271. package/dist/schema/call/bridge-handler.js +1 -265
  272. package/dist/schema/call/bridge.d.ts +7 -7
  273. package/dist/schema/call/bridge.js +1 -458
  274. package/dist/schema/call/contact.js +1 -37
  275. package/dist/schema/call/demand.js +1 -47
  276. package/dist/schema/call/guard.js +1 -161
  277. package/dist/schema/call/handler.js +1 -322
  278. package/dist/schema/call/index.js +1 -20
  279. package/dist/schema/call/machine.js +1 -193
  280. package/dist/schema/call/order.js +1 -35
  281. package/dist/schema/call/payment.js +1 -37
  282. package/dist/schema/call/permission-handler.js +1 -54
  283. package/dist/schema/call/permission.js +1 -105
  284. package/dist/schema/call/personal.js +1 -78
  285. package/dist/schema/call/progress.js +1 -47
  286. package/dist/schema/call/proof.js +1 -33
  287. package/dist/schema/call/repository.js +1 -77
  288. package/dist/schema/call/reward.js +1 -30
  289. package/dist/schema/call/semantic.js +1 -1679
  290. package/dist/schema/call/service.js +1 -184
  291. package/dist/schema/call/treasury.js +1 -71
  292. package/dist/schema/common/index.js +1 -407
  293. package/dist/schema/config/index.js +1 -68
  294. package/dist/schema/evaluation/index.d.ts +213 -16
  295. package/dist/schema/evaluation/index.js +1 -356
  296. package/dist/schema/index.js +1 -17
  297. package/dist/schema/intent-radar/index.d.ts +13 -13
  298. package/dist/schema/intent-radar/index.js +1 -89
  299. package/dist/schema/local/index.d.ts +21 -21
  300. package/dist/schema/local/index.js +1 -927
  301. package/dist/schema/local/wip.js +1 -187
  302. package/dist/schema/messenger/index.d.ts +7 -7
  303. package/dist/schema/messenger/index.js +1 -475
  304. package/dist/schema/operations.d.ts +7 -7
  305. package/dist/schema/operations.js +1 -520
  306. package/dist/schema/persona/index.d.ts +54 -54
  307. package/dist/schema/persona/index.js +1 -148
  308. package/dist/schema/project/index.d.ts +94 -48
  309. package/dist/schema/project/index.js +1 -2057
  310. package/dist/schema/query/index.d.ts +423 -7
  311. package/dist/schema/query/index.js +1 -1646
  312. package/dist/schema/schema-query/index.js +1 -104
  313. package/dist/schema/schema-version.js +1 -76
  314. package/dist/schema/sync-layer4.js +1 -286
  315. package/dist/schema/task-status.js +1 -36
  316. package/dist/schema/trust/index.js +1 -314
  317. package/dist/schema/utils/guard-parser.js +1 -419
  318. package/dist/schema/utils/guard-query-utils.js +1 -46
  319. package/dist/schema/utils/node-parser.js +1 -369
  320. package/dist/schema/utils/object-type-utils.js +1 -35
  321. package/dist/schema/utils/permission-index-utils.js +1 -7
  322. package/dist/schema/utils/permission-machine-check.js +1 -121
  323. package/dist/schema/utils/skills-recommendation.js +1 -77
  324. package/dist/schema-query/index.js +1 -810
  325. package/dist/schemas/account_operation.output.json +5 -2
  326. package/dist/schemas/bridge_operation.output.json +5 -2
  327. package/dist/schemas/evaluation_operation.output.json +112 -7
  328. package/dist/schemas/evaluation_operation.schema.json +93 -6
  329. package/dist/schemas/index.json +1 -1
  330. package/dist/schemas/intent_radar.output.json +4 -1
  331. package/dist/schemas/intent_radar.schema.json +4 -1
  332. package/dist/schemas/local_info_operation.output.json +5 -2
  333. package/dist/schemas/local_mark_operation.output.json +5 -2
  334. package/dist/schemas/messenger_operation.output.json +5 -2
  335. package/dist/schemas/onchain_events.output.json +5 -2
  336. package/dist/schemas/onchain_operations.output.json +5 -2
  337. package/dist/schemas/onchain_operations.schema.json +4 -4
  338. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  339. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  340. package/dist/schemas/onchain_operations_service.schema.json +1 -1
  341. package/dist/schemas/onchain_table_data.output.json +6 -3
  342. package/dist/schemas/persona_operation.output.json +4 -1
  343. package/dist/schemas/persona_operation.schema.json +4 -1
  344. package/dist/schemas/project_operation.output.json +28 -8
  345. package/dist/schemas/query_toolkit.output.json +8 -5
  346. package/dist/schemas/wowok_buildin_info.output.json +132 -0
  347. package/dist/schemas/wowok_buildin_info.schema.json +14 -0
  348. package/dist/telemetry/index.js +1 -112
  349. package/dist/telemetry/redact.js +1 -23
  350. package/dist/telemetry/storage.js +1 -80
  351. package/dist/tools/handlers/bridge.js +1 -1
  352. package/dist/tools/handlers/config.js +1 -74
  353. package/dist/tools/handlers/evaluation.js +1 -123
  354. package/dist/tools/handlers/file-export.js +1 -90
  355. package/dist/tools/handlers/intent-radar.js +1 -76
  356. package/dist/tools/handlers/local.js +1 -53
  357. package/dist/tools/handlers/messenger.js +1 -188
  358. package/dist/tools/handlers/onchain.js +1 -1180
  359. package/dist/tools/handlers/persona.js +1 -89
  360. package/dist/tools/handlers/project.js +1 -211
  361. package/dist/tools/handlers/query.js +1 -434
  362. package/dist/tools/handlers/schema-query.js +1 -176
  363. package/dist/tools/handlers/task-status.js +1 -26
  364. package/dist/tools/handlers/trust.js +1 -380
  365. package/dist/tools/handlers/wip.js +1 -90
  366. package/dist/tools/index.js +1 -1382
  367. package/dist/tools/retry.js +1 -85
  368. package/dist/tools/rules-hook.js +1 -23
  369. package/dist/tools/shared.js +1 -130
  370. package/dist/tools/types.js +1 -1
  371. package/dist/tools/upgrade-check.d.ts +19 -0
  372. package/dist/tools/upgrade-check.js +1 -0
  373. package/dist/tools/wip-deploy-assist.js +1 -306
  374. package/dist/tools/wrap.js +1 -500
  375. package/package.json +4 -2
@@ -1,463 +1 @@
1
- import { MAX_SHARING_COUNT, MAX_ALLOCATOR_COUNT } from "@wowok/wowok";
2
- export { MAX_ALLOCATOR_COUNT };
3
- export const ALLOCATION_MAX_SHARING_COUNT = MAX_SHARING_COUNT;
4
- export const ALLOCATION_MODE_AMOUNT = 0;
5
- export const ALLOCATION_MODE_RATE = 1;
6
- export const ALLOCATION_MODE_SURPLUS = 2;
7
- export const RATE_TOTAL_FULL = 10000;
8
- export const ALLOCATION_ERROR_CODES = {
9
- ERECIPIENT_IDENTIFIER_NOT_ADDRESS: 1,
10
- EALLOCATOR_COUNT_EXCEEDED: 2,
11
- ENO_ALLOCATOR: 3,
12
- ERATE_NOT_10000: 4,
13
- EMULTIPLE_SURPLUS: 5,
14
- ERATE_EXCEEDS_10000: 6,
15
- EINSUFFICIENT_BALANCE: 7,
16
- EALLOCATORS_EMPTY: 8,
17
- ENO_PAYMENT_INFO: 9,
18
- ESHARING_COUNT_EXCEEDED: 10,
19
- ESHARING_MODE_INVALID: 11,
20
- EAMOUNT_BELOW_THRESHOLD: 12,
21
- EAMOUNT_EXCEEDS_MAX: 13,
22
- };
23
- export const ORDER_ALLOCATION_ALREADY_SPECIFIED = "E_ALLOCATION_ALREADY_SPECIFIED";
24
- export const ALLOCATION_SCENES = [
25
- {
26
- id: "allocation_standard_three_way_split",
27
- name: "Standard three-way split (merchant / platform / logistics)",
28
- trigger_source: "service_order_allocators",
29
- distribution_strategy: "pure_rate",
30
- coin_type_note: "All three Treasury objects must use the same Coin<T> type as the Allocation",
31
- typical_allocator_count: 1,
32
- sharing_who_types: ["Entity"],
33
- modes_used: ["Rate"],
34
- guard_requirement: "required",
35
- non_zero_threshold: false,
36
- uses_max: false,
37
- common_patterns: [
38
- "Single Allocator, 3 Rate sharing items, sum(rates) === 10000",
39
- "Each sharing.who=Entity points to a Treasury address",
40
- "Guard verifies order.service binding (query 1563) to prevent cross-project bypass",
41
- "Guard verifies progress.current_node === 'Complete'",
42
- ],
43
- dependencies: ["Service", "Treasury", "Guard", "Order", "Progress", "Machine", "Payment"],
44
- key_constraints: [
45
- "F-A-05: sum(rates) === 10000 (pure Rate mode)",
46
- "Treasury Permission should match Service Permission (R-A-12)",
47
- "order_allocators immutable after Service publish (R-A-10)",
48
- ],
49
- recommended_templates: ["T-A-02"],
50
- },
51
- {
52
- id: "allocation_merchant_full_payment",
53
- name: "Merchant full payment (single recipient, 100%)",
54
- trigger_source: "service_order_allocators",
55
- distribution_strategy: "pure_rate",
56
- coin_type_note: "Simplest configuration — single Treasury or personal address",
57
- typical_allocator_count: 1,
58
- sharing_who_types: ["Entity"],
59
- modes_used: ["Rate"],
60
- guard_requirement: "single_relaxed",
61
- non_zero_threshold: false,
62
- uses_max: false,
63
- common_patterns: [
64
- "Single Allocator, 1 Rate sharing = 10000",
65
- "Guard only verifies order status (no complex conditions)",
66
- "who=Entity can be either Treasury or personal wallet",
67
- ],
68
- dependencies: ["Service", "Guard", "Order", "Payment"],
69
- key_constraints: [
70
- "Simplest allocation configuration",
71
- "No multi-party coordination required",
72
- ],
73
- recommended_templates: ["T-A-01"],
74
- },
75
- {
76
- id: "allocation_refund_first_surplus_to_merchant",
77
- name: "Refund first + surplus to merchant (Amount + Surplus hybrid)",
78
- trigger_source: "service_order_allocators",
79
- distribution_strategy: "amount_plus_surplus",
80
- coin_type_note: "Refund amount must match Coin<T> precision",
81
- typical_allocator_count: 1,
82
- sharing_who_types: ["Entity"],
83
- modes_used: ["Amount", "Surplus"],
84
- guard_requirement: "required",
85
- non_zero_threshold: true,
86
- uses_max: false,
87
- common_patterns: [
88
- "Single Allocator, 2 sharing items",
89
- "sharing[0]: Amount=refund_value, who=Entity(customer_address)",
90
- "sharing[1]: Surplus, who=Entity(merchant_treasury)",
91
- "fix = refund_value (cached Amount sum)",
92
- "threshold = refund_value (ensure sufficient balance for Amount)",
93
- ],
94
- dependencies: ["Service", "Treasury", "Guard", "Order", "Payment"],
95
- key_constraints: [
96
- "F-A-04: at most 1 Surplus per Allocator",
97
- "F-A-07: fix >= threshold (Amount sum must cover threshold)",
98
- "fix must precisely match the refund amount",
99
- ],
100
- recommended_templates: ["T-A-03"],
101
- },
102
- {
103
- id: "allocation_treasury_personal_alternatives",
104
- name: "Treasury + Personal alternative strategies (caller-specified guard)",
105
- trigger_source: "service_order_allocators",
106
- distribution_strategy: "first_match_alternatives",
107
- coin_type_note: "Both target addresses must accept the same Coin<T>",
108
- typical_allocator_count: 2,
109
- sharing_who_types: ["Entity"],
110
- modes_used: ["Rate"],
111
- guard_requirement: "multiple_unique",
112
- non_zero_threshold: false,
113
- uses_max: false,
114
- common_patterns: [
115
- "2 Allocators, each with 1 Rate=10000 sharing",
116
- "Allocator[0]: guard=guard_treasury, who=Entity(treasury_address)",
117
- "Allocator[1]: guard=guard_personal, who=Entity(personal_address)",
118
- "Two Guard objects must be different addresses (R-A-11)",
119
- "caller-specified guard: caller selects Treasury or Personal path via alloc_by_guard; passport::result_for_guard hard-validates (failure aborts with E_VERIFY_FAILED; caller must switch guard and retry)",
120
- ],
121
- dependencies: ["Service", "Treasury", "Guard", "Order", "Payment"],
122
- key_constraints: [
123
- "F-A-14: allocators[].guard must be unique",
124
- "Treasury Permission should match Service Permission (R-A-12)",
125
- "Guard A and Guard B may share root/table but must differ in description",
126
- ],
127
- recommended_templates: ["T-A-04"],
128
- },
129
- {
130
- id: "allocation_tiered_by_order_amount",
131
- name: "Tiered split by order amount (multi-Allocator amount-threshold switch)",
132
- trigger_source: "service_order_allocators",
133
- distribution_strategy: "tiered_by_amount",
134
- coin_type_note: "Amount threshold uses Coin<T> smallest unit (e.g. MIST for WOW)",
135
- typical_allocator_count: 2,
136
- sharing_who_types: ["Entity"],
137
- modes_used: ["Rate"],
138
- guard_requirement: "multiple_unique",
139
- non_zero_threshold: false,
140
- uses_max: false,
141
- common_patterns: [
142
- "2 Allocators triggered by mutually exclusive Guard conditions",
143
- "Allocator[0]: guard verifies order.amount < threshold, Rate=10000 to merchant",
144
- "Allocator[1]: guard verifies order.amount >= threshold, Rate=8000/2000 split",
145
- "caller-specified guard: caller selects the matching Allocator based on order amount; allocator order is irrelevant",
146
- "Guard queries order.amount (query 1561)",
147
- ],
148
- dependencies: ["Service", "Treasury", "Guard", "Order", "Payment"],
149
- key_constraints: [
150
- "Guard conditions must be mutually exclusive (R-A-4-02 design clarity)",
151
- "Caller must select correct guard based on order.amount (no auto-fallback)",
152
- ],
153
- recommended_templates: ["T-A-05"],
154
- },
155
- {
156
- id: "allocation_dynamic_recipient",
157
- name: "Multi-role split with dynamic recipient (GuardIdentifier)",
158
- trigger_source: "service_order_allocators",
159
- distribution_strategy: "dynamic_recipient",
160
- coin_type_note: "Passport table must contain address-typed entry at the referenced identifier",
161
- typical_allocator_count: 1,
162
- sharing_who_types: ["Entity", "GuardIdentifier"],
163
- modes_used: ["Rate"],
164
- guard_requirement: "required",
165
- non_zero_threshold: false,
166
- uses_max: false,
167
- common_patterns: [
168
- "Single Allocator, 3 Rate sharing items",
169
- "sharing[0]: Rate=8000, who=Entity(merchant_treasury)",
170
- "sharing[1]: Rate=1000, who=Entity(platform_treasury)",
171
- "sharing[2]: Rate=1000, who=GuardIdentifier(0) — resolves from Passport table",
172
- "Customer submits Passport with referrer address at identifier=0",
173
- ],
174
- dependencies: ["Service", "Treasury", "Guard", "Passport", "Order", "Payment"],
175
- key_constraints: [
176
- "F-A-13: Passport table[identifier] must be address type (else ERECIPIENT_IDENTIFIER_NOT_ADDRESS)",
177
- "Guard must verify Passport completeness",
178
- "Customer order must include Passport with referrer address",
179
- ],
180
- recommended_templates: ["T-A-06"],
181
- },
182
- {
183
- id: "allocation_arbitration_fees",
184
- name: "Arbitration fees split (arbitrator / platform)",
185
- trigger_source: "arbitration_fees",
186
- distribution_strategy: "pure_rate",
187
- coin_type_note: "Coin<T> must match Arbitration's fee Coin type",
188
- typical_allocator_count: 1,
189
- sharing_who_types: ["Entity"],
190
- modes_used: ["Rate"],
191
- guard_requirement: "required",
192
- non_zero_threshold: false,
193
- uses_max: false,
194
- common_patterns: [
195
- "Triggered by Arbitration.fees_alloc (permission 365) or fees_alloc_with_passport",
196
- "Single Allocator, 2 Rate sharing items: 8000 arbitrator / 2000 platform",
197
- "payment_info reuses Arbitration's payment_info",
198
- "Caller must hold ARBITRATION_FEES_ALLOC=365 permission",
199
- ],
200
- dependencies: ["Arbitration", "Treasury", "Guard", "Payment"],
201
- key_constraints: [
202
- "Independent from Service-order Allocation",
203
- "Requires ARBITRATION_FEES_ALLOC=365 permission",
204
- ],
205
- recommended_templates: ["T-A-08"],
206
- },
207
- {
208
- id: "allocation_refund_to_order",
209
- name: "Refund Allocator (100% to Order object)",
210
- trigger_source: "service_order_allocators",
211
- distribution_strategy: "refund_to_order",
212
- coin_type_note: "who=Entity must be the Order object address (NOT a personal wallet)",
213
- typical_allocator_count: 1,
214
- sharing_who_types: ["Entity"],
215
- modes_used: ["Rate"],
216
- guard_requirement: "required",
217
- non_zero_threshold: false,
218
- uses_max: false,
219
- common_patterns: [
220
- "Single Allocator, 1 Rate=10000 sharing",
221
- "who=Entity(order_address) — funds flow back to Order, not personal wallet",
222
- "Guard verifies customer refund request and eligibility",
223
- "Customer-side risk assessment adds 8-point weight (customer/risk-assessment.ts)",
224
- ],
225
- dependencies: ["Service", "Guard", "Order", "Payment"],
226
- key_constraints: [
227
- "who=Entity MUST be Order object address (not personal address)",
228
- "Customer due-diligence rewards this configuration (8-point weight)",
229
- "Refund funds return to Order for downstream handling",
230
- ],
231
- recommended_templates: ["T-A-07"],
232
- },
233
- {
234
- id: "allocation_max_capped_retain",
235
- name: "Max-capped allocation (retain residual balance)",
236
- trigger_source: "service_order_allocators",
237
- distribution_strategy: "max_capped",
238
- coin_type_note: "max field uses Coin<T> smallest unit",
239
- typical_allocator_count: 1,
240
- sharing_who_types: ["Entity"],
241
- modes_used: ["Amount", "Rate"],
242
- guard_requirement: "required",
243
- non_zero_threshold: true,
244
- uses_max: true,
245
- common_patterns: [
246
- "Single Allocator with max field set",
247
- "max triple role: Amount cap + Rate base + Surplus cap",
248
- "Amount sharing consumes fix; Rate sharing uses (max - fix) as base",
249
- "Residual balance remains in Allocation for subsequent alloc() calls",
250
- ],
251
- dependencies: ["Service", "Treasury", "Guard", "Order", "Payment"],
252
- key_constraints: [
253
- "F-A-08: Amount sum <= max (EAMOUNT_EXCEEDS_MAX)",
254
- "max - fix becomes Rate base (NOT balance - fix)",
255
- "Residual balance may be claimed by re-triggering alloc()",
256
- ],
257
- recommended_templates: [],
258
- },
259
- {
260
- id: "allocation_multi_node_trigger",
261
- name: "Multi-Machine-node triggered allocation (Complete / Refund / Lost)",
262
- trigger_source: "service_order_allocators",
263
- distribution_strategy: "multi_node_trigger",
264
- coin_type_note: "All Allocators share the same Allocation's Coin<T>",
265
- typical_allocator_count: 3,
266
- sharing_who_types: ["Entity"],
267
- modes_used: ["Rate"],
268
- guard_requirement: "multiple_unique",
269
- non_zero_threshold: false,
270
- uses_max: false,
271
- common_patterns: [
272
- "3 Allocators mapped to Machine terminal nodes (Complete/Refund/Lost)",
273
- "Each Allocator's Guard verifies progress.current_node == <node_name>",
274
- "Mutually exclusive Guard conditions (only one terminal node active at a time)",
275
- "Machine.required_allocators[] describes each trigger_node mapping",
276
- ],
277
- dependencies: ["Service", "Treasury", "Guard", "Order", "Progress", "Machine", "Payment"],
278
- key_constraints: [
279
- "Guard conditions must be mutually exclusive",
280
- "Sequence-sensitive: business-flow order",
281
- "Machine.required_allocators[trigger_node] must map to Allocator indices",
282
- ],
283
- recommended_templates: [],
284
- },
285
- {
286
- id: "allocation_standalone_periodic_split",
287
- name: "Standalone periodic split (investment dividends / shared income)",
288
- trigger_source: "standalone",
289
- distribution_strategy: "periodic_split",
290
- coin_type_note: "Coin<T> must match the asset being distributed (e.g. profit token)",
291
- typical_allocator_count: 1,
292
- sharing_who_types: ["Entity"],
293
- modes_used: ["Rate"],
294
- guard_requirement: "required",
295
- non_zero_threshold: false,
296
- uses_max: false,
297
- common_patterns: [
298
- "Single Allocator, N Rate sharing items, sum(rates) === 10000",
299
- "Each sharing.who=Entity points to a beneficiary wallet (not Treasury)",
300
- "Guard verifies time-based trigger (e.g. context(Clock).timestamp >= next_release) or signer authorization",
301
- "User calls receive() to deposit funds, then alloc() to trigger distribution",
302
- "No Service/Order/Progress/Machine context required",
303
- ],
304
- dependencies: ["Treasury", "Guard", "Payment"],
305
- key_constraints: [
306
- "F-A-05: sum(rates) === 10000 (pure Rate mode)",
307
- "R-A-3-04: standalone mode has no Service-layer access control — Guard + Passport MUST be sufficient",
308
- "Caller is fully responsible for receive → alloc lifecycle (no auto-trigger)",
309
- "Guard should bind Signer to prevent unauthorized alloc() calls",
310
- ],
311
- recommended_templates: ["T-A-09"],
312
- },
313
- {
314
- id: "allocation_standalone_vesting",
315
- name: "Standalone vesting release (time-locked multi-stage unlock)",
316
- trigger_source: "standalone",
317
- distribution_strategy: "time_locked_vesting",
318
- coin_type_note: "Coin<T> must match the vested asset (e.g. locked team tokens)",
319
- typical_allocator_count: 3,
320
- sharing_who_types: ["Entity"],
321
- modes_used: ["Amount", "Rate", "Surplus"],
322
- guard_requirement: "multiple_unique",
323
- non_zero_threshold: true,
324
- uses_max: true,
325
- common_patterns: [
326
- "N Allocators, each mapped to a vesting stage (e.g. 25% at month 12, 25% at month 24, 50% surplus at month 36)",
327
- "Each Allocator's Guard verifies context(Clock).timestamp >= stage_unlock_time",
328
- "Amount sharing per stage with max field capping the cumulative release",
329
- "Final Allocator uses Surplus to drain remaining balance after last vesting stage",
330
- "Mutually exclusive Guard conditions (only one stage active at a time, based on timestamp)",
331
- "User calls receive() to deposit locked tokens, then alloc() at each vesting milestone",
332
- ],
333
- dependencies: ["Treasury", "Guard", "Passport", "Payment"],
334
- key_constraints: [
335
- "F-A-04: at most 1 Surplus per Allocator (final stage uses Surplus to drain remainder)",
336
- "F-A-08: Amount sum <= max (EAMOUNT_EXCEEDS_MAX)",
337
- "R-A-3-04: standalone mode has no Service-layer access control — Guard time-lock MUST be enforced",
338
- "Guard conditions must be mutually exclusive by timestamp (R-A-4-02)",
339
- "Caller must wait for time-lock expiry before alloc() succeeds; otherwise alloc() silently returns (R-A-4-01)",
340
- ],
341
- recommended_templates: ["T-A-10"],
342
- },
343
- ];
344
- export const ALLOCATION_LEDGER_VERSION = "1.0.0";
345
- export function getScenesByTriggerSource(source) {
346
- return ALLOCATION_SCENES.filter(s => s.trigger_source === source);
347
- }
348
- export function getScenesByMode(mode) {
349
- return ALLOCATION_SCENES.filter(s => s.modes_used.includes(mode));
350
- }
351
- export function getScenesByStrategy(strategy) {
352
- return ALLOCATION_SCENES.filter(s => s.distribution_strategy === strategy);
353
- }
354
- export function findSceneById(id) {
355
- return ALLOCATION_SCENES.find(s => s.id === id);
356
- }
357
- export function inferSceneFromIntent(intent) {
358
- const lower = intent.toLowerCase();
359
- if (lower.includes("arbitration") || lower.includes("fees_alloc")) {
360
- return findSceneById("allocation_arbitration_fees");
361
- }
362
- if (lower.includes("standalone") || lower.includes("periodic split") ||
363
- lower.includes("investment dividend") || lower.includes("shared income") || lower.includes("dividend")) {
364
- return findSceneById("allocation_standalone_periodic_split");
365
- }
366
- if (lower.includes("vesting") || lower.includes("time-lock") || lower.includes("unlock period") ||
367
- lower.includes("locked release") || lower.includes("token unlock")) {
368
- return findSceneById("allocation_standalone_vesting");
369
- }
370
- if (lower.includes("refund")) {
371
- if (lower.includes("order") || lower.includes("100%")) {
372
- return findSceneById("allocation_refund_to_order");
373
- }
374
- if (lower.includes("surplus") || lower.includes("merchant")) {
375
- return findSceneById("allocation_refund_first_surplus_to_merchant");
376
- }
377
- }
378
- if (lower.includes("alternative") || lower.includes("priority") || (lower.includes("treasury") && lower.includes("personal"))) {
379
- return findSceneById("allocation_treasury_personal_alternatives");
380
- }
381
- if (lower.includes("tiered") || lower.includes("threshold switch")) {
382
- return findSceneById("allocation_tiered_by_order_amount");
383
- }
384
- if (lower.includes("dynamic recipient") || lower.includes("referrer") || lower.includes("guardidentifier")) {
385
- return findSceneById("allocation_dynamic_recipient");
386
- }
387
- if (lower.includes("retain") || lower.includes("max")) {
388
- return findSceneById("allocation_max_capped_retain");
389
- }
390
- if (lower.includes("multi-node") || lower.includes("multi machine") || lower.includes("multi_node")) {
391
- return findSceneById("allocation_multi_node_trigger");
392
- }
393
- const roleCount = (intent.match(/%/g) || []).length;
394
- if (roleCount <= 1) {
395
- return findSceneById("allocation_merchant_full_payment");
396
- }
397
- if (roleCount >= 2) {
398
- return findSceneById("allocation_standard_three_way_split");
399
- }
400
- return undefined;
401
- }
402
- export function getAllScenes() {
403
- return [...ALLOCATION_SCENES];
404
- }
405
- export function getScenesCount() {
406
- return ALLOCATION_SCENES.length;
407
- }
408
- export function allocationModeToNumber(mode) {
409
- switch (mode) {
410
- case "Amount": return ALLOCATION_MODE_AMOUNT;
411
- case "Rate": return ALLOCATION_MODE_RATE;
412
- case "Surplus": return ALLOCATION_MODE_SURPLUS;
413
- }
414
- }
415
- export function allocationModeFromNumber(n) {
416
- switch (n) {
417
- case ALLOCATION_MODE_AMOUNT: return "Amount";
418
- case ALLOCATION_MODE_RATE: return "Rate";
419
- case ALLOCATION_MODE_SURPLUS: return "Surplus";
420
- default: throw new Error(`Invalid AllocationMode number: ${n}`);
421
- }
422
- }
423
- export function getRecipientType(who) {
424
- if ("GuardIdentifier" in who)
425
- return "GuardIdentifier";
426
- if ("Entity" in who)
427
- return "Entity";
428
- return "Signer";
429
- }
430
- export function isSignerRecipient(who) {
431
- return "Signer" in who;
432
- }
433
- export function isEntityRecipient(who) {
434
- return "Entity" in who;
435
- }
436
- export function isGuardIdentifierRecipient(who) {
437
- return "GuardIdentifier" in who;
438
- }
439
- export function getErrorName(code) {
440
- for (const [name, c] of Object.entries(ALLOCATION_ERROR_CODES)) {
441
- if (c === code)
442
- return name;
443
- }
444
- return undefined;
445
- }
446
- export function getErrorDescription(code) {
447
- const descriptions = {
448
- 1: "GuardIdentifier resolved value is not an address type",
449
- 2: "Allocator count exceeds MAX_ALLOCATOR_COUNT (100)",
450
- 3: "No Allocator in the allocators vector",
451
- 4: "Pure Rate mode sum != 10000 (no Surplus to absorb remainder)",
452
- 5: "Multiple Surplus sharing in a single Allocator",
453
- 6: "Rate + Surplus sum > 10000",
454
- 7: "balance < threshold (insufficient balance to trigger alloc)",
455
- 8: "allocators.allocators is empty",
456
- 9: "payment_info is None when alloc() is called",
457
- 10: "sharing count exceeds MAX_SHARING_COUNT (100)",
458
- 11: "sharing mode is not 0 (Amount) / 1 (Rate) / 2 (Surplus)",
459
- 12: "Amount sum (fix) < threshold",
460
- 13: "Amount sum (fix) > max",
461
- };
462
- return descriptions[code];
463
- }
1
+ import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20passport::result_for_guard\x20hard-validates\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20Arbitration.fees_alloc\x20(permission\x20365)\x20or\x20fees_alloc_with_passport','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(customer/risk-assessment.ts)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','max\x20-\x20fix\x20becomes\x20Rate\x20base\x20(NOT\x20balance\x20-\x20fix)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees_alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max'};return b[a];}