@wowok/agent-mcp 2.4.3 → 2.5.1

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 (317) hide show
  1. package/dist/config/runtime.d.ts +4 -0
  2. package/dist/config/runtime.js +29 -5
  3. package/dist/harness/auto-escalation.d.ts +27 -0
  4. package/dist/harness/auto-escalation.js +68 -0
  5. package/dist/index.js +21 -0
  6. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  7. package/dist/knowledge/allocation-confirm.js +534 -0
  8. package/dist/knowledge/allocation-context.d.ts +58 -0
  9. package/dist/knowledge/allocation-context.js +249 -0
  10. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  11. package/dist/knowledge/allocation-ledger.js +463 -0
  12. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  13. package/dist/knowledge/allocation-puzzle.js +298 -0
  14. package/dist/knowledge/allocation-risk.d.ts +78 -0
  15. package/dist/knowledge/allocation-risk.js +568 -0
  16. package/dist/knowledge/allocation-templates.d.ts +38 -0
  17. package/dist/knowledge/allocation-templates.js +970 -0
  18. package/dist/knowledge/allocation-translation.d.ts +72 -0
  19. package/dist/knowledge/allocation-translation.js +585 -0
  20. package/dist/knowledge/arb-risk.d.ts +37 -0
  21. package/dist/knowledge/arb-risk.js +210 -0
  22. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  23. package/dist/knowledge/arbitration-confirm.js +559 -0
  24. package/dist/knowledge/arbitration-context.d.ts +81 -0
  25. package/dist/knowledge/arbitration-context.js +505 -0
  26. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  27. package/dist/knowledge/arbitration-ledger.js +521 -0
  28. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  29. package/dist/knowledge/arbitration-puzzle.js +304 -0
  30. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  31. package/dist/knowledge/arbitration-risk.js +433 -0
  32. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  33. package/dist/knowledge/arbitration-templates.js +276 -0
  34. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  35. package/dist/knowledge/arbitration-translation.js +487 -0
  36. package/dist/knowledge/bridge-risk.d.ts +36 -0
  37. package/dist/knowledge/bridge-risk.js +263 -0
  38. package/dist/knowledge/contact-risk.d.ts +32 -0
  39. package/dist/knowledge/contact-risk.js +200 -0
  40. package/dist/knowledge/demand-confirm.d.ts +32 -0
  41. package/dist/knowledge/demand-confirm.js +206 -0
  42. package/dist/knowledge/demand-risk.d.ts +30 -0
  43. package/dist/knowledge/demand-risk.js +240 -0
  44. package/dist/knowledge/demand-translation.d.ts +55 -0
  45. package/dist/knowledge/demand-translation.js +354 -0
  46. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  47. package/dist/knowledge/deployment-scanner.js +762 -0
  48. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  49. package/dist/knowledge/examples-scanner-cli.js +26 -0
  50. package/dist/knowledge/examples-scanner.d.ts +121 -0
  51. package/dist/knowledge/examples-scanner.js +825 -0
  52. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  53. package/dist/knowledge/flywheel-loop.js +32 -3
  54. package/dist/knowledge/glossary.js +3 -1
  55. package/dist/knowledge/guard-confirm.d.ts +86 -0
  56. package/dist/knowledge/guard-confirm.js +406 -0
  57. package/dist/knowledge/guard-context.d.ts +56 -0
  58. package/dist/knowledge/guard-context.js +287 -0
  59. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  60. package/dist/knowledge/guard-design-patterns.js +257 -0
  61. package/dist/knowledge/guard-puzzle.js +3 -2
  62. package/dist/knowledge/guard-risk.d.ts +1 -1
  63. package/dist/knowledge/guard-risk.js +12 -14
  64. package/dist/knowledge/guard-templates.js +1 -1
  65. package/dist/knowledge/guard-translation.js +6 -5
  66. package/dist/knowledge/index.d.ts +342 -0
  67. package/dist/knowledge/index.js +344 -0
  68. package/dist/knowledge/machine-confirm.d.ts +102 -0
  69. package/dist/knowledge/machine-confirm.js +559 -0
  70. package/dist/knowledge/machine-context.d.ts +160 -0
  71. package/dist/knowledge/machine-context.js +812 -0
  72. package/dist/knowledge/machine-ledger.d.ts +41 -0
  73. package/dist/knowledge/machine-ledger.js +315 -0
  74. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  75. package/dist/knowledge/machine-puzzle.js +494 -0
  76. package/dist/knowledge/machine-risk.d.ts +75 -0
  77. package/dist/knowledge/machine-risk.js +644 -0
  78. package/dist/knowledge/machine-templates.d.ts +92 -0
  79. package/dist/knowledge/machine-templates.js +1592 -0
  80. package/dist/knowledge/machine-topology.d.ts +57 -0
  81. package/dist/knowledge/machine-topology.js +234 -0
  82. package/dist/knowledge/machine-translation.d.ts +96 -0
  83. package/dist/knowledge/machine-translation.js +513 -0
  84. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  85. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  86. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  87. package/dist/knowledge/mcp-schema-audit.js +772 -0
  88. package/dist/knowledge/onchain-constants.d.ts +4 -0
  89. package/dist/knowledge/onchain-constants.js +35 -0
  90. package/dist/knowledge/order-confirm.d.ts +115 -0
  91. package/dist/knowledge/order-confirm.js +573 -0
  92. package/dist/knowledge/order-context.d.ts +66 -0
  93. package/dist/knowledge/order-context.js +390 -0
  94. package/dist/knowledge/order-ledger.d.ts +69 -0
  95. package/dist/knowledge/order-ledger.js +341 -0
  96. package/dist/knowledge/order-puzzle.d.ts +159 -0
  97. package/dist/knowledge/order-puzzle.js +255 -0
  98. package/dist/knowledge/order-risk.d.ts +66 -0
  99. package/dist/knowledge/order-risk.js +653 -0
  100. package/dist/knowledge/order-templates.d.ts +50 -0
  101. package/dist/knowledge/order-templates.js +368 -0
  102. package/dist/knowledge/order-translation.d.ts +78 -0
  103. package/dist/knowledge/order-translation.js +550 -0
  104. package/dist/knowledge/passport-confirm.d.ts +130 -0
  105. package/dist/knowledge/passport-confirm.js +531 -0
  106. package/dist/knowledge/passport-context.d.ts +59 -0
  107. package/dist/knowledge/passport-context.js +306 -0
  108. package/dist/knowledge/passport-ledger.d.ts +48 -0
  109. package/dist/knowledge/passport-ledger.js +282 -0
  110. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  111. package/dist/knowledge/passport-puzzle.js +333 -0
  112. package/dist/knowledge/passport-risk.d.ts +70 -0
  113. package/dist/knowledge/passport-risk.js +450 -0
  114. package/dist/knowledge/passport-templates.d.ts +40 -0
  115. package/dist/knowledge/passport-templates.js +568 -0
  116. package/dist/knowledge/passport-translation.d.ts +68 -0
  117. package/dist/knowledge/passport-translation.js +516 -0
  118. package/dist/knowledge/payment-risk.d.ts +33 -0
  119. package/dist/knowledge/payment-risk.js +182 -0
  120. package/dist/knowledge/permission-confirm.d.ts +110 -0
  121. package/dist/knowledge/permission-confirm.js +426 -0
  122. package/dist/knowledge/permission-context.d.ts +58 -0
  123. package/dist/knowledge/permission-context.js +224 -0
  124. package/dist/knowledge/permission-ledger.d.ts +38 -0
  125. package/dist/knowledge/permission-ledger.js +403 -0
  126. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  127. package/dist/knowledge/permission-puzzle.js +173 -0
  128. package/dist/knowledge/permission-risk.d.ts +76 -0
  129. package/dist/knowledge/permission-risk.js +411 -0
  130. package/dist/knowledge/permission-templates.d.ts +38 -0
  131. package/dist/knowledge/permission-templates.js +234 -0
  132. package/dist/knowledge/permission-translation.d.ts +57 -0
  133. package/dist/knowledge/permission-translation.js +350 -0
  134. package/dist/knowledge/personal-risk.d.ts +36 -0
  135. package/dist/knowledge/personal-risk.js +212 -0
  136. package/dist/knowledge/progress-confirm.d.ts +108 -0
  137. package/dist/knowledge/progress-confirm.js +456 -0
  138. package/dist/knowledge/progress-context.d.ts +123 -0
  139. package/dist/knowledge/progress-context.js +452 -0
  140. package/dist/knowledge/progress-ledger.d.ts +63 -0
  141. package/dist/knowledge/progress-ledger.js +327 -0
  142. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  143. package/dist/knowledge/progress-puzzle.js +219 -0
  144. package/dist/knowledge/progress-risk.d.ts +74 -0
  145. package/dist/knowledge/progress-risk.js +461 -0
  146. package/dist/knowledge/progress-templates.d.ts +38 -0
  147. package/dist/knowledge/progress-templates.js +228 -0
  148. package/dist/knowledge/progress-translation.d.ts +52 -0
  149. package/dist/knowledge/progress-translation.js +401 -0
  150. package/dist/knowledge/proof-confirm.d.ts +31 -0
  151. package/dist/knowledge/proof-confirm.js +187 -0
  152. package/dist/knowledge/proof-risk.d.ts +33 -0
  153. package/dist/knowledge/proof-risk.js +207 -0
  154. package/dist/knowledge/proof-translation.d.ts +52 -0
  155. package/dist/knowledge/proof-translation.js +283 -0
  156. package/dist/knowledge/registrar-risk.d.ts +34 -0
  157. package/dist/knowledge/registrar-risk.js +217 -0
  158. package/dist/knowledge/repository-confirm.d.ts +36 -0
  159. package/dist/knowledge/repository-confirm.js +242 -0
  160. package/dist/knowledge/repository-risk.d.ts +40 -0
  161. package/dist/knowledge/repository-risk.js +312 -0
  162. package/dist/knowledge/repository-translation.d.ts +58 -0
  163. package/dist/knowledge/repository-translation.js +422 -0
  164. package/dist/knowledge/resource-risk.d.ts +32 -0
  165. package/dist/knowledge/resource-risk.js +157 -0
  166. package/dist/knowledge/reward-confirm.d.ts +113 -0
  167. package/dist/knowledge/reward-confirm.js +496 -0
  168. package/dist/knowledge/reward-context.d.ts +127 -0
  169. package/dist/knowledge/reward-context.js +504 -0
  170. package/dist/knowledge/reward-ledger.d.ts +96 -0
  171. package/dist/knowledge/reward-ledger.js +502 -0
  172. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  173. package/dist/knowledge/reward-puzzle.js +288 -0
  174. package/dist/knowledge/reward-risk.d.ts +84 -0
  175. package/dist/knowledge/reward-risk.js +545 -0
  176. package/dist/knowledge/reward-translation.d.ts +58 -0
  177. package/dist/knowledge/reward-translation.js +501 -0
  178. package/dist/knowledge/safety-rules.js +11 -3
  179. package/dist/knowledge/scenario-modes.d.ts +53 -0
  180. package/dist/knowledge/scenario-modes.js +302 -0
  181. package/dist/knowledge/service-confirm.d.ts +152 -0
  182. package/dist/knowledge/service-confirm.js +699 -0
  183. package/dist/knowledge/service-context.d.ts +66 -0
  184. package/dist/knowledge/service-context.js +403 -0
  185. package/dist/knowledge/service-ledger.d.ts +71 -0
  186. package/dist/knowledge/service-ledger.js +609 -0
  187. package/dist/knowledge/service-puzzle.d.ts +158 -0
  188. package/dist/knowledge/service-puzzle.js +236 -0
  189. package/dist/knowledge/service-risk.d.ts +108 -0
  190. package/dist/knowledge/service-risk.js +615 -0
  191. package/dist/knowledge/service-templates.d.ts +39 -0
  192. package/dist/knowledge/service-templates.js +418 -0
  193. package/dist/knowledge/service-translation.d.ts +103 -0
  194. package/dist/knowledge/service-translation.js +622 -0
  195. package/dist/knowledge/tools-reference.d.ts +17 -0
  196. package/dist/knowledge/tools-reference.js +151 -0
  197. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  198. package/dist/knowledge/treasury-confirm.js +512 -0
  199. package/dist/knowledge/treasury-context.d.ts +64 -0
  200. package/dist/knowledge/treasury-context.js +363 -0
  201. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  202. package/dist/knowledge/treasury-ledger.js +300 -0
  203. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  204. package/dist/knowledge/treasury-puzzle.js +216 -0
  205. package/dist/knowledge/treasury-risk.d.ts +86 -0
  206. package/dist/knowledge/treasury-risk.js +440 -0
  207. package/dist/knowledge/treasury-templates.d.ts +38 -0
  208. package/dist/knowledge/treasury-templates.js +316 -0
  209. package/dist/knowledge/treasury-translation.d.ts +78 -0
  210. package/dist/knowledge/treasury-translation.js +498 -0
  211. package/dist/knowledge/util-risk.d.ts +30 -0
  212. package/dist/knowledge/util-risk.js +135 -0
  213. package/dist/project/business-puzzle.d.ts +47 -0
  214. package/dist/project/business-puzzle.js +372 -0
  215. package/dist/project/deployment-doc.d.ts +61 -0
  216. package/dist/project/deployment-doc.js +432 -0
  217. package/dist/project/risk-aggregator.d.ts +50 -0
  218. package/dist/project/risk-aggregator.js +280 -0
  219. package/dist/project/substep-trace.d.ts +130 -0
  220. package/dist/project/substep-trace.js +332 -0
  221. package/dist/schema/call/allocation.d.ts +34 -34
  222. package/dist/schema/call/arbitration.d.ts +141 -141
  223. package/dist/schema/call/base.d.ts +386 -386
  224. package/dist/schema/call/base.js +3 -3
  225. package/dist/schema/call/bridge-handler.d.ts +5 -2
  226. package/dist/schema/call/bridge.d.ts +159 -159
  227. package/dist/schema/call/contact.d.ts +110 -110
  228. package/dist/schema/call/demand.d.ts +76 -76
  229. package/dist/schema/call/handler.d.ts +2 -3
  230. package/dist/schema/call/handler.js +1 -1
  231. package/dist/schema/call/machine.d.ts +58 -58
  232. package/dist/schema/call/order.d.ts +98 -110
  233. package/dist/schema/call/permission-handler.d.ts +5 -0
  234. package/dist/schema/call/permission-handler.js +54 -0
  235. package/dist/schema/call/permission.d.ts +108 -108
  236. package/dist/schema/call/personal.d.ts +14 -14
  237. package/dist/schema/call/progress.d.ts +57 -72
  238. package/dist/schema/call/progress.js +7 -4
  239. package/dist/schema/call/proof.d.ts +18 -18
  240. package/dist/schema/call/proof.js +12 -7
  241. package/dist/schema/call/repository.d.ts +154 -154
  242. package/dist/schema/call/reward.d.ts +55 -55
  243. package/dist/schema/call/service.d.ts +231 -231
  244. package/dist/schema/call/treasury.d.ts +93 -93
  245. package/dist/schema/config/index.d.ts +178 -5
  246. package/dist/schema/config/index.js +52 -1
  247. package/dist/schema/local/index.d.ts +3554 -836
  248. package/dist/schema/local/index.js +2 -1
  249. package/dist/schema/messenger/index.d.ts +162 -162
  250. package/dist/schema/operations.d.ts +1058 -1074
  251. package/dist/schema/operations.js +7 -1
  252. package/dist/schema/project/index.d.ts +1412 -6
  253. package/dist/schema/project/index.js +441 -3
  254. package/dist/schema/query/index.d.ts +672 -672
  255. package/dist/schema/schema-query/index.d.ts +23 -3
  256. package/dist/schema/schema-query/index.js +13 -2
  257. package/dist/schema/sync-layer4.d.ts +21 -0
  258. package/dist/schema/sync-layer4.js +261 -0
  259. package/dist/schema/trust/index.d.ts +26 -26
  260. package/dist/schemas/account_operation.output.json +718 -0
  261. package/dist/schemas/config_operation.output.json +173 -0
  262. package/dist/schemas/index.json +9 -1
  263. package/dist/schemas/local_info_operation.output.json +718 -0
  264. package/dist/schemas/local_mark_operation.output.json +718 -0
  265. package/dist/schemas/onchain_operations.output.json +3 -2
  266. package/dist/schemas/onchain_operations.schema.json +1809 -336
  267. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  268. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  269. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  270. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  271. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  272. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  273. package/dist/schemas/onchain_operations_guard.schema.json +578 -579
  274. package/dist/schemas/onchain_operations_machine.schema.json +2 -1
  275. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  276. package/dist/schemas/onchain_operations_payment.schema.json +0 -514
  277. package/dist/schemas/onchain_operations_permission.schema.json +0 -514
  278. package/dist/schemas/onchain_operations_personal.schema.json +0 -514
  279. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  280. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  281. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  282. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  283. package/dist/schemas/onchain_operations_service.schema.json +2 -1
  284. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  285. package/dist/schemas/onchain_table_data.schema.json +32 -1
  286. package/dist/schemas/project_operation.output.json +918 -0
  287. package/dist/schemas/project_operation.schema.json +474 -3
  288. package/dist/schemas/query_toolkit.output.json +14906 -6
  289. package/dist/schemas/schema_query.output.json +38 -1
  290. package/dist/telemetry/index.d.ts +1 -1
  291. package/dist/tools/handlers/config.d.ts +1 -1
  292. package/dist/tools/handlers/config.js +21 -18
  293. package/dist/tools/handlers/file-export.d.ts +2 -2
  294. package/dist/tools/handlers/local.d.ts +3 -30
  295. package/dist/tools/handlers/local.js +14 -3
  296. package/dist/tools/handlers/messenger.d.ts +1 -1
  297. package/dist/tools/handlers/messenger.js +2 -1
  298. package/dist/tools/handlers/onchain.d.ts +1 -1
  299. package/dist/tools/handlers/onchain.js +24 -22
  300. package/dist/tools/handlers/project.d.ts +1 -1
  301. package/dist/tools/handlers/project.js +262 -18
  302. package/dist/tools/handlers/query.d.ts +4 -4
  303. package/dist/tools/handlers/schema-query.d.ts +1 -1
  304. package/dist/tools/handlers/schema-query.js +21 -20
  305. package/dist/tools/handlers/trust.d.ts +1 -1
  306. package/dist/tools/handlers/trust.js +2 -2
  307. package/dist/tools/handlers/wip.d.ts +1 -1
  308. package/dist/tools/handlers/wip.js +1 -1
  309. package/dist/tools/index.d.ts +1 -1
  310. package/dist/tools/index.js +96 -25
  311. package/dist/tools/rules-hook.d.ts +1 -1
  312. package/dist/tools/rules-hook.js +3 -2
  313. package/dist/tools/shared.d.ts +13 -22
  314. package/dist/tools/types.d.ts +5 -5
  315. package/dist/tools/wrap.d.ts +10 -2
  316. package/dist/tools/wrap.js +212 -0
  317. package/package.json +3 -3
