@wowok/agent-mcp 2.6.3 → 2.6.6

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 (193) hide show
  1. package/README.md +13 -9
  2. package/dist/customer/customer-advice.d.ts +31 -0
  3. package/dist/customer/customer-advice.js +129 -0
  4. package/dist/customer/index.d.ts +2 -0
  5. package/dist/customer/index.js +2 -0
  6. package/dist/customer/info-puzzle.d.ts +8 -1
  7. package/dist/customer/info-puzzle.js +30 -5
  8. package/dist/customer/order-monitor.d.ts +2 -0
  9. package/dist/customer/order-monitor.js +3 -2
  10. package/dist/customer/post-purchase.d.ts +2 -0
  11. package/dist/customer/post-purchase.js +6 -5
  12. package/dist/customer/preorder-compare.d.ts +24 -0
  13. package/dist/customer/preorder-compare.js +34 -0
  14. package/dist/customer/reminder-system.d.ts +2 -0
  15. package/dist/customer/reminder-system.js +2 -1
  16. package/dist/customer/risk-assessment.js +4 -3
  17. package/dist/customer/types.d.ts +5 -0
  18. package/dist/examples/arbitration-dispute-create.json +41 -0
  19. package/dist/examples/arbitration-vote-weighted.json +35 -0
  20. package/dist/examples/arbitration-voting-guard-add.json +38 -0
  21. package/dist/examples/demand-present-service.json +33 -0
  22. package/dist/examples/gen-passport-verify-guard.json +48 -0
  23. package/dist/examples/guard-template-balance-check.json +36 -15
  24. package/dist/examples/guard-template-time-lock.json +33 -12
  25. package/dist/examples/insurance-guard-claim-timelock.json +75 -0
  26. package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
  27. package/dist/examples/insurance-machine-create-publish.json +75 -0
  28. package/dist/examples/insurance-service-allocators-publish.json +56 -0
  29. package/dist/examples/machine-multisig-threshold.json +86 -0
  30. package/dist/examples/machine-template-7node-rental.json +99 -94
  31. package/dist/examples/payment-scenario-bound.json +45 -0
  32. package/dist/examples/rental-ziroom-machine-create.json +126 -114
  33. package/dist/examples/rental-ziroom-permission-create.json +10 -3
  34. package/dist/examples/rental-ziroom-service-create.json +27 -18
  35. package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
  36. package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
  37. package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
  38. package/dist/examples/retail-adv-reward-guard-add.json +51 -0
  39. package/dist/examples/retail-myshop-allocation-activate.json +55 -0
  40. package/dist/examples/retail-myshop-arbitration-create.json +40 -0
  41. package/dist/examples/retail-myshop-contact-create.json +43 -0
  42. package/dist/examples/retail-myshop-order-create.json +56 -0
  43. package/dist/examples/retail-myshop-progress-operate.json +38 -0
  44. package/dist/examples/retail-myshop-reward-create.json +35 -0
  45. package/dist/examples/service-discount-issue.json +46 -0
  46. package/dist/examples/threebody-guard-create.json +56 -0
  47. package/dist/examples/threebody-machine-create.json +72 -0
  48. package/dist/examples/threebody-permission-create.json +38 -0
  49. package/dist/examples/threebody-service-allocators.json +49 -0
  50. package/dist/examples/travel-guard-time-lock.json +69 -0
  51. package/dist/examples/travel-guard-weather-oracle.json +70 -0
  52. package/dist/examples/travel-machine-create.json +136 -0
  53. package/dist/examples/travel-repository-create.json +47 -0
  54. package/dist/examples/travel-service-create.json +102 -0
  55. package/dist/examples/travel-treasury-create.json +34 -0
  56. package/dist/examples/treasury-deposit.json +37 -0
  57. package/dist/examples/treasury-withdraw.json +38 -0
  58. package/dist/extensions/business-modules.d.ts +49 -0
  59. package/dist/extensions/business-modules.js +287 -0
  60. package/dist/extensions/capability-manifest.js +192 -5
  61. package/dist/extensions/constraint-registry.js +3 -1
  62. package/dist/extensions/modes.js +10 -4
  63. package/dist/extensions/registry.d.ts +14 -9
  64. package/dist/extensions/registry.js +69 -14
  65. package/dist/extensions/types.d.ts +1 -0
  66. package/dist/knowledge/fund-layer.d.ts +67 -1
  67. package/dist/knowledge/fund-layer.js +561 -12
  68. package/dist/knowledge/guard-templates.d.ts +10 -0
  69. package/dist/knowledge/guard-templates.js +50 -0
  70. package/dist/knowledge/index.d.ts +2 -2
  71. package/dist/knowledge/index.js +2 -2
  72. package/dist/knowledge/machine-risk.js +4 -1
  73. package/dist/knowledge/progress-context.js +1 -1
  74. package/dist/knowledge/progress-ledger.js +3 -3
  75. package/dist/knowledge/progress-templates.js +1 -1
  76. package/dist/knowledge/progress-translation.js +1 -1
  77. package/dist/knowledge/safety-rules.d.ts +83 -1
  78. package/dist/knowledge/safety-rules.js +166 -2
  79. package/dist/knowledge/scenario-modes.d.ts +1 -1
  80. package/dist/knowledge/scenario-modes.js +13 -11
  81. package/dist/knowledge/template-registry.d.ts +48 -0
  82. package/dist/knowledge/template-registry.js +341 -0
  83. package/dist/knowledge/tool-constraints.js +6 -6
  84. package/dist/knowledge/tools-reference.js +11 -8
  85. package/dist/participation/merchant-interest.d.ts +32 -0
  86. package/dist/participation/merchant-interest.js +100 -0
  87. package/dist/participation/radar-core.d.ts +104 -0
  88. package/dist/participation/radar-core.js +269 -0
  89. package/dist/project/context-assembly.js +8 -0
  90. package/dist/project/edit-planner.js +27 -56
  91. package/dist/project/evaluation.d.ts +36 -0
  92. package/dist/project/evaluation.js +422 -56
  93. package/dist/project/game-theory.d.ts +43 -0
  94. package/dist/project/game-theory.js +177 -0
  95. package/dist/project/graph-builder.js +1 -0
  96. package/dist/project/handlers.d.ts +38 -0
  97. package/dist/project/handlers.js +65 -35
  98. package/dist/project/intent-analyzer.d.ts +71 -0
  99. package/dist/project/intent-analyzer.js +149 -0
  100. package/dist/project/machine-nodes.d.ts +2 -0
  101. package/dist/project/machine-nodes.js +36 -0
  102. package/dist/project/merchant-guide.d.ts +165 -0
  103. package/dist/project/merchant-guide.js +264 -0
  104. package/dist/project/mode-actions.d.ts +199 -0
  105. package/dist/project/mode-actions.js +309 -0
  106. package/dist/project/participation-radar.d.ts +18 -0
  107. package/dist/project/participation-radar.js +428 -0
  108. package/dist/project/pipeline-actions.d.ts +101 -0
  109. package/dist/project/pipeline-actions.js +109 -0
  110. package/dist/project/semantic-graph.d.ts +95 -0
  111. package/dist/project/semantic-graph.js +245 -0
  112. package/dist/schema/call/allocation.d.ts +11 -11
  113. package/dist/schema/call/allocation.js +11 -1
  114. package/dist/schema/call/arbitration.d.ts +21 -21
  115. package/dist/schema/call/arbitration.js +17 -9
  116. package/dist/schema/call/base.d.ts +2 -2
  117. package/dist/schema/call/base.js +1 -1
  118. package/dist/schema/call/bridge.d.ts +127 -127
  119. package/dist/schema/call/bridge.js +12 -12
  120. package/dist/schema/call/contact.d.ts +3 -3
  121. package/dist/schema/call/demand.d.ts +3 -3
  122. package/dist/schema/call/guard.d.ts +11 -11
  123. package/dist/schema/call/guard.js +1 -1
  124. package/dist/schema/call/machine.d.ts +216 -21
  125. package/dist/schema/call/machine.js +1 -1
  126. package/dist/schema/call/order.d.ts +7 -7
  127. package/dist/schema/call/payment.d.ts +3 -3
  128. package/dist/schema/call/permission.d.ts +3 -3
  129. package/dist/schema/call/personal.d.ts +337 -3
  130. package/dist/schema/call/personal.js +10 -0
  131. package/dist/schema/call/progress.d.ts +177 -9
  132. package/dist/schema/call/progress.js +7 -3
  133. package/dist/schema/call/proof.d.ts +6 -6
  134. package/dist/schema/call/repository.d.ts +3 -3
  135. package/dist/schema/call/reward.d.ts +57 -57
  136. package/dist/schema/call/semantic.js +41 -1
  137. package/dist/schema/call/service.d.ts +114 -114
  138. package/dist/schema/call/service.js +11 -2
  139. package/dist/schema/call/treasury.d.ts +57 -57
  140. package/dist/schema/messenger/index.js +4 -1
  141. package/dist/schema/operations.d.ts +713 -291
  142. package/dist/schema/operations.js +33 -0
  143. package/dist/schema/project/index.d.ts +4635 -100
  144. package/dist/schema/project/index.js +868 -1
  145. package/dist/schema/query/index.d.ts +363 -19
  146. package/dist/schema/query/index.js +25 -3
  147. package/dist/schema/schema-query/index.d.ts +13 -7
  148. package/dist/schema/schema-query/index.js +29 -5
  149. package/dist/schema/trust/index.d.ts +1012 -6
  150. package/dist/schema/trust/index.js +212 -11
  151. package/dist/schema/utils/skills-recommendation.js +1 -0
  152. package/dist/schema-query/index.d.ts +4 -1
  153. package/dist/schema-query/index.js +255 -1
  154. package/dist/schemas/bridge_operation.schema.json +14 -7
  155. package/dist/schemas/guard2file.schema.json +2 -0
  156. package/dist/schemas/index.json +1 -1
  157. package/dist/schemas/machineNode2file.schema.json +2 -0
  158. package/dist/schemas/messenger_operation.schema.json +1 -1
  159. package/dist/schemas/onchain_operations.schema.json +143 -15
  160. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  161. package/dist/schemas/onchain_operations_arbitration.schema.json +7 -5
  162. package/dist/schemas/onchain_operations_contact.schema.json +1 -0
  163. package/dist/schemas/onchain_operations_demand.schema.json +1 -0
  164. package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -0
  165. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  166. package/dist/schemas/onchain_operations_guard.schema.json +578 -0
  167. package/dist/schemas/onchain_operations_machine.schema.json +1 -0
  168. package/dist/schemas/onchain_operations_order.schema.json +4 -3
  169. package/dist/schemas/onchain_operations_payment.schema.json +1 -0
  170. package/dist/schemas/onchain_operations_permission.schema.json +1 -0
  171. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  172. package/dist/schemas/onchain_operations_progress.schema.json +90 -3
  173. package/dist/schemas/onchain_operations_proof.schema.json +1 -0
  174. package/dist/schemas/onchain_operations_repository.schema.json +1 -0
  175. package/dist/schemas/onchain_operations_reward.schema.json +1 -0
  176. package/dist/schemas/onchain_operations_service.schema.json +4 -3
  177. package/dist/schemas/onchain_operations_treasury.schema.json +1 -0
  178. package/dist/schemas/project_operation.output.json +2243 -1
  179. package/dist/schemas/project_operation.schema.json +683 -1
  180. package/dist/schemas/query_toolkit.output.json +1 -1
  181. package/dist/schemas/query_toolkit.schema.json +37 -0
  182. package/dist/schemas/schema_query.output.json +1 -1
  183. package/dist/schemas/schema_query.schema.json +30 -5
  184. package/dist/schemas/trust_score.output.json +392 -1
  185. package/dist/schemas/trust_score.schema.json +275 -1
  186. package/dist/tools/handlers/onchain.js +73 -8
  187. package/dist/tools/handlers/project.js +46 -0
  188. package/dist/tools/handlers/query.js +117 -2
  189. package/dist/tools/handlers/schema-query.js +41 -0
  190. package/dist/tools/handlers/trust.js +192 -6
  191. package/dist/tools/index.js +52 -9
  192. package/dist/tools/wrap.js +194 -15
  193. package/package.json +2 -2
