@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,609 +1 @@
1
- export const SERVICE_PERMISSIONS = [
2
- { index: 300, name: "SERVICE_NEW", description: "Create new Service", governed_operation: "service::new", post_publish_mutability: "na" },
3
- { index: 301, name: "SERVICE_DESCRIPTION", description: "Modify Service description", governed_operation: "service::description_set", post_publish_mutability: "mutable" },
4
- { index: 303, name: "SERVICE_LOCATION", description: "Set Service location/URL", governed_operation: "service::location_set", post_publish_mutability: "mutable" },
5
- { index: 304, name: "SERVICE_REPOSITORY", description: "Add/remove Repository references", governed_operation: "service::repository_add/remove/clear", post_publish_mutability: "mutable" },
6
- { index: 305, name: "SERVICE_SALES", description: "Add/set/remove/clear sales items", governed_operation: "service::sales_add/set/remove/clear", post_publish_mutability: "mutable" },
7
- { index: 306, name: "SERVICE_MACHINE", description: "Bind/unbind Machine workflow template", governed_operation: "service::machine_set/machine_none", post_publish_mutability: "immutable" },
8
- { index: 307, name: "SERVICE_BUY_GUARD", description: "Set/clear buy Guard (post-publish mutable)", governed_operation: "service::buy_guard_set/buy_guard_none", post_publish_mutability: "mutable" },
9
- { index: 308, name: "SERVICE_ARBITRATION", description: "Add/remove Arbitration references", governed_operation: "service::arbitration_add/remove/clear", post_publish_mutability: "immutable" },
10
- { index: 309, name: "SERVICE_CUSTOMER_INFO_REQUIRED", description: "Set customer required info fields", governed_operation: "service::customer_required_set", post_publish_mutability: "mutable" },
11
- { index: 310, name: "SERVICE_PAUSE", description: "Pause/resume Service (block new orders)", governed_operation: "service::pause", post_publish_mutability: "mutable" },
12
- { index: 311, name: "SERVICE_PUBLISH", description: "Publish Service (IRREVERSIBLE)", governed_operation: "service::publish", post_publish_mutability: "one_shot" },
13
- { index: 312, name: "SERVICE_DISCOUNT", description: "Issue/discount_destroy discount coupons", governed_operation: "service::discount", post_publish_mutability: "mutable" },
14
- { index: 313, name: "SERVICE_ORDER_ALLOCATOR", description: "Set order allocator strategy", governed_operation: "service::order_allocators_set", post_publish_mutability: "immutable" },
15
- { index: 314, name: "SERVICE_COMPENSATION_FUND_WITHDRAW", description: "Withdraw compensation fund (lock_duration)", governed_operation: "service::compensation_fund_withdraw", post_publish_mutability: "locked_by_duration" },
16
- { index: 315, name: "SERVICE_COMPENSATION_FUND_DEPOSIT", description: "Deposit to compensation fund", governed_operation: "service::compensation_fund_add", post_publish_mutability: "mutable" },
17
- { index: 316, name: "SERVICE_COMPENSATION_FUND_RECEIVE", description: "Receive compensation fund (lock_duration)", governed_operation: "service::compensation_fund_receive", post_publish_mutability: "locked_by_duration" },
18
- { index: 317, name: "SERVICE_COMPENSATION_LOCK_DURATION_ADD", description: "Extend setting_lock_duration (only-increase)", governed_operation: "service::setting_lock_duration_add", post_publish_mutability: "mutable" },
19
- { index: 318, name: "SERVICE_REWARD", description: "Add/remove Reward references (locked)", governed_operation: "service::reward_add/remove/clear", post_publish_mutability: "locked_by_duration" },
20
- { index: 319, name: "SERVICE_OWNER_RECEIVE", description: "Receive Payment/objects to owner", governed_operation: "service::owner_receive", post_publish_mutability: "mutable" },
21
- { index: 320, name: "SERVICE_UM", description: "Bind/unbind Contact as UM", governed_operation: "service::um_set/um_none", post_publish_mutability: "mutable" },
22
- ];
23
- export const SERVICE_ORDER_FLOW_STAGES = [
24
- {
25
- stage: 1,
26
- name: "pre_check",
27
- preconditions: [
28
- "Service.bPublished == true (else E_SERVICE_NOT_PUBLISHED)",
29
- "Service.bPaused == false (else E_SERVICE_PAUSED)",
30
- "buy_guard (if set) added to guards[] list for verification",
31
- ],
32
- side_effects: [],
33
- always_executed: true,
34
- },
35
- {
36
- stage: 2,
37
- name: "wip_verify",
38
- preconditions: [
39
- "buy.items non-empty",
40
- "Each item.name matches a sale in Service.sales (else E_SALE_NOT_FOUND)",
41
- "sale.suspension == false (else E_SALE_SUSPENDED)",
42
- ],
43
- side_effects: [
44
- "If buyer passes empty wip_hash, SDK auto-fills with sale.wip_hash",
45
- "verifiedWipUrls Set avoids re-verifying same WIP URL across items",
46
- "verify_wip() fetches WIP file and compares hash (else E_WIP_HASH_NOT_MATCH)",
47
- ],
48
- always_executed: true,
49
- },
50
- {
51
- stage: 3,
52
- name: "quote",
53
- preconditions: [
54
- "All items have valid sale + wip_hash match",
55
- "stock >= purchase quantity (else E_STOCK_INSUFFICIENT)",
56
- "discount object (if used) is valid and unexpired",
57
- ],
58
- side_effects: [
59
- "quote_imp() computes total price (with discount if applicable)",
60
- "⚠️ Stock is deducted (split) — side effect is NOT auto-rolled-back on later failure",
61
- "service::quote or service::quote_with_discount MoveCall",
62
- ],
63
- always_executed: true,
64
- },
65
- {
66
- stage: 4,
67
- name: "create_order",
68
- preconditions: ["Quote object from stage 3", "Registrar + Clock objects available"],
69
- side_effects: [
70
- "service::buy or service::buy_with_passport MoveCall",
71
- "Order object created (builder=customer, service=Service.id)",
72
- "Order.id recorded for stages 5-7",
73
- ],
74
- always_executed: true,
75
- },
76
- {
77
- stage: 5,
78
- name: "create_allocation",
79
- preconditions: [
80
- "Service.order_allocators is Some (configured)",
81
- "Order from stage 4",
82
- "CoinParam for total_pay matches Service<T> type",
83
- ],
84
- side_effects: [
85
- "service::order_allocation MoveCall",
86
- "Allocation object created (first-match-wins fund distribution)",
87
- "Order.allocation = Allocation address",
88
- ],
89
- always_executed: true,
90
- },
91
- {
92
- stage: 6,
93
- name: "create_progress",
94
- preconditions: ["Service.machine is Some (machine bound)", "Order from stage 4", "Machine from Service.machine"],
95
- side_effects: [
96
- "service::order_progress MoveCall",
97
- "Progress object created (Progress.machine = Service.machine, Progress.task = Order.id)",
98
- ],
99
- always_executed: false,
100
- },
101
- {
102
- stage: 7,
103
- name: "post_actions",
104
- preconditions: ["Order/Allocation/Progress objects from stages 4-6"],
105
- side_effects: [
106
- "agent_set (if order_new.agents provided)",
107
- "order_required_info_update (if order_required_info provided)",
108
- "owner_change (if transfer provided — sets new Order owner)",
109
- "namedNewOrder / namedNewAllocation / namedNewProgress (local naming)",
110
- ],
111
- always_executed: false,
112
- },
113
- {
114
- stage: 8,
115
- name: "return_result",
116
- preconditions: ["All preceding stages succeeded"],
117
- side_effects: [
118
- "Returns BuyResult { order, allocation?, progress? }",
119
- "Caller proceeds to sign + submit transaction",
120
- ],
121
- always_executed: true,
122
- },
123
- ];
124
- export const SERVICE_CROSS_OBJECT_BINDINGS = [
125
- { object: "Machine", field: "machine", required: false, locked_after_publish: true, notes: "Workflow template; post-publish immutable (F-S-20). Progress.machine inherits this value." },
126
- { object: "Guard", field: "buy_guard", required: false, locked_after_publish: false, notes: "Buyer eligibility guard; post-publish STILL MUTABLE (unusual — see F-S-26)" },
127
- { object: "Allocation", field: "order_allocators", required: true, locked_after_publish: true, notes: "Order fund distribution strategy; publish prerequisite (F-S-18). Post-publish immutable (F-S-22)." },
128
- { object: "Arbitration", field: "arbitrations", required: false, locked_after_publish: true, notes: "Dispute handlers; required if compensation_fund > 0 (F-S-19). Post-publish immutable (F-S-21)." },
129
- { object: "Repository", field: "repositories", required: false, locked_after_publish: false, notes: "Shared data stores; mutable post-publish" },
130
- { object: "Reward", field: "rewards", required: false, locked_after_publish: false, notes: "Marketing incentives; mutable but locked by setting_lock_duration (F-S-24)" },
131
- { object: "Contact", field: "um", required: false, locked_after_publish: false, notes: "User Manager (Contact object); mutable post-publish" },
132
- { object: "Treasury", field: "(indirect via order_allocators.sharing.who=Entity)", required: false, locked_after_publish: false, notes: "Treasury is referenced by Allocation.sharing.who, not by Service directly" },
133
- ];
134
- export const SERVICE_SCENES = [
135
- {
136
- id: "service_retail",
137
- name: "Retail e-commerce Service",
138
- category: "retail",
139
- permission_index_range: "300-320",
140
- builtin_indexes: SERVICE_PERMISSIONS,
141
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
142
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
143
- owner_operations: ["um_set", "builder (transfer)"],
144
- admin_operations: ["description_set", "location_set", "customer_required_set"],
145
- permission_index_operations: [
146
- "service::publish (311)",
147
- "service::pause (310)",
148
- "service::sales_add/set/remove/clear (305)",
149
- "service::order_allocators_set (313)",
150
- "service::buy_guard_set (307)",
151
- "service::discount (312)",
152
- ],
153
- mutable_after_publish: {
154
- machine: false, arbitrations: false, order_allocators: false,
155
- buy_guard: true, rewards: "locked_by_duration",
156
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
157
- sales: true, description: true, location: true, repositories: true,
158
- customer_required: true, discount: true, um: true, pause: true,
159
- },
160
- publish_prerequisites: [
161
- "order_allocators must be set (F-S-18, E_NO_ALLOCATOR)",
162
- "If compensation_fund > 0, arbitrations must be non-empty (F-S-19)",
163
- ],
164
- common_patterns: [
165
- "Multi-tier pricing via sales[] (Standard/Premium/Enterprise)",
166
- "WIP hash per sale item for tamper-proof product info",
167
- "buy_guard for KYC whitelist during pre-sale, then null for public sale",
168
- "compensation_fund deposited before publish + arbitrations configured",
169
- ],
170
- recommended_templates: ["T-S-01", "T-S-06"],
171
- },
172
- {
173
- id: "service_rental",
174
- name: "Rental Service (short/long-term)",
175
- category: "rental",
176
- permission_index_range: "300-320",
177
- builtin_indexes: SERVICE_PERMISSIONS,
178
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
179
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
180
- owner_operations: ["um_set", "builder (transfer)"],
181
- admin_operations: ["description_set", "location_set"],
182
- permission_index_operations: [
183
- "service::publish (311)",
184
- "service::sales_add/set (305)",
185
- "service::machine_set (306) — for rental workflow",
186
- "service::arbitration_add (308) — for deposit disputes",
187
- ],
188
- mutable_after_publish: {
189
- machine: false, arbitrations: false, order_allocators: false,
190
- buy_guard: true, rewards: "locked_by_duration",
191
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
192
- sales: true, description: true, location: true, repositories: true,
193
- customer_required: true, discount: true, um: true, pause: true,
194
- },
195
- publish_prerequisites: [
196
- "order_allocators must be set",
197
- "machine recommended (rental workflow with deposit/return stages)",
198
- "arbitrations recommended (deposit refund disputes)",
199
- ],
200
- common_patterns: [
201
- "Machine workflow with 'Deposit → Use → Return → Refund' nodes",
202
- "compensation_fund holds deposit guarantees",
203
- "buy_guard verifies renter identity/KYC",
204
- "stock=1 per rental item (unique items)",
205
- ],
206
- recommended_templates: ["T-S-02", "T-S-04"],
207
- },
208
- {
209
- id: "service_subscription",
210
- name: "Subscription Service (recurring)",
211
- category: "subscription",
212
- permission_index_range: "300-320",
213
- builtin_indexes: SERVICE_PERMISSIONS,
214
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
215
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
216
- owner_operations: ["um_set", "builder (transfer)"],
217
- admin_operations: ["description_set", "location_set"],
218
- permission_index_operations: [
219
- "service::publish (311)",
220
- "service::sales_add/set (305)",
221
- "service::discount (312) — promotional rates",
222
- "service::reward_add (318) — loyalty rewards",
223
- ],
224
- mutable_after_publish: {
225
- machine: false, arbitrations: false, order_allocators: false,
226
- buy_guard: true, rewards: "locked_by_duration",
227
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
228
- sales: true, description: true, location: true, repositories: true,
229
- customer_required: true, discount: true, um: true, pause: true,
230
- },
231
- publish_prerequisites: ["order_allocators must be set"],
232
- common_patterns: [
233
- "Tiered plans (Free/Pro/Enterprise) as sales[]",
234
- "Discount coupons for trial periods",
235
- "Rewards for long-term subscribers",
236
- "Renewal handled by repeat orders (no native recurring billing)",
237
- ],
238
- recommended_templates: ["T-S-03"],
239
- },
240
- {
241
- id: "service_workflow",
242
- name: "Workflow-bound Service (machine-bound)",
243
- category: "workflow",
244
- permission_index_range: "300-320",
245
- builtin_indexes: SERVICE_PERMISSIONS,
246
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
247
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
248
- owner_operations: ["um_set", "builder (transfer)"],
249
- admin_operations: ["description_set", "location_set"],
250
- permission_index_operations: [
251
- "service::machine_set (306) — bind workflow",
252
- "service::publish (311)",
253
- "service::order_allocators_set (313)",
254
- ],
255
- mutable_after_publish: {
256
- machine: false, arbitrations: false, order_allocators: false,
257
- buy_guard: true, rewards: "locked_by_duration",
258
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
259
- sales: true, description: true, location: true, repositories: true,
260
- customer_required: true, discount: true, um: true, pause: true,
261
- },
262
- publish_prerequisites: [
263
- "order_allocators must be set",
264
- "machine must be published before binding",
265
- "machine recommended for any multi-stage service delivery",
266
- ],
267
- common_patterns: [
268
- "Machine defines Pay → Confirm → Deliver → Sign-off nodes",
269
- "Progress created per order (stage 6 of buy flow)",
270
- "Named operators assigned per Forward in Machine",
271
- "Service.paused does NOT affect already-created Progress (existing orders continue)",
272
- ],
273
- recommended_templates: ["T-S-04"],
274
- },
275
- {
276
- id: "service_arbitration",
277
- name: "Arbitration-bound Service (dispute-ready)",
278
- category: "arbitration",
279
- permission_index_range: "300-320",
280
- builtin_indexes: SERVICE_PERMISSIONS,
281
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
282
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
283
- owner_operations: ["um_set", "builder (transfer)"],
284
- admin_operations: ["description_set"],
285
- permission_index_operations: [
286
- "service::arbitration_add (308)",
287
- "service::compensation_fund_add (315)",
288
- "service::setting_lock_duration_add (317)",
289
- "service::publish (311)",
290
- ],
291
- mutable_after_publish: {
292
- machine: false, arbitrations: false, order_allocators: false,
293
- buy_guard: true, rewards: "locked_by_duration",
294
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
295
- sales: true, description: true, location: true, repositories: true,
296
- customer_required: true, discount: true, um: true, pause: true,
297
- },
298
- publish_prerequisites: [
299
- "If compensation_fund > 0, arbitrations must be non-empty (F-S-19)",
300
- "Arbitration objects must be created before binding",
301
- "compensation_fund_add before publish recommended (else post-publish deposit still possible)",
302
- ],
303
- common_patterns: [
304
- "2-3 Arbitration objects (different arb committees for different dispute types)",
305
- "compensation_fund deposited as % of expected order volume",
306
- "setting_lock_duration extended by owner to build customer trust",
307
- "compensation_claim triggered by arbitration result (not by Service directly)",
308
- ],
309
- recommended_templates: ["T-S-05", "T-S-06"],
310
- },
311
- {
312
- id: "service_compensation_fund",
313
- name: "Compensation Fund Service (embedded balance)",
314
- category: "compensation_fund",
315
- permission_index_range: "300-320",
316
- builtin_indexes: SERVICE_PERMISSIONS,
317
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
318
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
319
- owner_operations: ["um_set", "builder (transfer)"],
320
- admin_operations: ["description_set"],
321
- permission_index_operations: [
322
- "service::compensation_fund_add (315) — deposit",
323
- "service::compensation_fund_withdraw (314) — withdraw (locked)",
324
- "service::compensation_fund_receive (316) — receive (locked)",
325
- "service::setting_lock_duration_add (317) — extend lock",
326
- ],
327
- mutable_after_publish: {
328
- machine: false, arbitrations: false, order_allocators: false,
329
- buy_guard: true, rewards: "locked_by_duration",
330
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
331
- sales: true, description: true, location: true, repositories: true,
332
- customer_required: true, discount: true, um: true, pause: true,
333
- },
334
- publish_prerequisites: [
335
- "compensation_fund > 0 → arbitrations non-empty (F-S-19)",
336
- "compensation_fund coin type must match Service<T> type parameter",
337
- ],
338
- common_patterns: [
339
- "Fund inflow: compensation_fund_add (315) — always mutable",
340
- "Fund outflow: compensation_fund_withdraw (314) — requires bPaused + lock_duration expired",
341
- "Fund receive: compensation_fund_receive (316) — locked by duration",
342
- "Fund consumer: arbitration::compensation_claim (driven by arb result)",
343
- "Distinct from Treasury: Service-internal, arbitration-bound, lock-protected",
344
- ],
345
- recommended_templates: ["T-S-06"],
346
- },
347
- {
348
- id: "service_reward",
349
- name: "Reward-attached Service (marketing)",
350
- category: "reward",
351
- permission_index_range: "300-320",
352
- builtin_indexes: SERVICE_PERMISSIONS,
353
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
354
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
355
- owner_operations: ["um_set", "builder (transfer)"],
356
- admin_operations: ["description_set"],
357
- permission_index_operations: [
358
- "service::reward_add/remove/clear (318) — locked by duration",
359
- "service::discount (312)",
360
- "service::publish (311)",
361
- ],
362
- mutable_after_publish: {
363
- machine: false, arbitrations: false, order_allocators: false,
364
- buy_guard: true, rewards: "locked_by_duration",
365
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
366
- sales: true, description: true, location: true, repositories: true,
367
- customer_required: true, discount: true, um: true, pause: true,
368
- },
369
- publish_prerequisites: ["order_allocators must be set"],
370
- common_patterns: [
371
- "Rewards added post-publish (still allowed, but locked by duration)",
372
- "Reward objects must exist before binding (queryObjectsWithType validation)",
373
- "MAX_REWARD_COUNT = 20 per Service",
374
- "Reward removal also locked by duration (protects customer expectations)",
375
- ],
376
- recommended_templates: ["T-S-08"],
377
- },
378
- {
379
- id: "service_arbitration_binding",
380
- name: "Arbitration Binding Service (post-publish immutable)",
381
- category: "arbitration",
382
- permission_index_range: "300-320",
383
- builtin_indexes: SERVICE_PERMISSIONS,
384
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
385
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
386
- owner_operations: ["um_set", "builder (transfer)"],
387
- admin_operations: ["description_set"],
388
- permission_index_operations: [
389
- "service::arbitration_add (308) — pre-publish only",
390
- "service::arbitration_remove (308) — pre-publish only",
391
- "service::arbitration_clear (308) — pre-publish only",
392
- "service::publish (311)",
393
- ],
394
- mutable_after_publish: {
395
- machine: false, arbitrations: false, order_allocators: false,
396
- buy_guard: true, rewards: "locked_by_duration",
397
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
398
- sales: true, description: true, location: true, repositories: true,
399
- customer_required: true, discount: true, um: true, pause: true,
400
- },
401
- publish_prerequisites: [
402
- "MAX_ARBITRATION_COUNT = 20 per Service (F-S-04)",
403
- "Each Arbitration object must be valid (queryObjectsWithType validation)",
404
- "Arbitration bound = locked post-publish (F-S-21). To change: create new Service.",
405
- ],
406
- common_patterns: [
407
- "Pre-publish: set 1-3 Arbitration objects for different dispute scopes",
408
- "Post-publish: immutable — clone Service if change needed",
409
- "⚠️ Data inconsistency: dynamic-pricing.ts marks arbitrations as mutable, but SDK blocks it (F-S-21)",
410
- ],
411
- recommended_templates: ["T-S-05"],
412
- },
413
- {
414
- id: "service_buy_guard",
415
- name: "Buy Guard Service (post-publish mutable guard)",
416
- category: "buy_guard",
417
- permission_index_range: "300-320",
418
- builtin_indexes: SERVICE_PERMISSIONS,
419
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
420
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
421
- owner_operations: ["um_set", "builder (transfer)"],
422
- admin_operations: ["description_set"],
423
- permission_index_operations: [
424
- "service::buy_guard_set (307) — bind guard",
425
- "service::buy_guard_none (307) — clear guard",
426
- "service::publish (311)",
427
- ],
428
- mutable_after_publish: {
429
- machine: false, arbitrations: false, order_allocators: false,
430
- buy_guard: true, rewards: "locked_by_duration",
431
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
432
- sales: true, description: true, location: true, repositories: true,
433
- customer_required: true, discount: true, um: true, pause: true,
434
- },
435
- publish_prerequisites: ["order_allocators must be set"],
436
- common_patterns: [
437
- "Pre-sale phase: buy_guard = whitelist Guard (KYC verified buyers only)",
438
- "Public sale: buy_guard = null (anyone can buy)",
439
- "Restricted phase: buy_guard = KYC Guard (compliance)",
440
- "⚠️ buy_guard is the ONLY publish-locked-field exception — still mutable post-publish",
441
- "buy_guard verification happens at Stage 1 of buy flow (pre_check)",
442
- ],
443
- recommended_templates: ["T-S-01"],
444
- },
445
- {
446
- id: "service_order_allocator",
447
- name: "Order Allocator Service (fund distribution config)",
448
- category: "order_allocator",
449
- permission_index_range: "300-320",
450
- builtin_indexes: SERVICE_PERMISSIONS,
451
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
452
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
453
- owner_operations: ["um_set", "builder (transfer)"],
454
- admin_operations: ["description_set"],
455
- permission_index_operations: [
456
- "service::order_allocators_set (313) — pre-publish only",
457
- "service::publish (311) — requires order_allocators (F-S-18)",
458
- ],
459
- mutable_after_publish: {
460
- machine: false, arbitrations: false, order_allocators: false,
461
- buy_guard: true, rewards: "locked_by_duration",
462
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
463
- sales: true, description: true, location: true, repositories: true,
464
- customer_required: true, discount: true, um: true, pause: true,
465
- },
466
- publish_prerequisites: [
467
- "order_allocators MUST be set (F-S-18, E_NO_ALLOCATOR)",
468
- "Allocators.sharing.who can reference Treasury addresses (indirect Treasury binding)",
469
- "MAX_SHARING_COUNT = 100 per allocator",
470
- ],
471
- common_patterns: [
472
- "Multi-party split: merchant 80% / platform 10% / logistics 10%",
473
- "Threshold-based: different allocators for different order sizes",
474
- "Guard-bound allocator: allocation execution requires Guard verification",
475
- "Post-publish immutable — clone Service to change allocation strategy",
476
- ],
477
- recommended_templates: ["T-S-08"],
478
- },
479
- {
480
- id: "service_dynamic_pricing",
481
- name: "Dynamic Pricing Service (discount-driven)",
482
- category: "dynamic_pricing",
483
- permission_index_range: "300-320",
484
- builtin_indexes: SERVICE_PERMISSIONS,
485
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
486
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
487
- owner_operations: ["um_set", "builder (transfer)"],
488
- admin_operations: ["description_set"],
489
- permission_index_operations: [
490
- "service::discount (312) — issue coupons",
491
- "service::sales_add/set (305) — adjust base prices",
492
- "service::sales_remove (305) — remove deprecated SKUs",
493
- ],
494
- mutable_after_publish: {
495
- machine: false, arbitrations: false, order_allocators: false,
496
- buy_guard: true, rewards: "locked_by_duration",
497
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
498
- sales: true, description: true, location: true, repositories: true,
499
- customer_required: true, discount: true, um: true, pause: true,
500
- },
501
- publish_prerequisites: ["order_allocators must be set"],
502
- common_patterns: [
503
- "Discount types: 0=rates (basis points, per 10000), 1=minus (direct deduction)",
504
- "MAX_DISCOUNT_COUNT_ONCE = 1000 per issue call",
505
- "MAX_DISCOUNT_RECEIVER_ONCE = 1000 receivers per call",
506
- "MAX_DISCOUNT_TOTAL_COUNT = 20000 total coupons",
507
- "discount_destroy: holder-only (no SERVICE_DISCOUNT permission needed)",
508
- ],
509
- recommended_templates: ["T-S-07"],
510
- },
511
- {
512
- id: "service_multi_allocator",
513
- name: "Multi-Allocator Service (tiered fund distribution)",
514
- category: "multi_allocator",
515
- permission_index_range: "300-320",
516
- builtin_indexes: SERVICE_PERMISSIONS,
517
- cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
518
- order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
519
- owner_operations: ["um_set", "builder (transfer)"],
520
- admin_operations: ["description_set"],
521
- permission_index_operations: [
522
- "service::order_allocators_set (313) — pre-publish only",
523
- "service::publish (311)",
524
- ],
525
- mutable_after_publish: {
526
- machine: false, arbitrations: false, order_allocators: false,
527
- buy_guard: true, rewards: "locked_by_duration",
528
- compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
529
- sales: true, description: true, location: true, repositories: true,
530
- customer_required: true, discount: true, um: true, pause: true,
531
- },
532
- publish_prerequisites: [
533
- "order_allocators MUST be set",
534
- "Each allocator has its own Guard + sharing + threshold",
535
- "First-match-wins: first allocator whose threshold is met handles the order",
536
- ],
537
- common_patterns: [
538
- "Tier 1 (small orders): single-recipient allocator (low fee)",
539
- "Tier 2 (medium orders): two-recipient split (merchant + platform)",
540
- "Tier 3 (large orders): three-recipient split (merchant + platform + logistics)",
541
- "Each tier can have its own Guard for execution authorization",
542
- ],
543
- recommended_templates: ["T-S-08"],
544
- },
545
- ];
546
- export const SERVICE_LEDGER_VERSION = "1.0.0";
547
- export function getScenesByCategory(category) {
548
- return SERVICE_SCENES.filter(s => s.category === category);
549
- }
550
- export function findSceneById(id) {
551
- return SERVICE_SCENES.find(s => s.id === id);
552
- }
553
- export function getServicePermissionByIndex(index) {
554
- return SERVICE_PERMISSIONS.find(p => p.index === index);
555
- }
556
- export function isServicePermission(index) {
557
- return getServicePermissionByIndex(index) !== undefined;
558
- }
559
- export function getPermissionsByMutability(mutability) {
560
- return SERVICE_PERMISSIONS.filter(p => p.post_publish_mutability === mutability);
561
- }
562
- export function getImmutablePostPublishPermissions() {
563
- return SERVICE_PERMISSIONS.filter(p => p.post_publish_mutability === "immutable" || p.post_publish_mutability === "one_shot");
564
- }
565
- export function getLockedByDurationPermissions() {
566
- return SERVICE_PERMISSIONS.filter(p => p.post_publish_mutability === "locked_by_duration");
567
- }
568
- export function inferSceneFromIntent(intent) {
569
- const lower = intent.toLowerCase();
570
- const categoryKeywords = [
571
- ["retail", "retail"], ["ecommerce", "retail"],
572
- ["rental", "rental"], ["rent", "rental"], ["short-term rental", "rental"], ["long-term rental", "rental"],
573
- ["subscription", "subscription"], ["subscribe", "subscription"],
574
- ["workflow", "workflow"], ["machine-bound", "workflow"],
575
- ["arbitration", "arbitration"], ["dispute", "arbitration"],
576
- ["compensation", "compensation_fund"], ["compensation_fund", "compensation_fund"],
577
- ["reward", "reward"], ["marketing", "reward"],
578
- ["buy_guard", "buy_guard"], ["kyc", "buy_guard"], ["whitelist", "buy_guard"],
579
- ["allocator", "order_allocator"],
580
- ["discount", "dynamic_pricing"], ["coupon", "dynamic_pricing"],
581
- ["multi-allocator", "multi_allocator"], ["tiered", "multi_allocator"],
582
- ];
583
- for (const [kw, cat] of categoryKeywords) {
584
- if (lower.includes(kw)) {
585
- const scenes = getScenesByCategory(cat);
586
- if (scenes.length > 0)
587
- return scenes[0];
588
- }
589
- }
590
- if (lower.includes("service")) {
591
- return findSceneById("service_retail");
592
- }
593
- return undefined;
594
- }
595
- export function getAllServiceScenes() {
596
- return [...SERVICE_SCENES];
597
- }
598
- export function getServiceScenesCount() {
599
- return SERVICE_SCENES.length;
600
- }
601
- export function getServicePermissionsCount() {
602
- return SERVICE_PERMISSIONS.length;
603
- }
604
- export function getOrderFlowStage(stage) {
605
- return SERVICE_ORDER_FLOW_STAGES.find(s => s.stage === stage);
606
- }
607
- export function getCrossObjectBindings() {
608
- return [...SERVICE_CROSS_OBJECT_BINDINGS];
609
- }
1
+ export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'service::new','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'service::description_set','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'service::location_set','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'service::repository_add/remove/clear','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items','governed_operation':'service::sales_add/set/remove/clear','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'service::machine_set/machine_none','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'service::buy_guard_set/buy_guard_none','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'service::arbitration_add/remove/clear','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'service::customer_required_set','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'service::pause','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'service::publish','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'service::discount','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'service::order_allocators_set','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(lock_duration)','governed_operation':'service::compensation_fund_withdraw','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'service::compensation_fund_add','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(lock_duration)','governed_operation':'service::compensation_fund_receive','post_publish_mutability':'locked_by_duration'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'service::setting_lock_duration_add','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(locked)','governed_operation':'service::reward_add/remove/clear','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'service::owner_receive','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'service::um_set/um_none','post_publish_mutability':'mutable'}];export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_SERVICE_NOT_PUBLISHED)','Service.bPaused\x20==\x20false\x20(else\x20E_SERVICE_PAUSED)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_NOT_FOUND)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_INSUFFICIENT)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20unexpired'],'side_effects':['quote_imp()\x20computes\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','service::quote\x20or\x20service::quote_with_discount\x20MoveCall'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['service::buy\x20or\x20service::buy_with_passport\x20MoveCall','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['service::order_allocation\x20MoveCall','Allocation\x20object\x20created\x20(first-match-wins\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['service::order_progress\x20MoveCall','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['agent_set\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','owner_change\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':!![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set','customer_required_set'],'permission_index_operations':['service::publish\x20(311)','service::pause\x20(310)','service::sales_add/set/remove/clear\x20(305)','service::order_allocators_set\x20(313)','service::buy_guard_set\x20(307)','service::discount\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::machine_set\x20(306)\x20—\x20for\x20rental\x20workflow','service::arbitration_add\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::discount\x20(312)\x20—\x20promotional\x20rates','service::reward_add\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::machine_set\x20(306)\x20—\x20bind\x20workflow','service::publish\x20(311)','service::order_allocators_set\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)','service::compensation_fund_add\x20(315)','service::setting_lock_duration_add\x20(317)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','compensation_claim\x20triggered\x20by\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::compensation_fund_add\x20(315)\x20—\x20deposit','service::compensation_fund_withdraw\x20(314)\x20—\x20withdraw\x20(locked)','service::compensation_fund_receive\x20(316)\x20—\x20receive\x20(locked)','service::setting_lock_duration_add\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20locked\x20by\x20duration','Fund\x20consumer:\x20arbitration::compensation_claim\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::reward_add/remove/clear\x20(318)\x20—\x20locked\x20by\x20duration','service::discount\x20(312)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(still\x20allowed,\x20but\x20locked\x20by\x20duration)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20removal\x20also\x20locked\x20by\x20duration\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_remove\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_clear\x20(308)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::buy_guard_set\x20(307)\x20—\x20bind\x20guard','service::buy_guard_none\x20(307)\x20—\x20clear\x20guard','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::discount\x20(312)\x20—\x20issue\x20coupons','service::sales_add/set\x20(305)\x20—\x20adjust\x20base\x20prices','service::sales_remove\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20is\x20met\x20handles\x20the\x20order'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}