@@ -0,0 +1,276 @@
1
+ export const ARBITRATION_TEMPLATES = [
2
+ {
3
+ id: "T-AB-01",
4
+ name: "Single-arbiter quick ruling",
5
+ description: "Simplest Arbitration: one arbiter makes all rulings. voting_guard empty (open vote, but only arbiter has 358 perm). Suitable for small-scale / fast dispute resolution.",
6
+ applicable_scenes: ["arbitration_create", "arbitration_ruling", "arbitration_confirm"],
7
+ industry_tags: ["retail", "freelance", "small_business"],
8
+ params: [
9
+ { name: "owner_address", type: "address", description: "Arbitration owner (also admin)", required: true },
10
+ { name: "arbiter_address", type: "address", description: "Single arbiter address (gets ARBITRATION_VOTE=358 + ARBITRATION_ARBITRATION=359)", required: true },
11
+ { name: "coin_type", type: "string", description: "Coin type for arbitration fee (e.g. 0x2::wow::WOW)", required: true },
12
+ { name: "description", type: "string", description: "Arbitration description", required: true },
13
+ { name: "fee_amount", type: "number", description: "Dispute application fee (u64, in Coin base units)", required: false, default: 0 },
14
+ { name: "arbitration_name", type: "string", description: "Local name for the Arbitration object", required: false },
15
+ ],
16
+ body: (p) => ({
17
+ object: {
18
+ name: p.arbitration_name ?? "single_arb_arbitration",
19
+ type_parameter: p.coin_type,
20
+ permission: { name: `${p.arbitration_name ?? "single_arb"}_permission` },
21
+ },
22
+ description: p.description,
23
+ fee: String(p.fee_amount ?? 0),
24
+ pause: false,
25
+ }),
26
+ notes: [
27
+ "voting_guard remains empty → vote() uses open vote (1 person 1 vote)",
28
+ "Only arbiter_address should be granted ARBITRATION_VOTE (358) + ARBITRATION_ARBITRATION (359)",
29
+ "Fast ruling: arbiter confirms materials → votes → makes ruling in one session",
30
+ "Not suitable for high-value disputes (no consensus check)",
31
+ ],
32
+ },
33
+ {
34
+ id: "T-AB-02",
35
+ name: "Multi-arbiter voting (weighted)",
36
+ description: "Multiple arbiters vote with weighted voting_guard. Each arbiter's Guard has FixedValue weight. Ruling requires majority weight.",
37
+ applicable_scenes: ["arbitration_create", "arbitration_vote", "arbitration_voting_guard_config"],
38
+ industry_tags: ["governance", "dao", "committee"],
39
+ params: [
40
+ { name: "owner_address", type: "address", description: "Arbitration owner", required: true },
41
+ { name: "arbiter_guards", type: "string[]", description: "Guard addresses for each arbiter (will be added to voting_guard)", required: true },
42
+ { name: "vote_weights", type: "string[]", description: "FixedValue weights for each arbiter (parallel to arbiter_guards)", required: true },
43
+ { name: "coin_type", type: "string", description: "Coin type", required: true },
44
+ { name: "description", type: "string", description: "Arbitration description", required: true },
45
+ { name: "fee_amount", type: "number", description: "Dispute fee", required: false, default: 0 },
46
+ ],
47
+ body: (p) => {
48
+ const guards = p.arbiter_guards.map((guard, i) => ({
49
+ guard,
50
+ vote_weight: { FixedValue: Number(p.vote_weights[i] ?? 1) },
51
+ }));
52
+ return {
53
+ object: {
54
+ name: "weighted_arbitration",
55
+ type_parameter: p.coin_type,
56
+ permission: { name: "weighted_arb_permission" },
57
+ },
58
+ description: p.description,
59
+ fee: String(p.fee_amount ?? 0),
60
+ pause: false,
61
+ voting_guard: {
62
+ op: "set",
63
+ guards,
64
+ },
65
+ };
66
+ },
67
+ notes: [
68
+ "voting_guard non-empty → vote MUST use vote_with_voting_guard",
69
+ "Each arbiter's Guard must be a valid Guard object they can submit Passport for",
70
+ "Consider: max(arbiter_weights) / total_weights < 0.5 to avoid collusion (see R-AB-3-01)",
71
+ "Max 50 voting_guards (MAX_VOTING_GUARD_COUNT)",
72
+ ],
73
+ },
74
+ {
75
+ id: "T-AB-03",
76
+ name: "Public voting arbitration",
77
+ description: "voting_guard allows public to vote (anyone with a Guard can vote). Suitable for community-driven dispute resolution.",
78
+ applicable_scenes: ["arbitration_create", "arbitration_vote", "arbitration_voting_guard_config"],
79
+ industry_tags: ["community", "public_goods", "social"],
80
+ params: [
81
+ { name: "owner_address", type: "address", description: "Arbitration owner", required: true },
82
+ { name: "public_guard", type: "address", description: "Guard address anyone can submit Passport for (e.g. based on account existence)", required: true },
83
+ { name: "vote_weight", type: "number", description: "FixedValue weight per public voter (e.g. 1)", required: false, default: 1 },
84
+ { name: "coin_type", type: "string", description: "Coin type", required: true },
85
+ { name: "description", type: "string", description: "Arbitration description", required: true },
86
+ ],
87
+ body: (p) => ({
88
+ object: {
89
+ name: "public_arbitration",
90
+ type_parameter: p.coin_type,
91
+ permission: { name: "public_arb_permission" },
92
+ },
93
+ description: p.description,
94
+ fee: "0",
95
+ pause: false,
96
+ voting_guard: {
97
+ op: "set",
98
+ guards: [
99
+ { guard: p.public_guard, vote_weight: { FixedValue: Number(p.vote_weight ?? 1) } },
100
+ ],
101
+ },
102
+ }),
103
+ notes: [
104
+ "Public voting: anyone holding the public_guard can vote",
105
+ "Consider using GuardIdentifier (dynamic weight) for token-weighted voting",
106
+ "Low/zero fee to encourage participation — but watch for spam disputes",
107
+ "Suitable for community moderation, content disputes, public goods arbitration",
108
+ ],
109
+ },
110
+ {
111
+ id: "T-AB-04",
112
+ name: "Scope-restricted arbitration",
113
+ description: "usage_guard filters which disputes can be filed. Only users passing the Guard can file disputes. Suitable for verified-merchant / KYC arbitration.",
114
+ applicable_scenes: ["arbitration_create", "arbitration_usage_guard_config", "arbitration_dispute"],
115
+ industry_tags: ["kyc", "verified_merchant", "enterprise"],
116
+ params: [
117
+ { name: "owner_address", type: "address", description: "Arbitration owner", required: true },
118
+ { name: "usage_guard_address", type: "address", description: "Guard address that filters who can file disputes (KYC/verification)", required: true },
119
+ { name: "coin_type", type: "string", description: "Coin type", required: true },
120
+ { name: "description", type: "string", description: "Arbitration description", required: true },
121
+ { name: "arbiter_address", type: "address", description: "Arbiter address (single arbiter for simplicity)", required: true },
122
+ { name: "fee_amount", type: "number", description: "Dispute fee (higher to deter spam)", required: false, default: 1000000000 },
123
+ ],
124
+ body: (p) => ({
125
+ object: {
126
+ name: "restricted_arbitration",
127
+ type_parameter: p.coin_type,
128
+ permission: { name: "restricted_arb_permission" },
129
+ },
130
+ description: p.description,
131
+ fee: String(p.fee_amount ?? 1000000000),
132
+ pause: false,
133
+ usage_guard: p.usage_guard_address,
134
+ }),
135
+ notes: [
136
+ "usage_guard set → dispute MUST use dispute_with_passport variant",
137
+ "Guard verifies: KYC / membership / token-balance / etc.",
138
+ "Higher fee (default 1 WOW) to deter spam from verified users",
139
+ "Arbiter should also be Guard-verified for consistency",
140
+ ],
141
+ },
142
+ {
143
+ id: "T-AB-05",
144
+ name: "Arbitration committee",
145
+ description: "Multi-arbiter committee with weighted voting + usage_guard. Most controlled configuration — restricted dispute filing + weighted voting + multi-arbiter ruling.",
146
+ applicable_scenes: ["arbitration_create", "arbitration_voting_guard_config", "arbitration_usage_guard_config", "arbitration_ruling"],
147
+ industry_tags: ["enterprise", "legal", "high_value"],
148
+ params: [
149
+ { name: "owner_address", type: "address", description: "Committee owner", required: true },
150
+ { name: "committee_guards", type: "string[]", description: "Guard addresses for each committee member", required: true },
151
+ { name: "member_weights", type: "string[]", description: "Vote weights for each member (parallel to committee_guards)", required: true },
152
+ { name: "membership_guard", type: "address", description: "usage_guard for dispute filing (membership verification)", required: true },
153
+ { name: "coin_type", type: "string", description: "Coin type", required: true },
154
+ { name: "description", type: "string", description: "Arbitration description", required: true },
155
+ { name: "fee_amount", type: "number", description: "Dispute fee (high for high-value disputes)", required: false, default: 10000000000 },
156
+ ],
157
+ body: (p) => {
158
+ const guards = p.committee_guards.map((guard, i) => ({
159
+ guard,
160
+ vote_weight: { FixedValue: Number(p.member_weights[i] ?? 1) },
161
+ }));
162
+ return {
163
+ object: {
164
+ name: "committee_arbitration",
165
+ type_parameter: p.coin_type,
166
+ permission: { name: "committee_arb_permission" },
167
+ },
168
+ description: p.description,
169
+ fee: String(p.fee_amount ?? 10000000000),
170
+ pause: false,
171
+ voting_guard: { op: "set", guards },
172
+ usage_guard: p.membership_guard,
173
+ };
174
+ },
175
+ notes: [
176
+ "Most restrictive config: weighted voting + restricted filing",
177
+ "Suitable for high-value B2B disputes, legal arbitration, enterprise SLA enforcement",
178
+ "Committee members should have clear escalation / tiebreaker rules",
179
+ "All disputes require Passport (both filing and voting)",
180
+ ],
181
+ },
182
+ {
183
+ id: "T-AB-06",
184
+ name: "Fee-split arbitration",
185
+ description: "Pre-configured fees_alloc / fees_transfer destination. After arb_withdraw, fees are automatically distributed to Allocation (for arbiter compensation).",
186
+ applicable_scenes: ["arbitration_create", "arbitration_arb_withdraw", "arbitration_fees_alloc"],
187
+ industry_tags: ["marketplace", "service", "platform"],
188
+ params: [
189
+ { name: "owner_address", type: "address", description: "Arbitration owner", required: true },
190
+ { name: "allocation_address", type: "address", description: "Allocation object address for fee distribution to arbiters", required: true },
191
+ { name: "coin_type", type: "string", description: "Coin type", required: true },
192
+ { name: "description", type: "string", description: "Arbitration description", required: true },
193
+ { name: "arbiter_address", type: "address", description: "Arbiter (single for simplicity)", required: true },
194
+ { name: "fee_amount", type: "number", description: "Dispute fee (will be split to arbiters via Allocation)", required: false, default: 5000000000 },
195
+ ],
196
+ body: (p) => ({
197
+ object: {
198
+ name: "feesplit_arbitration",
199
+ type_parameter: p.coin_type,
200
+ permission: { name: "feesplit_arb_permission" },
201
+ },
202
+ description: p.description,
203
+ fee: String(p.fee_amount ?? 5000000000),
204
+ pause: false,
205
+ }),
206
+ notes: [
207
+ "Fee-split is a 2-step process: arb_withdraw → fees_transfer",
208
+ "arb_withdraw (364) moves fees from Arb → Arbitration.balance",
209
+ "fees_alloc (365) or fees_transfer (366) moves fees → Allocation/Treasury",
210
+ "Allocation policy determines how fees are split among arbiters",
211
+ "Payment object is created for bookkeeping (payment_remark + payment_index)",
212
+ ],
213
+ },
214
+ {
215
+ id: "T-AB-07",
216
+ name: "Appeal arbitration (reset flow)",
217
+ description: "Template for reset operation — disputant objects to ruling and resubmits materials. Restarts Arb lifecycle from Principal_confirming.",
218
+ applicable_scenes: ["arbitration_reset", "arbitration_ruling"],
219
+ industry_tags: ["legal", "appeal", "high_value"],
220
+ params: [
221
+ { name: "arbitration_address", type: "address", description: "Existing Arbitration object address", required: true },
222
+ { name: "arb_address", type: "address", description: "Arb object address to reset (must be in Objectionable/Arbitrated status)", required: true },
223
+ { name: "reset_feedback", type: "string", description: "Feedback explaining why disputant objects to the ruling", required: true },
224
+ ],
225
+ body: (p) => ({
226
+ object: p.arbitration_address,
227
+ reset: {
228
+ arb: p.arb_address,
229
+ feedback: p.reset_feedback,
230
+ },
231
+ }),
232
+ notes: [
233
+ "Precondition: Arb must be in Objectionable (4) or Arbitrated (3) status",
234
+ "Post-condition: Arb status → Principal_confirming (0), lifecycle restarts",
235
+ "Original ruling is invalidated — new voting + ruling required",
236
+ "Consider capping reset count to prevent infinite appeals",
237
+ "reset feedback is permanent — recorded on-chain for audit trail",
238
+ ],
239
+ },
240
+ ];
241
+ export const ARBITRATION_TEMPLATES_VERSION = "1.0.0";
242
+ export function getAllTemplates() {
243
+ return [...ARBITRATION_TEMPLATES];
244
+ }
245
+ export function getTemplateById(id) {
246
+ return ARBITRATION_TEMPLATES.find(t => t.id === id);
247
+ }
248
+ export function getTemplatesByScene(sceneId) {
249
+ return ARBITRATION_TEMPLATES.filter(t => t.applicable_scenes.includes(sceneId));
250
+ }
251
+ export function getTemplatesByIndustry(industry) {
252
+ return ARBITRATION_TEMPLATES.filter(t => t.industry_tags.includes(industry) || t.industry_tags.includes("universal"));
253
+ }
254
+ export function suggestTemplateForScene(sceneId) {
255
+ const matches = getTemplatesByScene(sceneId);
256
+ return matches.length > 0 ? matches[0] : undefined;
257
+ }
258
+ export function listTemplates() {
259
+ return ARBITRATION_TEMPLATES.map(t => ({
260
+ id: t.id,
261
+ name: t.name,
262
+ description: t.description,
263
+ scenes: t.applicable_scenes,
264
+ }));
265
+ }
266
+ export function fillTemplate(templateId, params) {
267
+ const tpl = getTemplateById(templateId);
268
+ if (!tpl)
269
+ return { ok: false, error: `Template ${templateId} not found` };
270
+ for (const p of tpl.params) {
271
+ if (p.required && !(p.name in params)) {
272
+ return { ok: false, error: `Missing required param: ${p.name}` };
273
+ }
274
+ }
275
+ return { ok: true, body: tpl.body(params) };
276
+ }
@@ -0,0 +1,91 @@
1
+ import { type ArbStatus } from "./arbitration-ledger.js";
2
+ export interface SemanticToSchemaRule {
3
+ id: string;
4
+ pattern_name: string;
5
+ semantic_intent: string;
6
+ match_keywords: string[];
7
+ schema_fields: string[];
8
+ example_json: object;
9
+ reverse_explanation: string;
10
+ }
11
+ export interface SchemaToSemanticRule {
12
+ element_type: "field" | "op" | "index" | "status";
13
+ type_name: string;
14
+ semantic_explanation: string;
15
+ constraints?: string[];
16
+ }
17
+ export interface ArbitrationConstraintRule {
18
+ id: string;
19
+ category: "structural" | "semantic" | "authority" | "lifecycle" | "cross_object";
20
+ rule: string;
21
+ applies_to: string[];
22
+ }
23
+ export declare const SEMANTIC_TO_SCHEMA_RULES: SemanticToSchemaRule[];
24
+ export declare const SCHEMA_TO_SEMANTIC_RULES: SchemaToSemanticRule[];
25
+ export declare const ARBITRATION_CONSTRAINT_RULES: ArbitrationConstraintRule[];
26
+ export declare const ARBITRATION_TRANSLATION_VERSION = "1.0.0";
27
+ export declare function matchSemanticPattern(userIntent: string): SemanticToSchemaRule[];
28
+ export declare function explainArbitrationCallData(data: {
29
+ object?: string | null | object;
30
+ description?: string;
31
+ location?: string;
32
+ fee?: string | number;
33
+ pause?: boolean;
34
+ dispute?: {
35
+ order: string;
36
+ description?: string;
37
+ proposition: string[];
38
+ fee?: unknown;
39
+ namedArb?: unknown;
40
+ };
41
+ confirm?: {
42
+ arb: string;
43
+ voting_deadline: number | null;
44
+ };
45
+ voting_deadline_change?: {
46
+ arb: string;
47
+ voting_deadline: number | null;
48
+ };
49
+ vote?: {
50
+ arb: string;
51
+ votes: number[];
52
+ voting_guard?: string;
53
+ };
54
+ feedback?: {
55
+ arb: string;
56
+ feedback: string;
57
+ };
58
+ arbitration?: {
59
+ arb: string;
60
+ feedback: string;
61
+ indemnity: number;
62
+ };
63
+ reset?: {
64
+ arb: string;
65
+ feedback: string;
66
+ };
67
+ arb_withdraw?: {
68
+ arb: string;
69
+ };
70
+ fees_transfer?: {
71
+ to: {
72
+ allocation?: string;
73
+ treasury?: string;
74
+ };
75
+ payment_remark: string;
76
+ payment_index: number;
77
+ };
78
+ usage_guard?: string | null;
79
+ voting_guard?: {
80
+ op: string;
81
+ guards?: unknown[];
82
+ };
83
+ um?: string | null;
84
+ builder?: string;
85
+ }): string;
86
+ export declare function explainField(fieldName: string): SchemaToSemanticRule | undefined;
87
+ export declare function explainOp(opName: string): SchemaToSemanticRule | undefined;
88
+ export declare function explainStatus(statusName: string): SchemaToSemanticRule | undefined;
89
+ export declare function getConstraintsByCategory(category: ArbitrationConstraintRule["category"]): ArbitrationConstraintRule[];
90
+ export declare function explainPermissionIndex(index: number): string;
91
+ export declare function explainArbStatus(status: ArbStatus): string;