@@ -0,0 +1,102 @@
1
+ {
2
+ "title": "Create and Publish Travel Service with Tiered Allocation Waterfall",
3
+ "description": "Create the Iceland travel Service with Machine binding, one sales item, Arbitration binding, and a 3-tier order_allocators waterfall (first-Guard-wins): merchant victory 100% to Treasury, no-ice-scooting 80/20 Treasury/customer, no-SPA 5/95 Treasury/customer — then publish in the same transaction.",
4
+ "tags": ["service", "travel", "order_allocators", "waterfall", "allocation", "publish", "arbitration"],
5
+ "industry": "travel",
6
+ "operation_type": "service",
7
+ "source": "docs/examples/Travel — schema-validated, not chain-verified",
8
+ "verified": false,
9
+ "network": "testnet",
10
+ "call": {
11
+ "tool": "onchain_operations",
12
+ "operation_type": "service",
13
+ "data": {
14
+ "object": {
15
+ "name": "travel_service",
16
+ "permission": "travel_permission",
17
+ "replaceExistName": true
18
+ },
19
+ "description": "Iceland travel service: Blue Lagoon SPA + Glacier Ice Scooting.",
20
+ "machine": "travel_machine",
21
+ "sales": {
22
+ "op": "add",
23
+ "sales": [
24
+ {
25
+ "name": "Iceland Travel Package",
26
+ "price": "500000000",
27
+ "stock": "99",
28
+ "suspension": false,
29
+ "wip": "",
30
+ "wip_hash": ""
31
+ }
32
+ ]
33
+ },
34
+ "arbitrations": {
35
+ "op": "add",
36
+ "objects": ["travel_arbitration"]
37
+ },
38
+ "order_allocators": {
39
+ "description": "Travel order revenue allocation based on progress state",
40
+ "threshold": 0,
41
+ "allocators": [
42
+ {
43
+ "guard": "merchant_victory_guard",
44
+ "sharing": [
45
+ {
46
+ "who": {"Entity": {"name_or_address": "travel_treasury"}},
47
+ "sharing": 10000,
48
+ "mode": "Rate"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "guard": "no_ice_scooting_guard",
54
+ "sharing": [
55
+ {
56
+ "who": {"Entity": {"name_or_address": "travel_treasury"}},
57
+ "sharing": 8000,
58
+ "mode": "Rate"
59
+ },
60
+ {
61
+ "who": {"GuardIdentifier": 0},
62
+ "sharing": 2000,
63
+ "mode": "Rate"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "guard": "no_spa_guard",
69
+ "sharing": [
70
+ {
71
+ "who": {"Entity": {"name_or_address": "travel_treasury"}},
72
+ "sharing": 500,
73
+ "mode": "Rate"
74
+ },
75
+ {
76
+ "who": {"GuardIdentifier": 0},
77
+ "sharing": 9500,
78
+ "mode": "Rate"
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ },
84
+ "pause": false,
85
+ "publish": true
86
+ },
87
+ "env": {
88
+ "account": "travel_provider",
89
+ "network": "testnet",
90
+ "no_cache": true,
91
+ "confirmed": true
92
+ }
93
+ },
94
+ "notes": [
95
+ "Tiered allocation waterfall pattern (query/index.ts AllocatorsSchema): allocators are evaluated IN ORDER and the FIRST allocator whose Guard passes wins (mutually exclusive paths). Each tier's Rate-mode sharing sums to exactly 10000 basis points (10000=100%; 8000+2000; 500+9500) — required by the contract when no Surplus item exists (ERATE_NOT_10000). The three Guards discriminate on progress.current ('Complete' / 'Cancel'|'Ice Scooting' / 'SPA') plus order.service ownership, so the tier that fires is determined by the terminal workflow state.",
96
+ "Recipient forms (query/index.ts RecipientSchema): {Entity:{name_or_address:'travel_treasury'}} is a FIXED address resolved at build time — merchant revenue always flows to the Treasury object regardless of who calls alloc_by_guard (Treasury-first rule, R-C3-06 safe, no Signer binding needed). {GuardIdentifier:0} is DYNAMIC — resolved from the Guard table submission at allocation time; all three allocation Guards define identifier 0 as b_submission:true Address accepting the Order ID, so the customer share escrows to the Order object (claimable by the order owner via order receive).",
97
+ "Schema check (call/service.ts CallService_DataSchema, strict): object uses the OBJECT form of TypedPermissionObjectSchema (type_parameter omitted -> WOW default '0x2::wow::WOW'); sales is an op discriminated union {op:'add', sales:[ServiceSaleSchema]} — each sale requires name/price/stock/suspension/wip/wip_hash (price '500000000' = 0.5 WOW smallest unit as string; empty wip/wip_hash are TESTING-ONLY, production must pin a real WIP URL + hash); arbitrations uses ObjectsSchema {op:'add', objects:[...]} — the bound Arbitration MUST use a Permission DIFFERENT from the Service's (E_ARBITRATION_PERMISSION_CONFLICT), hence travel_arbitration_permission in the doc.",
98
+ "L1 immutability warning: machine and order_allocators are PERMANENTLY LOCKED once publish=true executes (service.move assert!(!bPublished)) — there is no pause+lock exception. Verify every guard name resolves and every sharing split is intended BEFORE publishing; after publish the only fix is a NEW Service object. Guards (merchant_victory_guard, no_ice_scooting_guard, no_spa_guard), the published Machine (travel_machine), the Arbitration (travel_arbitration), and the Treasury (travel_treasury) must all exist before this call.",
99
+ "threshold:0 means no minimum balance is required for allocation to fire. Allocator 'fix' and 'max' fields are intentionally omitted — fix is output-only (contract-computed sum of Amount-mode items) and max is an optional cap.",
100
+ "Desensitization: doc payload already uses generic local-mark names only (travel_provider, travel_service, travel_treasury, travel_arbitration, guard names); no real personal data or raw 0x object addresses present — nothing replaced."
101
+ ]
102
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "title": "Create Treasury for Merchant Revenue (Travel)",
3
+ "description": "Create a Treasury (travel_treasury) holding WOW tokens to aggregate travel service merchant revenue, sharing the Service's permission for unified governance",
4
+ "tags": ["treasury", "fund", "travel", "revenue"],
5
+ "industry": "travel",
6
+ "operation_type": "treasury",
7
+ "source": "Travel verified deployment walkthrough (docs/examples/Travel) — adapted to current schema",
8
+ "verified": true,
9
+ "network": "testnet",
10
+ "call": {
11
+ "tool": "onchain_operations",
12
+ "operation_type": "treasury",
13
+ "data": {
14
+ "object": {
15
+ "name": "travel_treasury",
16
+ "type_parameter": "0x2::wow::WOW",
17
+ "permission": "travel_permission",
18
+ "replaceExistName": true
19
+ },
20
+ "description": "Treasury for aggregating travel service merchant revenue. Uses the same Permission as the Service (travel_permission) for consistency — a single permission organization governs both fund collection and service operations."
21
+ },
22
+ "env": {
23
+ "network": "testnet",
24
+ "no_cache": true,
25
+ "confirmed": true
26
+ }
27
+ },
28
+ "notes": [
29
+ "Treasury-First rule: merchant revenue flows to a Treasury object. The Treasury aggregates public funds in one fixed place, which makes Service allocator guards inherently safe — allocated funds always flow to the fixed treasury address, never to an arbitrary recipient, so guard logic cannot be abused to redirect money.",
30
+ "A Treasury MAY share the Service's Permission (travel_permission here) so one permission organization governs both fund collection and service operations. This is the opposite of Arbitration, which MUST NOT share the Service's Permission (arbitration needs independent governance to stay neutral between merchant and customer).",
31
+ "type_parameter determines the token type the Treasury holds and pays out (format {address}::{module}::{struct}). Use '0x2::wow::WOW' for WOW (the schema default, set explicitly here for clarity); it must match the Service's type_parameter so order payments can flow into this Treasury.",
32
+ "Doc payload validated against current CallTreasury_DataSchema with no drift: 'object' uses the OBJECT form of TypedPermissionObjectSchema (TypeNamedObjectWithPermissionSchema — name, type_parameter, permission, replaceExistName all valid); only restructured from the raw MCP envelope (data.operation_type/data.data) into the example-library call shape. The verified walkthrough executed this call with env.account='travel_provider'."
33
+ ]
34
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "title": "Deposit Revenue into Treasury",
3
+ "description": "Deposit 1 WOW of service revenue into travel_treasury via Permission, recording the payment with a remark and naming the generated Payment object.",
4
+ "tags": ["treasury", "deposit", "fund", "travel"],
5
+ "industry": "travel",
6
+ "operation_type": "treasury",
7
+ "source": "constructed under T-09 authorization; grounded in DepositSchema + treasury.ts SDK — schema-validated, not chain-verified",
8
+ "verified": false,
9
+ "network": "testnet",
10
+ "call": {
11
+ "tool": "onchain_operations",
12
+ "operation_type": "treasury",
13
+ "data": {
14
+ "object": "travel_treasury",
15
+ "deposit": {
16
+ "coin": { "balance": 1000000000 },
17
+ "payment_info": {
18
+ "remark": "Service revenue settlement 2026-07",
19
+ "index": 0
20
+ },
21
+ "namedNewPayment": { "name": "travel_deposit_payment_v1" }
22
+ }
23
+ },
24
+ "env": {
25
+ "network": "testnet",
26
+ "no_cache": true,
27
+ "confirmed": true
28
+ }
29
+ },
30
+ "notes": [
31
+ "coin uses CoinParam: {balance: <amount>} pulls that amount from the signer's wallet (1000000000 = 1 WOW, 9 decimals); alternatively {coin: '<coin_object_id_or_name>'} deposits a specific Coin object.",
32
+ "Two deposit paths: via PERMISSION (default, as here — caller must hold the Treasury's deposit operation permission) or via EXTERNAL GUARD (set by_external_deposit_guard to a Guard name/address; the amount may then be bounded by the Guard table value at the identifier configured in external_deposit_guard).",
33
+ "payment_info (PaymentInfoSchema): remark + index are REQUIRED; index is the payment-record sequence number used later by fees_transfer-style operations to reference this payment. for_object/for_guard are optional scenario bindings (see payment-scenario-bound example).",
34
+ "namedNewPayment names the Payment object auto-generated by the deposit — recommended so the fund flow is auditable by name in later queries.",
35
+ "Token type is fixed by the Treasury's type_parameter (0x2::wow::WOW here); the deposited coin must match."
36
+ ]
37
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "title": "Withdraw Fixed Amount from Treasury",
3
+ "description": "Withdraw 0.5 WOW from travel_treasury to the provider account via Permission (fixed-amount path), recording the payout as a named Payment.",
4
+ "tags": ["treasury", "withdraw", "payout", "travel"],
5
+ "industry": "travel",
6
+ "operation_type": "treasury",
7
+ "source": "constructed under T-09 authorization; grounded in WithdrawSchema + treasury.ts SDK — schema-validated, not chain-verified",
8
+ "verified": false,
9
+ "network": "testnet",
10
+ "call": {
11
+ "tool": "onchain_operations",
12
+ "operation_type": "treasury",
13
+ "data": {
14
+ "object": "travel_treasury",
15
+ "withdraw": {
16
+ "amount": { "fixed": 500000000 },
17
+ "recipient": { "name_or_address": "travel_provider" },
18
+ "payment_info": {
19
+ "remark": "Monthly provider payout 2026-07",
20
+ "index": 1
21
+ },
22
+ "namedNewPayment": { "name": "travel_withdraw_payment_v1" }
23
+ }
24
+ },
25
+ "env": {
26
+ "network": "testnet",
27
+ "no_cache": true,
28
+ "confirmed": true
29
+ }
30
+ },
31
+ "notes": [
32
+ "amount is a UNION: {fixed: <amount>} = fixed withdrawal via PERMISSION only (500000000 = 0.5 WOW); {by_external_withdraw_guard: '<guard>'} = Guard-verified withdrawal where the amount comes from the Guard table value at the identifier configured in external_withdraw_guard. The two paths are mutually exclusive.",
33
+ "recipient is AccountOrMark_Address OBJECT form {name_or_address: 'travel_provider'} — resolves the local account/mark to an address. A bare string is NOT accepted here (unlike NameOrAddress fields); wrap it in the object.",
34
+ "payment_info.remark and payment_info.index are REQUIRED (PaymentInfoSchema). Keep index unique per payment for clean audit trails.",
35
+ "namedNewPayment names the Payment object generated by the withdrawal for later audit reference.",
36
+ "The Treasury must hold sufficient balance of its type_parameter token; withdrawal via Permission requires the caller to hold the Treasury's withdraw operation permission."
37
+ ]
38
+ }
@@ -0,0 +1,49 @@
1
+ import type { ProjectObjectType } from "../project/namespace.js";
2
+ export type BusinessModuleId = "milestone_escrow" | "independent_arbitration" | "wip_provenance" | "multi_tier_allocation" | "subscription_with_proof" | "accept_timeout_protection" | "refund_guarantee" | "reputation_on_chain" | "supplier_collaboration" | "damage_attestation";
3
+ export interface ModuleEvaluationImpact {
4
+ dimension: string;
5
+ effect: "boost" | "required" | "optional";
6
+ description: string;
7
+ }
8
+ export interface ModuleConstraint {
9
+ constraint_id: string;
10
+ description: string;
11
+ level: "hard" | "soft" | "info";
12
+ blocking: boolean;
13
+ }
14
+ export interface ModuleTemplateRef {
15
+ template_id: string;
16
+ object_type: ProjectObjectType;
17
+ purpose: string;
18
+ }
19
+ export interface BusinessModule {
20
+ id: BusinessModuleId;
21
+ name: string;
22
+ description: string;
23
+ objectTypes: ProjectObjectType[];
24
+ templateRefs: ModuleTemplateRef[];
25
+ requiredConstraints: ModuleConstraint[];
26
+ evaluationImpact: ModuleEvaluationImpact[];
27
+ industryFit: Record<string, number>;
28
+ addressesPainPoints: string[];
29
+ userProtections: string[];
30
+ merchantObligations: string[];
31
+ requiresKeeper: boolean;
32
+ keeperHint?: string;
33
+ }
34
+ export interface ModuleAdoptionResult {
35
+ module: BusinessModuleId;
36
+ adopted: boolean;
37
+ reason?: string;
38
+ missingConstraints?: string[];
39
+ estimatedScoreBoost: number;
40
+ }
41
+ export declare const CORE_BUSINESS_MODULES: BusinessModule[];
42
+ export declare function getBusinessModule(id: BusinessModuleId): BusinessModule | undefined;
43
+ export declare function getModulesForIndustry(industry: string): BusinessModule[];
44
+ export declare function recommendModules(industry: string, intentDescription: string, options?: {
45
+ minFit?: number;
46
+ maxModules?: number;
47
+ }): BusinessModule[];
48
+ export declare function checkModuleConstraints(module: BusinessModule, satisfiedConstraintIds: Set<string>): ModuleAdoptionResult;
49
+ export declare function calculateModuleScoreBoost(adoptedModules: BusinessModule[]): Record<string, number>;
@@ -0,0 +1,287 @@
1
+ export const CORE_BUSINESS_MODULES = [
2
+ {
3
+ id: "milestone_escrow",
4
+ name: "Milestone Escrow",
5
+ description: "Funds held in Order and released per milestone completion. Protects both merchant and user.",
6
+ objectTypes: ["service", "machine", "order", "allocation"],
7
+ templateRefs: [
8
+ { template_id: "freelance-machine", object_type: "machine", purpose: "Milestone workflow with accept/reject nodes" },
9
+ { template_id: "milestone-allocation", object_type: "allocation", purpose: "Per-milestone fund release" },
10
+ ],
11
+ requiredConstraints: [
12
+ { constraint_id: "order_allocators_bound", description: "Order must have allocators bound before publish", level: "hard", blocking: true },
13
+ { constraint_id: "machine_published", description: "Machine must be published and bound to Service", level: "hard", blocking: true },
14
+ { constraint_id: "milestone_forward_guarded", description: "Each milestone forward must have a guard", level: "soft", blocking: false },
15
+ ],
16
+ evaluationImpact: [
17
+ { dimension: "fund_safety", effect: "boost", description: "Escrow ensures funds not released until verification" },
18
+ { dimension: "escrow_quality", effect: "required", description: "Module requires proper escrow configuration" },
19
+ { dimension: "operational_risk", effect: "boost", description: "Milestones reduce single-point delivery risk" },
20
+ ],
21
+ industryFit: { freelance: 95, education: 80, rental: 60, retail: 40, subscription: 30, travel: 50, general: 70 },
22
+ addressesPainPoints: ["Client never approves deliverables", "Merchant delivers but cannot get paid", "Full upfront payment with no delivery guarantee"],
23
+ userProtections: ["Funds held in escrow until milestone verified", "Can reject substandard deliverables", "Refund for unstarted milestones"],
24
+ merchantObligations: ["Must deliver each milestone to defined acceptance criteria", "Must configure Machine with proper forward guards"],
25
+ requiresKeeper: true,
26
+ keeperHint: "Keeper must monitor Machine node timeouts and trigger adminUnhold if user does not respond",
27
+ },
28
+ {
29
+ id: "independent_arbitration",
30
+ name: "Independent Arbitration",
31
+ description: "Third-party arbitration with Guard-weighted voting. Arbitration Permission MUST differ from Service Permission (contract-enforced).",
32
+ objectTypes: ["arb", "permission", "guard"],
33
+ templateRefs: [
34
+ { template_id: "arbitration-3-voters", object_type: "arb", purpose: "3-voter arbitration with weighted voting" },
35
+ { template_id: "voting-guard-weighted", object_type: "guard", purpose: "Vote weight from Guard config" },
36
+ ],
37
+ requiredConstraints: [
38
+ { constraint_id: "arbitration_permission_independent", description: "Arbitration.permission != Service.permission", level: "hard", blocking: true },
39
+ { constraint_id: "voting_guard_configured", description: "At least one voting_guard must be configured", level: "soft", blocking: false },
40
+ { constraint_id: "arbitration_bound_to_service", description: "Arbitration must be in Service.arbitrations list", level: "hard", blocking: true },
41
+ ],
42
+ evaluationImpact: [
43
+ { dimension: "arbitration_coverage", effect: "required", description: "Module requires arbitration configuration" },
44
+ { dimension: "arbitration_fairness", effect: "required", description: "Independent permission ensures neutrality" },
45
+ { dimension: "governance_risk", effect: "boost", description: "Reduces platform-as-judge risk" },
46
+ ],
47
+ industryFit: { freelance: 90, education: 75, rental: 85, retail: 75, subscription: 60, travel: 80, general: 70 },
48
+ addressesPainPoints: ["Platform acts as both judge and party", "Arbitration fees too high for small claims", "No binding dispute resolution"],
49
+ userProtections: ["Independent arbitrators (not merchant or platform)", "Guard-weighted voting prevents Sybil attacks", "Micro-arbitration: no per-case fees"],
50
+ merchantObligations: ["Must accept arbitration verdict", "Must maintain compensation_fund for indemnities"],
51
+ requiresKeeper: false,
52
+ },
53
+ {
54
+ id: "wip_provenance",
55
+ name: "WIP Provenance",
56
+ description: "Work-in-progress hash commitments on-chain via Repository. Prevents tampering of delivery evidence.",
57
+ objectTypes: ["repository", "guard", "proof"],
58
+ templateRefs: [
59
+ { template_id: "wip-hash-guard", object_type: "guard", purpose: "Verify WIP hash matches commitment" },
60
+ { template_id: "delivery-proof", object_type: "proof", purpose: "On-chain delivery confirmation" },
61
+ ],
62
+ requiredConstraints: [
63
+ { constraint_id: "repository_published", description: "Repository must be published", level: "hard", blocking: true },
64
+ { constraint_id: "wip_hash_before_delivery", description: "WIP hash must be committed before delivery", level: "soft", blocking: false },
65
+ ],
66
+ evaluationImpact: [
67
+ { dimension: "proof_integrity", effect: "required", description: "WIP hash provides tamper-proof evidence" },
68
+ { dimension: "transparency", effect: "boost", description: "On-chain commitment is publicly verifiable" },
69
+ ],
70
+ industryFit: { freelance: 90, education: 85, rental: 95, retail: 70, subscription: 60, travel: 70, general: 75 },
71
+ addressesPainPoints: ["Evidence stored on platform servers can be tampered", "No proof of pre-delivery state (e.g. rental condition)", "Dispute resolution relies on trust in platform"],
72
+ userProtections: ["WIP hash commitment is immutable on-chain", "Guard automatically verifies hash match", "Repository history is auditable"],
73
+ merchantObligations: ["Must commit WIP hash at defined checkpoints", "Must use Repository for evidence storage"],
74
+ requiresKeeper: false,
75
+ },
76
+ {
77
+ id: "multi_tier_allocation",
78
+ name: "Multi-Tier Allocation",
79
+ description: "Order funds automatically split among multiple recipients. Fully transparent on-chain.",
80
+ objectTypes: ["allocation", "treasury", "payment"],
81
+ templateRefs: [
82
+ { template_id: "multi-tier-allocation", object_type: "allocation", purpose: "Waterfall fund distribution" },
83
+ { template_id: "supplier-waterfall", object_type: "allocation", purpose: "Supplier payment tiers" },
84
+ ],
85
+ requiredConstraints: [
86
+ { constraint_id: "allocators_configured", description: "Allocators must be configured with recipients", level: "hard", blocking: true },
87
+ { constraint_id: "sharing_sum_100", description: "Allocation percentages must sum to 100%", level: "hard", blocking: true },
88
+ { constraint_id: "platform_fee_zero", description: "Platform fee should be 0 or user-defined", level: "soft", blocking: false },
89
+ ],
90
+ evaluationImpact: [
91
+ { dimension: "fee_transparency", effect: "required", description: "All allocations visible on-chain" },
92
+ { dimension: "supplier_visibility", effect: "boost", description: "Supplier payments are auditable" },
93
+ ],
94
+ industryFit: { freelance: 60, education: 50, rental: 40, retail: 80, subscription: 70, travel: 95, general: 70 },
95
+ addressesPainPoints: ["Multi-layer commission hidden from users", "Suppliers paid opaquely", "Platform takes undisclosed FX spread"],
96
+ userProtections: ["Full allocation waterfall visible on-chain", "No hidden fees", "Can verify supplier payments"],
97
+ merchantObligations: ["Must declare all allocation recipients upfront", "Cannot change allocation after publish"],
98
+ requiresKeeper: false,
99
+ },
100
+ {
101
+ id: "subscription_with_proof",
102
+ name: "Subscription with Delivery Proof",
103
+ description: "Each billing cycle requires proof of content delivery before charging. Prevents creator abandonment.",
104
+ objectTypes: ["service", "guard", "repository", "progress"],
105
+ templateRefs: [
106
+ { template_id: "subscription-machine", object_type: "machine", purpose: "Cycle-based workflow" },
107
+ { template_id: "delivery-guard-cycle", object_type: "guard", purpose: "Verify content delivery per cycle" },
108
+ ],
109
+ requiredConstraints: [
110
+ { constraint_id: "delivery_guard_per_cycle", description: "Each cycle must have a delivery guard", level: "hard", blocking: true },
111
+ { constraint_id: "repository_updated", description: "Repository must be updated with cycle content hash", level: "soft", blocking: false },
112
+ ],
113
+ evaluationImpact: [
114
+ { dimension: "content_commitment", effect: "required", description: "Delivery proof required before each charge" },
115
+ { dimension: "timeout_protection", effect: "boost", description: "Cycles enforce regular delivery" },
116
+ ],
117
+ industryFit: { freelance: 40, education: 85, rental: 30, retail: 20, subscription: 98, travel: 30, general: 50 },
118
+ addressesPainPoints: ["Creator abandons after collecting subscriptions", "Silent auto-renewal with no delivery proof", "No mechanism to hold creators accountable"],
119
+ userProtections: ["Payment only after delivery proof verified", "Can cancel if delivery guard fails", "Cycle history on-chain"],
120
+ merchantObligations: ["Must deliver content and commit hash each cycle", "Must configure delivery_guard per cycle"],
121
+ requiresKeeper: true,
122
+ keeperHint: "Keeper triggers cycle transitions and verifies delivery_guard conditions",
123
+ },
124
+ {
125
+ id: "accept_timeout_protection",
126
+ name: "Accept Timeout Protection",
127
+ description: "If user does not accept/reject within N days, auto-accept advances the Machine. Protects merchant from indefinite stalls.",
128
+ objectTypes: ["machine", "guard"],
129
+ templateRefs: [
130
+ { template_id: "timeout-forward", object_type: "machine", purpose: "Forward with time_guard + adminUnhold fallback" },
131
+ ],
132
+ requiredConstraints: [
133
+ { constraint_id: "time_guard_configured", description: "time_guard must be set on accept forward", level: "hard", blocking: true },
134
+ { constraint_id: "adminUnhold_permission", description: "Admin must have PROGRESS_UNHOLD (224) permission", level: "soft", blocking: false },
135
+ ],
136
+ evaluationImpact: [
137
+ { dimension: "timeout_protection", effect: "required", description: "Auto-advance prevents indefinite user stalls" },
138
+ { dimension: "operational_risk", effect: "boost", description: "Reduces delivery timeline uncertainty" },
139
+ ],
140
+ industryFit: { freelance: 95, education: 70, rental: 80, retail: 60, subscription: 40, travel: 60, general: 75 },
141
+ addressesPainPoints: ["Buyer never approves deliverables (Upwork/Fiverr)", "Merchant cash flow blocked by inactive buyer", "Infinite revision loops without resolution"],
142
+ userProtections: ["Still has full N days to review and reject", "Rejection triggers arbitration if configured"],
143
+ merchantObligations: ["Must configure time_guard on forward", "Must set reasonable timeout (e.g. 7 days)"],
144
+ requiresKeeper: true,
145
+ keeperHint: "Keeper monitors time_guard deadlines and triggers adminUnhold if user has not responded",
146
+ },
147
+ {
148
+ id: "refund_guarantee",
149
+ name: "Refund Guarantee",
150
+ description: "Service maintains compensation_fund for refunds. Refund_guard validates eligibility and transfers funds back to Order.",
151
+ objectTypes: ["service", "guard", "order"],
152
+ templateRefs: [
153
+ { template_id: "refund-guard", object_type: "guard", purpose: "Validate refund eligibility" },
154
+ ],
155
+ requiredConstraints: [
156
+ { constraint_id: "compensation_fund_positive", description: "compensation_fund_add > 0", level: "hard", blocking: true },
157
+ { constraint_id: "refund_guard_configured", description: "Service must have refund_guard", level: "soft", blocking: false },
158
+ ],
159
+ evaluationImpact: [
160
+ { dimension: "fund_safety", effect: "boost", description: "Compensation fund backs refund promise" },
161
+ { dimension: "consumer_diligence", effect: "boost", description: "Shows merchant confidence in service quality" },
162
+ ],
163
+ industryFit: { freelance: 70, education: 85, rental: 90, retail: 95, subscription: 80, travel: 85, general: 80 },
164
+ addressesPainPoints: ["Refund trapped in platform balance (Fiverr)", "No refund mechanism for service failure", "Refund decision centralized at platform"],
165
+ userProtections: ["Refund goes back to Order (not platform balance)", "Guard validates eligibility (not platform discretion)", "Compensation fund guarantees liquidity"],
166
+ merchantObligations: ["Must maintain compensation_fund > 0", "Must configure refund_guard rules"],
167
+ requiresKeeper: false,
168
+ },
169
+ {
170
+ id: "reputation_on_chain",
171
+ name: "On-Chain Reputation",
172
+ description: "Merchant and user behavior permanently recorded on Registrar. Evaluations, completions, and disputes contribute to reputation score.",
173
+ objectTypes: ["service", "order", "arb"],
174
+ templateRefs: [],
175
+ requiredConstraints: [
176
+ { constraint_id: "service_published", description: "Service must be published to accumulate reputation", level: "soft", blocking: false },
177
+ ],
178
+ evaluationImpact: [
179
+ { dimension: "reputation_verifiability", effect: "required", description: "On-chain history is tamper-proof" },
180
+ { dimension: "trust", effect: "boost", description: "Reputation signals reduce information asymmetry" },
181
+ ],
182
+ industryFit: { freelance: 90, education: 80, rental: 85, retail: 90, subscription: 85, travel: 80, general: 85 },
183
+ addressesPainPoints: ["Fake reviews and rating manipulation", "No cross-platform reputation portability", "Platform can delete negative reviews"],
184
+ userProtections: ["Reputation is on-chain and immutable", "Can verify merchant's complete transaction history", "Dispute outcomes affect reputation permanently"],
185
+ merchantObligations: ["All service interactions become part of permanent record", "Cannot hide negative outcomes"],
186
+ requiresKeeper: false,
187
+ },
188
+ {
189
+ id: "supplier_collaboration",
190
+ name: "Supplier Collaboration",
191
+ description: "Enable merchant to delegate sub-services to suppliers with transparent payment splitting. No platform intermediary.",
192
+ objectTypes: ["service", "allocation", "demand"],
193
+ templateRefs: [
194
+ { template_id: "supplier-demand", object_type: "demand", purpose: "Create sub-service demand for suppliers" },
195
+ { template_id: "supplier-allocation", object_type: "allocation", purpose: "Split order payment with suppliers" },
196
+ ],
197
+ requiredConstraints: [
198
+ { constraint_id: "demand_configured", description: "Demand must reference main Service", level: "soft", blocking: false },
199
+ { constraint_id: "allocation_sharing_configured", description: "Allocation sharing must include suppliers", level: "hard", blocking: true },
200
+ ],
201
+ evaluationImpact: [
202
+ { dimension: "supplier_visibility", effect: "required", description: "Supplier payments transparent on-chain" },
203
+ { dimension: "governance_risk", effect: "boost", description: "No platform controls supplier relationships" },
204
+ ],
205
+ industryFit: { freelance: 60, education: 70, rental: 40, retail: 85, subscription: 50, travel: 90, general: 60 },
206
+ addressesPainPoints: ["Supplier payments opaque to end user", "Platform controls supplier relationships", "No direct merchant-supplier collaboration"],
207
+ userProtections: ["Can see all suppliers involved in service", "Supplier payments are on-chain auditable", "Merchant remains accountable for supplier quality"],
208
+ merchantObligations: ["Must declare all suppliers upfront", "Must ensure supplier deliverables meet criteria"],
209
+ requiresKeeper: false,
210
+ },
211
+ {
212
+ id: "damage_attestation",
213
+ name: "Damage Attestation",
214
+ description: "Rental-specific: pre/post condition photos hashed to Repository. Guard compares hashes to automatically enforce damage deductions.",
215
+ objectTypes: ["repository", "guard", "service"],
216
+ templateRefs: [
217
+ { template_id: "rental-condition-guard", object_type: "guard", purpose: "Compare pre/post rental condition hashes" },
218
+ { template_id: "condition-repository", object_type: "repository", purpose: "Store rental condition evidence" },
219
+ ],
220
+ requiredConstraints: [
221
+ { constraint_id: "pre_rental_hash", description: "Pre-rental condition hash must be committed", level: "hard", blocking: true },
222
+ { constraint_id: "post_rental_hash", description: "Post-rental condition hash must be committed", level: "hard", blocking: true },
223
+ ],
224
+ evaluationImpact: [
225
+ { dimension: "proof_integrity", effect: "required", description: "Condition hashes prevent tampering" },
226
+ { dimension: "arbitration_fairness", effect: "boost", description: "Objective evidence reduces dispute bias" },
227
+ ],
228
+ industryFit: { freelance: 20, education: 30, rental: 98, retail: 40, subscription: 20, travel: 60, general: 40 },
229
+ addressesPainPoints: ["Landlord claims damage without proof (Airbnb)", "No mandatory pre-rental photo (Turo claims denied)", "Platform arbitrates damage disputes opaquely"],
230
+ userProtections: ["Pre-rental hash commits baseline condition", "Guard automatically compares post-rental state", "Cannot be charged for pre-existing damage"],
231
+ merchantObligations: ["Must commit pre-rental condition hash", "Must commit post-rental condition hash", "Must use Repository for evidence storage"],
232
+ requiresKeeper: true,
233
+ keeperHint: "Keeper triggers post-rental hash collection and initiates damage Guard comparison",
234
+ },
235
+ ];
236
+ export function getBusinessModule(id) {
237
+ return CORE_BUSINESS_MODULES.find((m) => m.id === id);
238
+ }
239
+ export function getModulesForIndustry(industry) {
240
+ return [...CORE_BUSINESS_MODULES]
241
+ .sort((a, b) => (b.industryFit[industry] ?? 0) - (a.industryFit[industry] ?? 0));
242
+ }
243
+ export function recommendModules(industry, intentDescription, options) {
244
+ const minFit = options?.minFit ?? 50;
245
+ const maxModules = options?.maxModules ?? 5;
246
+ const scored = CORE_BUSINESS_MODULES.map((m) => {
247
+ let score = m.industryFit[industry] ?? 50;
248
+ const desc = intentDescription.toLowerCase();
249
+ for (const pain of m.addressesPainPoints) {
250
+ const painWords = pain.toLowerCase().split(/\s+/);
251
+ const matchCount = painWords.filter((w) => desc.includes(w)).length;
252
+ score += matchCount * 5;
253
+ }
254
+ return { module: m, score: Math.min(score, 100) };
255
+ });
256
+ return scored
257
+ .filter((s) => s.score >= minFit)
258
+ .sort((a, b) => b.score - a.score)
259
+ .slice(0, maxModules)
260
+ .map((s) => s.module);
261
+ }
262
+ export function checkModuleConstraints(module, satisfiedConstraintIds) {
263
+ const missing = module.requiredConstraints
264
+ .filter((c) => c.blocking && !satisfiedConstraintIds.has(c.constraint_id))
265
+ .map((c) => c.constraint_id);
266
+ const adopted = missing.length === 0;
267
+ const boost = module.evaluationImpact
268
+ .filter((e) => e.effect === "boost" || e.effect === "required")
269
+ .reduce((sum, e) => sum + (e.effect === "required" ? 15 : 8), 0);
270
+ return {
271
+ module: module.id,
272
+ adopted,
273
+ reason: adopted ? undefined : `Missing required constraints: ${missing.join(", ")}`,
274
+ missingConstraints: missing.length > 0 ? missing : undefined,
275
+ estimatedScoreBoost: Math.min(boost, 100),
276
+ };
277
+ }
278
+ export function calculateModuleScoreBoost(adoptedModules) {
279
+ const boosts = {};
280
+ for (const m of adoptedModules) {
281
+ for (const impact of m.evaluationImpact) {
282
+ const increment = impact.effect === "required" ? 15 : impact.effect === "boost" ? 8 : 3;
283
+ boosts[impact.dimension] = (boosts[impact.dimension] ?? 0) + increment;
284
+ }
285
+ }
286
+ return boosts;
287
+ }