@wowok/agent-mcp 2.4.3 → 2.5.0

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 +1392 -6
  253. package/dist/schema/project/index.js +426 -2
  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 +1802 -313
  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 +584 -70
  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 +2 -1
  277. package/dist/schemas/onchain_operations_permission.schema.json +2 -1
  278. package/dist/schemas/onchain_operations_personal.schema.json +2 -1
  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 +879 -0
  287. package/dist/schemas/project_operation.schema.json +473 -2
  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 +258 -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 +55 -8
  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,97 @@
1
+ import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD } from "./onchain-constants.js";
2
+ import { resolveGuardConstructor, getGuardConstructorSpec, type RewardBuiltinPermissionEntry, type RewardGuardConstructor, type RewardRecipientType, type RewardAmountType } from "./reward-ledger.js";
3
+ export interface RewardIntentPuzzle {
4
+ action: "create" | "claim" | "guard_add" | "guard_remove_expired" | "guard_expiration_time_add" | "coin_add" | "receive" | "owner_receive" | "um_set" | "um_none" | "description_set" | "permission_set" | "query";
5
+ target_reward?: string;
6
+ rule_sentence: string;
7
+ failure_conditions: string[];
8
+ }
9
+ export interface RewardConfigPuzzle {
10
+ coin_type: string;
11
+ description: string;
12
+ permission: string;
13
+ permission_is_new: boolean;
14
+ }
15
+ export interface RewardGuardPuzzle {
16
+ guard: string;
17
+ recipient_type: RewardRecipientType;
18
+ recipient_param?: number | string;
19
+ amount_type: RewardAmountType;
20
+ amount_param: number | string;
21
+ expiration_time?: number | null;
22
+ store_from_id?: number | null;
23
+ constructor: RewardGuardConstructor;
24
+ }
25
+ export interface RewardFundsPuzzle {
26
+ current_balance: string;
27
+ coin_add_amount?: string;
28
+ receive_payment?: {
29
+ payment: string;
30
+ token_type: string;
31
+ };
32
+ claim_amount_estimate?: string;
33
+ owner_receive_envelope?: string;
34
+ }
35
+ export interface RewardPermissionPuzzle {
36
+ builtin_indexes_used: RewardBuiltinPermissionEntry[];
37
+ is_permission_free: boolean;
38
+ requires_passport: boolean;
39
+ signer?: string;
40
+ signer_is_owner?: boolean;
41
+ }
42
+ export interface RewardConstraintChecklist {
43
+ F_R_01_guard_count_le_200: boolean;
44
+ F_R_02_record_count_le_5200: boolean;
45
+ F_R_03_balance_sufficient_for_claim: boolean;
46
+ F_R_04_guard_not_locked: boolean;
47
+ F_R_05_guard_not_expired: boolean;
48
+ F_R_06_recipient_amount_valid_pairing: boolean;
49
+ F_R_07_coin_type_matches_reward_t: boolean;
50
+ F_R_08_passport_required_for_claim: boolean;
51
+ }
52
+ export type RewardPuzzleDimension = "A" | "B" | "C" | "D" | "E" | "F";
53
+ export interface RewardPuzzle {
54
+ intent?: RewardIntentPuzzle;
55
+ config?: RewardConfigPuzzle;
56
+ guard?: RewardGuardPuzzle;
57
+ funds?: RewardFundsPuzzle;
58
+ permission?: RewardPermissionPuzzle;
59
+ constraints?: RewardConstraintChecklist;
60
+ }
61
+ export interface RewardPuzzleCompleteness {
62
+ dimensions: RewardPuzzleDimension[];
63
+ missing: RewardPuzzleDimension[];
64
+ missing_details: {
65
+ dimension: RewardPuzzleDimension;
66
+ reason: string;
67
+ }[];
68
+ complete: boolean;
69
+ next_step: string;
70
+ }
71
+ export type RewardFieldMutability = "immutable" | "admin_mutable" | "runtime";
72
+ export interface RewardFieldMutabilityEntry {
73
+ field: string;
74
+ mutability: RewardFieldMutability;
75
+ permission_index?: number;
76
+ set_at_creation: boolean;
77
+ }
78
+ export declare const REWARD_FIELD_MUTABILITY: RewardFieldMutabilityEntry[];
79
+ export declare function initPuzzleFromIntent(intent: Partial<RewardIntentPuzzle>): RewardPuzzle;
80
+ export declare function checkPuzzleCompleteness(puzzle: RewardPuzzle): RewardPuzzleCompleteness;
81
+ export interface RewardConstraintViolation {
82
+ constraint_id: string;
83
+ severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
84
+ message: string;
85
+ current_value?: string | number;
86
+ limit?: string | number;
87
+ }
88
+ export declare function validateConstraints(puzzle: RewardPuzzle): RewardConstraintViolation[];
89
+ export declare function generateConfirmationText(puzzle: RewardPuzzle): string;
90
+ export declare function resolveBuiltinPermission(index: number): RewardBuiltinPermissionEntry | undefined;
91
+ export declare function requiresGuardConfig(puzzle: RewardPuzzle): boolean;
92
+ export declare function requiresPassport(puzzle: RewardPuzzle): boolean;
93
+ export declare function getRelevantDimensions(action: RewardIntentPuzzle["action"]): RewardPuzzleDimension[];
94
+ export declare function getFieldMutability(field: string): RewardFieldMutabilityEntry | undefined;
95
+ export declare function isAdminMutableField(field: string): boolean;
96
+ export declare function getFieldPermissionIndex(field: string): number | undefined;
97
+ export { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, resolveGuardConstructor, getGuardConstructorSpec, };
@@ -0,0 +1,288 @@
1
+ import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, } from "./onchain-constants.js";
2
+ import { resolveGuardConstructor, getGuardConstructorSpec, } from "./reward-ledger.js";
3
+ export const REWARD_FIELD_MUTABILITY = [
4
+ { field: "id", mutability: "immutable", set_at_creation: true },
5
+ { field: "description", mutability: "admin_mutable", permission_index: 151, set_at_creation: true },
6
+ { field: "guards", mutability: "admin_mutable", permission_index: 152, set_at_creation: true },
7
+ { field: "balance", mutability: "runtime", set_at_creation: true },
8
+ { field: "guard_not_added_expiration_time", mutability: "admin_mutable", permission_index: 155, set_at_creation: true },
9
+ { field: "record", mutability: "runtime", set_at_creation: true },
10
+ { field: "um", mutability: "admin_mutable", permission_index: 157, set_at_creation: true },
11
+ { field: "permission", mutability: "admin_mutable", set_at_creation: true },
12
+ ];
13
+ export function initPuzzleFromIntent(intent) {
14
+ const puzzle = {};
15
+ if (intent.action || intent.rule_sentence) {
16
+ puzzle.intent = {
17
+ action: intent.action ?? "create",
18
+ target_reward: intent.target_reward,
19
+ rule_sentence: intent.rule_sentence ?? "",
20
+ failure_conditions: intent.failure_conditions ?? [],
21
+ };
22
+ }
23
+ puzzle.constraints = {
24
+ F_R_01_guard_count_le_200: true,
25
+ F_R_02_record_count_le_5200: true,
26
+ F_R_03_balance_sufficient_for_claim: true,
27
+ F_R_04_guard_not_locked: true,
28
+ F_R_05_guard_not_expired: true,
29
+ F_R_06_recipient_amount_valid_pairing: false,
30
+ F_R_07_coin_type_matches_reward_t: false,
31
+ F_R_08_passport_required_for_claim: false,
32
+ };
33
+ return puzzle;
34
+ }
35
+ export function checkPuzzleCompleteness(puzzle) {
36
+ const missing = [];
37
+ const missing_details = [];
38
+ if (!puzzle.intent) {
39
+ missing.push("A");
40
+ missing_details.push({ dimension: "A", reason: "Intent not specified (action + rule_sentence)" });
41
+ }
42
+ else if (!puzzle.intent.rule_sentence) {
43
+ missing.push("A");
44
+ missing_details.push({ dimension: "A", reason: "rule_sentence is empty" });
45
+ }
46
+ const action = puzzle.intent?.action;
47
+ const isQueryOnly = action === "query";
48
+ const isClaim = action === "claim";
49
+ if (!isQueryOnly) {
50
+ if (action === "create") {
51
+ if (!puzzle.config) {
52
+ missing.push("B");
53
+ missing_details.push({ dimension: "B", reason: "Reward config not specified (coin_type + description + permission)" });
54
+ }
55
+ else if (!puzzle.config.coin_type) {
56
+ missing.push("B");
57
+ missing_details.push({ dimension: "B", reason: "coin_type missing (Reward<T> phantom T)" });
58
+ }
59
+ else if (!puzzle.config.permission && !puzzle.config.permission_is_new) {
60
+ missing.push("B");
61
+ missing_details.push({ dimension: "B", reason: "permission address missing (or set permission_is_new=true)" });
62
+ }
63
+ }
64
+ }
65
+ if (action === "guard_add") {
66
+ if (!puzzle.guard) {
67
+ missing.push("C");
68
+ missing_details.push({ dimension: "C", reason: "Guard config not specified (guard + recipient + amount)" });
69
+ }
70
+ else if (!puzzle.guard.guard) {
71
+ missing.push("C");
72
+ missing_details.push({ dimension: "C", reason: "guard address missing" });
73
+ }
74
+ else {
75
+ const c = resolveGuardConstructor(puzzle.guard.recipient_type, puzzle.guard.amount_type);
76
+ if (!c) {
77
+ missing.push("C");
78
+ missing_details.push({ dimension: "C", reason: `Invalid Recipient × Amount pairing: ${puzzle.guard.recipient_type} × ${puzzle.guard.amount_type}` });
79
+ }
80
+ }
81
+ }
82
+ if (action === "coin_add" || action === "receive" || action === "claim" || action === "owner_receive") {
83
+ if (!puzzle.funds) {
84
+ missing.push("D");
85
+ missing_details.push({ dimension: "D", reason: "Funds data not specified" });
86
+ }
87
+ else if (action === "coin_add" && !puzzle.funds.coin_add_amount) {
88
+ missing.push("D");
89
+ missing_details.push({ dimension: "D", reason: "coin_add_amount missing" });
90
+ }
91
+ else if (action === "receive" && !puzzle.funds.receive_payment) {
92
+ missing.push("D");
93
+ missing_details.push({ dimension: "D", reason: "receive_payment missing (payment address + token_type)" });
94
+ }
95
+ else if (action === "owner_receive" && !puzzle.funds.owner_receive_envelope) {
96
+ missing.push("D");
97
+ missing_details.push({ dimension: "D", reason: "owner_receive_envelope missing (Receiving<K> address)" });
98
+ }
99
+ }
100
+ if (!puzzle.permission) {
101
+ missing.push("E");
102
+ missing_details.push({ dimension: "E", reason: "Permission config not specified" });
103
+ }
104
+ else if (isClaim && !puzzle.permission.requires_passport) {
105
+ missing.push("E");
106
+ missing_details.push({ dimension: "E", reason: "claim requires Passport (requires_passport must be true)" });
107
+ }
108
+ if (!puzzle.constraints) {
109
+ missing.push("F");
110
+ missing_details.push({ dimension: "F", reason: "Constraints not checked" });
111
+ }
112
+ return {
113
+ dimensions: ["A", "B", "C", "D", "E", "F"],
114
+ missing,
115
+ missing_details,
116
+ complete: missing.length === 0,
117
+ next_step: missing.length === 0
118
+ ? "Puzzle complete — ready for confirmation text generation"
119
+ : `Next: complete dimension ${missing[0]} — ${missing_details[0].reason}`,
120
+ };
121
+ }
122
+ export function validateConstraints(puzzle) {
123
+ const violations = [];
124
+ if (puzzle.intent?.action === "claim" && puzzle.funds && puzzle.constraints) {
125
+ if (!puzzle.constraints.F_R_03_balance_sufficient_for_claim) {
126
+ violations.push({
127
+ constraint_id: "F-R-03",
128
+ severity: "HIGH",
129
+ message: "Balance insufficient for claim — E_INSUFFICIENT_BALANCE will abort",
130
+ current_value: puzzle.funds.current_balance,
131
+ limit: puzzle.funds.claim_amount_estimate,
132
+ });
133
+ }
134
+ }
135
+ if (puzzle.intent?.action === "guard_add" && puzzle.constraints && !puzzle.constraints.F_R_04_guard_not_locked) {
136
+ violations.push({
137
+ constraint_id: "F-R-04",
138
+ severity: "HIGH",
139
+ message: "guard_not_added_expiration_time is in the future — E_GUARD_LOCKED_TIME will abort guard_add",
140
+ });
141
+ }
142
+ if ((puzzle.intent?.action === "guard_add" || puzzle.intent?.action === "claim") &&
143
+ puzzle.constraints && !puzzle.constraints.F_R_05_guard_not_expired) {
144
+ violations.push({
145
+ constraint_id: "F-R-05",
146
+ severity: "HIGH",
147
+ message: "guard.expiration_time < now — E_GUARD_EXPIRED will abort",
148
+ });
149
+ }
150
+ if (puzzle.guard) {
151
+ const c = resolveGuardConstructor(puzzle.guard.recipient_type, puzzle.guard.amount_type);
152
+ if (!c) {
153
+ violations.push({
154
+ constraint_id: "F-R-06",
155
+ severity: "HIGH",
156
+ message: `Invalid Recipient × Amount pairing: ${puzzle.guard.recipient_type} × ${puzzle.guard.amount_type} — no matching Move constructor`,
157
+ current_value: `${puzzle.guard.recipient_type} × ${puzzle.guard.amount_type}`,
158
+ limit: "one of 6 valid pairings (see REWARD_GUARD_CONSTRUCTORS)",
159
+ });
160
+ }
161
+ }
162
+ if (puzzle.intent?.action === "coin_add" && puzzle.config && puzzle.funds && puzzle.constraints) {
163
+ if (!puzzle.constraints.F_R_07_coin_type_matches_reward_t) {
164
+ violations.push({
165
+ constraint_id: "F-R-07",
166
+ severity: "CRITICAL",
167
+ message: `coin_add coin type does not match Reward<T> (${puzzle.config.coin_type})`,
168
+ current_value: puzzle.funds.receive_payment?.token_type ?? "(unknown)",
169
+ limit: puzzle.config.coin_type,
170
+ });
171
+ }
172
+ }
173
+ if (puzzle.intent?.action === "claim" && puzzle.permission && !puzzle.permission.requires_passport) {
174
+ violations.push({
175
+ constraint_id: "F-R-08",
176
+ severity: "CRITICAL",
177
+ message: "claim requires Passport — SDK W_ERROR if missing",
178
+ });
179
+ }
180
+ return violations;
181
+ }
182
+ export function generateConfirmationText(puzzle) {
183
+ const lines = [];
184
+ lines.push("═══ Reward Confirmation ═══");
185
+ lines.push("");
186
+ if (puzzle.intent) {
187
+ lines.push(`Action: ${puzzle.intent.action}`);
188
+ if (puzzle.intent.target_reward)
189
+ lines.push(`Target Reward: ${puzzle.intent.target_reward}`);
190
+ lines.push(`Rule: ${puzzle.intent.rule_sentence}`);
191
+ if (puzzle.intent.failure_conditions.length > 0) {
192
+ lines.push("Failure conditions:");
193
+ for (const fc of puzzle.intent.failure_conditions)
194
+ lines.push(` - ${fc}`);
195
+ }
196
+ lines.push("");
197
+ }
198
+ if (puzzle.config) {
199
+ lines.push("─ Reward Config ──────────────");
200
+ lines.push(`Coin type T: ${puzzle.config.coin_type}`);
201
+ lines.push(`Description: ${puzzle.config.description}`);
202
+ lines.push(`Permission: ${puzzle.config.permission} (new: ${puzzle.config.permission_is_new ? "YES" : "NO"})`);
203
+ lines.push("");
204
+ }
205
+ if (puzzle.guard) {
206
+ lines.push("─ Guard Config ──────────────");
207
+ lines.push(`Guard: ${puzzle.guard.guard}`);
208
+ lines.push(`Recipient: ${puzzle.guard.recipient_type}` +
209
+ (puzzle.guard.recipient_param !== undefined ? ` (${puzzle.guard.recipient_param})` : ""));
210
+ lines.push(`Amount: ${puzzle.guard.amount_type} (${puzzle.guard.amount_param})`);
211
+ lines.push(`Constructor: ${puzzle.guard.constructor}`);
212
+ if (puzzle.guard.expiration_time != null) {
213
+ lines.push(`expiration_time: ${puzzle.guard.expiration_time}`);
214
+ }
215
+ if (puzzle.guard.store_from_id != null) {
216
+ lines.push(`store_from_id: ${puzzle.guard.store_from_id}`);
217
+ }
218
+ lines.push("");
219
+ }
220
+ if (puzzle.funds) {
221
+ lines.push("─ Funds ──────────────");
222
+ lines.push(`Current balance: ${puzzle.funds.current_balance}`);
223
+ if (puzzle.funds.coin_add_amount)
224
+ lines.push(`coin_add amount: ${puzzle.funds.coin_add_amount}`);
225
+ if (puzzle.funds.receive_payment) {
226
+ lines.push(`receive payment: ${puzzle.funds.receive_payment.payment} (token: ${puzzle.funds.receive_payment.token_type})`);
227
+ }
228
+ if (puzzle.funds.claim_amount_estimate)
229
+ lines.push(`Estimated claim amount: ${puzzle.funds.claim_amount_estimate}`);
230
+ if (puzzle.funds.owner_receive_envelope)
231
+ lines.push(`owner_receive envelope: ${puzzle.funds.owner_receive_envelope}`);
232
+ lines.push("");
233
+ }
234
+ if (puzzle.permission) {
235
+ lines.push("─ Permission ──────────────");
236
+ if (puzzle.permission.builtin_indexes_used.length > 0) {
237
+ lines.push("Builtin indexes used:");
238
+ for (const p of puzzle.permission.builtin_indexes_used) {
239
+ lines.push(` [${p.index}] ${p.name}: ${p.description}`);
240
+ }
241
+ }
242
+ lines.push(`Permission-free: ${puzzle.permission.is_permission_free ? "YES (claim)" : "NO"}`);
243
+ lines.push(`Requires Passport: ${puzzle.permission.requires_passport ? "YES" : "NO"}`);
244
+ if (puzzle.permission.signer) {
245
+ lines.push(`Signer: ${puzzle.permission.signer} (is_owner: ${puzzle.permission.signer_is_owner ? "YES" : "NO"})`);
246
+ }
247
+ lines.push("");
248
+ }
249
+ const violations = validateConstraints(puzzle);
250
+ if (violations.length > 0) {
251
+ lines.push("─ Constraint Violations ──────────────");
252
+ for (const v of violations)
253
+ lines.push(` [${v.severity}] ${v.constraint_id}: ${v.message}`);
254
+ lines.push("");
255
+ }
256
+ return lines.join("\n");
257
+ }
258
+ export function resolveBuiltinPermission(index) {
259
+ void index;
260
+ return undefined;
261
+ }
262
+ export function requiresGuardConfig(puzzle) {
263
+ return puzzle.intent?.action === "guard_add";
264
+ }
265
+ export function requiresPassport(puzzle) {
266
+ return puzzle.intent?.action === "claim";
267
+ }
268
+ export function getRelevantDimensions(action) {
269
+ const base = ["A", "E", "F"];
270
+ if (action === "create")
271
+ base.push("B");
272
+ if (action === "guard_add")
273
+ base.push("C");
274
+ if (action === "coin_add" || action === "receive" || action === "claim" || action === "owner_receive") {
275
+ base.push("D");
276
+ }
277
+ return base;
278
+ }
279
+ export function getFieldMutability(field) {
280
+ return REWARD_FIELD_MUTABILITY.find(f => f.field === field);
281
+ }
282
+ export function isAdminMutableField(field) {
283
+ return getFieldMutability(field)?.mutability === "admin_mutable";
284
+ }
285
+ export function getFieldPermissionIndex(field) {
286
+ return getFieldMutability(field)?.permission_index;
287
+ }
288
+ export { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, resolveGuardConstructor, getGuardConstructorSpec, };
@@ -0,0 +1,84 @@
1
+ import { type RewardScene, type RewardAmountType } from "./reward-ledger.js";
2
+ export type RewardRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
3
+ export type RewardRiskCategory = "structural" | "semantic" | "permission" | "lifecycle" | "cross_object";
4
+ export interface RewardRisk {
5
+ id: string;
6
+ level: RewardRiskLevel;
7
+ category: RewardRiskCategory;
8
+ title: string;
9
+ description: string;
10
+ affected_stakeholders: RewardStakeholder[];
11
+ scenario: string;
12
+ mitigation: string;
13
+ evidence?: string;
14
+ related_move_error?: string;
15
+ auto_fixable: boolean;
16
+ }
17
+ export type RewardStakeholder = "owner" | "claimer" | "service_provider" | "system";
18
+ export interface RewardRiskRule {
19
+ id: string;
20
+ category: RewardRiskCategory;
21
+ trigger: string;
22
+ check: (ctx: RewardRiskCheckContext) => RewardRisk | null;
23
+ }
24
+ export interface RewardGuardAddEntry {
25
+ guard: string;
26
+ recipient: {
27
+ GuardIdentifier: number;
28
+ } | {
29
+ Entity: string;
30
+ } | {
31
+ Signer: unknown;
32
+ };
33
+ amount: {
34
+ type: RewardAmountType | string;
35
+ value: number | string;
36
+ };
37
+ expiration_time?: number;
38
+ store_from_id?: number | null;
39
+ }
40
+ export interface RewardRiskCheckContext {
41
+ object?: string | null;
42
+ claim?: string;
43
+ description?: string;
44
+ coin_add?: {
45
+ amount: string | number;
46
+ coin_type: string;
47
+ };
48
+ receive?: {
49
+ token_type: string;
50
+ };
51
+ guard_add?: RewardGuardAddEntry[];
52
+ guard_remove_expired?: boolean;
53
+ guard_expiration_time?: number | null;
54
+ owner_receive?: unknown;
55
+ um?: string | null;
56
+ reward_type?: string;
57
+ current_balance?: string;
58
+ current_guard_count?: number;
59
+ current_record_count_for_recipient?: number;
60
+ current_guard_not_added_expiration_time?: number | null;
61
+ current_clock_ms?: number;
62
+ permission_address?: string;
63
+ signer?: string;
64
+ target_guard_addresses?: string[];
65
+ passport_submission_value_types?: Record<number, string>;
66
+ passport_identifier_is_address?: Record<number, boolean>;
67
+ guard_store_from_id_compatible?: Record<string, boolean>;
68
+ }
69
+ export declare const REWARD_RISK_VERSION = "1.0.0";
70
+ export declare function getAllRewardRiskRules(): RewardRiskRule[];
71
+ export declare function getRewardRiskRulesCount(): number;
72
+ export declare function getRewardRiskRulesByCategory(category: RewardRiskCategory): RewardRiskRule[];
73
+ export interface RewardRiskAssessment {
74
+ summary: string;
75
+ scene?: RewardScene;
76
+ risks: RewardRisk[];
77
+ overall_risk: RewardRiskLevel;
78
+ risks_by_category: Partial<Record<RewardRiskCategory, number>>;
79
+ stakeholder_advice: Partial<Record<RewardStakeholder, string[]>>;
80
+ needs_human_review: boolean;
81
+ }
82
+ export declare function assessRewardRisks(ctx: RewardRiskCheckContext): RewardRiskAssessment;
83
+ export declare const REWARD_STAKEHOLDERS: RewardStakeholder[];
84
+ export declare function getRewardRiskRulesByStakeholder(stakeholder: RewardStakeholder): RewardRiskRule[];