@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,158 @@
1
+ import { type ServicePermissionEntry } from "./service-ledger.js";
2
+ export interface ServiceIntentPuzzle {
3
+ action: "create" | "modify" | "publish" | "pause" | "order" | "compensate" | "query";
4
+ business_scenario: "retail" | "service" | "digital_goods" | "rental" | "freelance" | "travel_package" | "subscription" | "general";
5
+ lifecycle_phase: "draft" | "published" | "paused" | "deprecated";
6
+ primary_goal: string;
7
+ failure_conditions: string[];
8
+ }
9
+ export interface ServiceBindingPuzzle {
10
+ coin_type: string;
11
+ permission: string;
12
+ owner: string;
13
+ admins: string[];
14
+ um?: string | null;
15
+ machine?: string | null;
16
+ buy_guard?: string | null;
17
+ order_allocators?: object | null;
18
+ arbitrations: string[];
19
+ rewards: string[];
20
+ repositories: string[];
21
+ compensation_fund_balance: string;
22
+ setting_lock_duration: string;
23
+ }
24
+ export interface ServicePermissionAllocatorPuzzle {
25
+ permission_indexes_used: ServicePermissionEntry[];
26
+ allocators_configured: boolean;
27
+ allocators_summary?: string;
28
+ guards_bound: {
29
+ kind: "buy_guard";
30
+ address: string;
31
+ }[];
32
+ treasury_addresses_referenced: string[];
33
+ }
34
+ export interface ServiceGuardProtectionPuzzle {
35
+ buy_guard_set: boolean;
36
+ buy_guard_address?: string;
37
+ buy_guard_post_publish_mutable: boolean;
38
+ allocators_guards_count: number;
39
+ repository_guards_count: number;
40
+ }
41
+ export interface ServiceDisputeHandlingPuzzle {
42
+ arbitrations_count: number;
43
+ arbitrations_addresses: string[];
44
+ compensation_fund_configured: boolean;
45
+ compensation_fund_balance: string;
46
+ setting_lock_duration_ms: string;
47
+ setting_lock_duration_can_only_increase: boolean;
48
+ publish_prerequisites_met: boolean;
49
+ publish_blockers: string[];
50
+ }
51
+ export interface ServiceConstraintChecklist {
52
+ F_S_01_description_length_le_4000: boolean;
53
+ F_S_02_sales_count_le_50: boolean;
54
+ F_S_03_repositories_count_le_100: boolean;
55
+ F_S_04_arbitrations_count_le_20: boolean;
56
+ F_S_05_rewards_count_le_20: boolean;
57
+ F_S_06_customer_required_count_le_10: boolean;
58
+ F_S_07_customer_required_each_le_20: boolean;
59
+ F_S_08_discount_once_le_1000: boolean;
60
+ F_S_09_discount_receivers_le_1000: boolean;
61
+ F_S_10_discount_total_le_20000: boolean;
62
+ F_S_11_wip_url_length_le_1024: boolean;
63
+ F_S_12_wip_hash_length_le_64: boolean;
64
+ F_S_13_wip_hash_not_empty: boolean;
65
+ F_S_14_quote_stock_sufficient: boolean;
66
+ F_S_15_quote_sale_not_suspended: boolean;
67
+ F_S_16_buy_requires_published: boolean;
68
+ F_S_17_buy_requires_not_paused: boolean;
69
+ F_S_18_publish_requires_order_allocators: boolean;
70
+ F_S_19_publish_compensation_fund_requires_arbitrations: boolean;
71
+ F_S_20_machine_immutable_post_publish: boolean;
72
+ F_S_21_arbitrations_immutable_post_publish: boolean;
73
+ F_S_22_order_allocators_immutable_post_publish: boolean;
74
+ F_S_23_bPublished_irreversible: boolean;
75
+ F_S_24_setting_lock_duration_only_increases: boolean;
76
+ F_S_25_compensation_fund_withdraw_locked_by_duration: boolean;
77
+ F_S_26_compensation_fund_withdraw_requires_paused: boolean;
78
+ F_S_27_quote_deducts_stock_side_effect: boolean;
79
+ F_S_28_order_service_must_match: boolean;
80
+ F_S_29_order_one_to_one_with_service: boolean;
81
+ F_S_30_permission_indexes_300_to_320: boolean;
82
+ }
83
+ export type ServicePuzzleDimension = "A" | "B" | "C" | "D" | "E" | "F";
84
+ export interface ServicePuzzle {
85
+ intent?: ServiceIntentPuzzle;
86
+ binding?: ServiceBindingPuzzle;
87
+ permission_allocator?: ServicePermissionAllocatorPuzzle;
88
+ guard_protection?: ServiceGuardProtectionPuzzle;
89
+ dispute_handling?: ServiceDisputeHandlingPuzzle;
90
+ constraints?: ServiceConstraintChecklist;
91
+ }
92
+ export interface ServicePuzzleCompleteness {
93
+ dimensions: ServicePuzzleDimension[];
94
+ missing: ServicePuzzleDimension[];
95
+ missing_details: {
96
+ dimension: ServicePuzzleDimension;
97
+ reason: string;
98
+ }[];
99
+ complete: boolean;
100
+ next_step: string;
101
+ }
102
+ export interface ServiceOrderFlowPuzzle {
103
+ stage_1_pre_check: {
104
+ bPublished: boolean;
105
+ bPaused: boolean;
106
+ buy_guard?: string;
107
+ ready: boolean;
108
+ };
109
+ stage_2_wip_verify: {
110
+ items_count: number;
111
+ wip_verified: boolean;
112
+ wip_hash_mismatches: string[];
113
+ };
114
+ stage_3_quote: {
115
+ items_quoted: number;
116
+ stock_sufficient: boolean;
117
+ discount_applied: boolean;
118
+ total_pay: string;
119
+ };
120
+ stage_4_create_order: {
121
+ order_created: boolean;
122
+ passport_used: boolean;
123
+ };
124
+ stage_5_create_allocation: {
125
+ allocation_created: boolean;
126
+ allocators_configured: boolean;
127
+ };
128
+ stage_6_create_progress: {
129
+ progress_created: boolean;
130
+ machine_bound: boolean;
131
+ };
132
+ stage_7_post_actions: {
133
+ agents_set: boolean;
134
+ required_info_set: boolean;
135
+ transfer_set: boolean;
136
+ };
137
+ stage_8_return_result: {
138
+ order_address?: string;
139
+ allocation_address?: string;
140
+ progress_address?: string;
141
+ };
142
+ }
143
+ export declare function initPuzzleFromIntent(intent: Partial<ServiceIntentPuzzle>): ServicePuzzle;
144
+ export declare function checkPuzzleCompleteness(puzzle: ServicePuzzle): ServicePuzzleCompleteness;
145
+ export interface ServiceConstraintViolation {
146
+ constraint_id: string;
147
+ severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
148
+ message: string;
149
+ current_value?: string | number;
150
+ limit?: string | number;
151
+ }
152
+ export declare function validateConstraints(puzzle: ServicePuzzle): ServiceConstraintViolation[];
153
+ export declare function generateConfirmationText(puzzle: ServicePuzzle): string;
154
+ export declare function initOrderFlowPuzzle(buy_items_count: number, machine_bound: boolean): ServiceOrderFlowPuzzle;
155
+ export declare function checkOrderFlowCompleteness(flow: ServiceOrderFlowPuzzle): {
156
+ complete: boolean;
157
+ blockers: string[];
158
+ };
@@ -0,0 +1,236 @@
1
+ import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_COUNT_ONCE, MAX_DISCOUNT_TOTAL_COUNT, MAX_REQUIRED_INFO_SIZE, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, } from "@wowok/wowok";
2
+ export function initPuzzleFromIntent(intent) {
3
+ const puzzle = {};
4
+ if (intent.action || intent.primary_goal) {
5
+ puzzle.intent = {
6
+ action: intent.action ?? "create",
7
+ business_scenario: intent.business_scenario ?? "general",
8
+ lifecycle_phase: intent.lifecycle_phase ?? "draft",
9
+ primary_goal: intent.primary_goal ?? "",
10
+ failure_conditions: intent.failure_conditions ?? [],
11
+ };
12
+ }
13
+ puzzle.constraints = {
14
+ F_S_01_description_length_le_4000: true,
15
+ F_S_02_sales_count_le_50: true,
16
+ F_S_03_repositories_count_le_100: true,
17
+ F_S_04_arbitrations_count_le_20: true,
18
+ F_S_05_rewards_count_le_20: true,
19
+ F_S_06_customer_required_count_le_10: true,
20
+ F_S_07_customer_required_each_le_20: true,
21
+ F_S_08_discount_once_le_1000: true,
22
+ F_S_09_discount_receivers_le_1000: true,
23
+ F_S_10_discount_total_le_20000: true,
24
+ F_S_11_wip_url_length_le_1024: true,
25
+ F_S_12_wip_hash_length_le_64: true,
26
+ F_S_13_wip_hash_not_empty: true,
27
+ F_S_14_quote_stock_sufficient: true,
28
+ F_S_15_quote_sale_not_suspended: true,
29
+ F_S_16_buy_requires_published: true,
30
+ F_S_17_buy_requires_not_paused: true,
31
+ F_S_18_publish_requires_order_allocators: true,
32
+ F_S_19_publish_compensation_fund_requires_arbitrations: true,
33
+ F_S_20_machine_immutable_post_publish: true,
34
+ F_S_21_arbitrations_immutable_post_publish: true,
35
+ F_S_22_order_allocators_immutable_post_publish: true,
36
+ F_S_23_bPublished_irreversible: true,
37
+ F_S_24_setting_lock_duration_only_increases: true,
38
+ F_S_25_compensation_fund_withdraw_locked_by_duration: true,
39
+ F_S_26_compensation_fund_withdraw_requires_paused: true,
40
+ F_S_27_quote_deducts_stock_side_effect: true,
41
+ F_S_28_order_service_must_match: true,
42
+ F_S_29_order_one_to_one_with_service: true,
43
+ F_S_30_permission_indexes_300_to_320: true,
44
+ };
45
+ return puzzle;
46
+ }
47
+ export function checkPuzzleCompleteness(puzzle) {
48
+ const missing = [];
49
+ const missing_details = [];
50
+ if (!puzzle.intent) {
51
+ missing.push("A");
52
+ missing_details.push({ dimension: "A", reason: "Intent not specified (action + primary_goal)" });
53
+ }
54
+ else if (!puzzle.intent.primary_goal) {
55
+ missing.push("A");
56
+ missing_details.push({ dimension: "A", reason: "primary_goal is empty" });
57
+ }
58
+ if (!puzzle.binding) {
59
+ missing.push("B");
60
+ missing_details.push({ dimension: "B", reason: "Binding not specified (coin_type + permission + owner)" });
61
+ }
62
+ else if (!puzzle.binding.coin_type || !puzzle.binding.permission || !puzzle.binding.owner) {
63
+ missing.push("B");
64
+ missing_details.push({ dimension: "B", reason: "coin_type / permission / owner missing" });
65
+ }
66
+ if (!puzzle.permission_allocator && puzzle.intent?.action === "create") {
67
+ missing.push("C");
68
+ missing_details.push({ dimension: "C", reason: "Permission/allocator config not specified" });
69
+ }
70
+ if (!puzzle.guard_protection) {
71
+ missing.push("D");
72
+ missing_details.push({ dimension: "D", reason: "Guard protection not enumerated" });
73
+ }
74
+ if (!puzzle.dispute_handling && puzzle.intent?.action === "publish") {
75
+ missing.push("E");
76
+ missing_details.push({ dimension: "E", reason: "Dispute handling not configured (needed for publish)" });
77
+ }
78
+ if (!puzzle.constraints) {
79
+ missing.push("F");
80
+ missing_details.push({ dimension: "F", reason: "Constraints not checked" });
81
+ }
82
+ return {
83
+ dimensions: ["A", "B", "C", "D", "E", "F"],
84
+ missing,
85
+ missing_details,
86
+ complete: missing.length === 0,
87
+ next_step: missing.length === 0
88
+ ? "Puzzle complete — ready for confirmation text generation"
89
+ : `Next: complete dimension ${missing[0]} — ${missing_details[0].reason}`,
90
+ };
91
+ }
92
+ export function validateConstraints(puzzle) {
93
+ const violations = [];
94
+ if (!puzzle.constraints)
95
+ return violations;
96
+ const c = puzzle.constraints;
97
+ const checks = [
98
+ [!c.F_S_02_sales_count_le_50, "F-S-02", "CRITICAL", "sales count", MAX_SALE_COUNT],
99
+ [!c.F_S_03_repositories_count_le_100, "F-S-03", "HIGH", "repositories count", MAX_REPOSITORY_COUNT],
100
+ [!c.F_S_04_arbitrations_count_le_20, "F-S-04", "HIGH", "arbitrations count", MAX_ARBITRATION_COUNT],
101
+ [!c.F_S_05_rewards_count_le_20, "F-S-05", "MEDIUM", "rewards count", 20],
102
+ [!c.F_S_06_customer_required_count_le_10, "F-S-06", "MEDIUM", "customer_required count", 10],
103
+ [!c.F_S_07_customer_required_each_le_20, "F-S-07", "LOW", "customer_required item length", MAX_REQUIRED_INFO_SIZE],
104
+ [!c.F_S_08_discount_once_le_1000, "F-S-08", "MEDIUM", "discount count (once)", MAX_DISCOUNT_COUNT_ONCE],
105
+ [!c.F_S_10_discount_total_le_20000, "F-S-10", "MEDIUM", "discount total count", MAX_DISCOUNT_TOTAL_COUNT],
106
+ [!c.F_S_11_wip_url_length_le_1024, "F-S-11", "HIGH", "wip URL length", MAX_WIP_LENGTH],
107
+ [!c.F_S_12_wip_hash_length_le_64, "F-S-12", "HIGH", "wip_hash length", MAX_WIP_HASH_LENGTH],
108
+ [!c.F_S_13_wip_hash_not_empty, "F-S-13", "CRITICAL", "wip_hash empty", undefined],
109
+ [!c.F_S_18_publish_requires_order_allocators, "F-S-18", "CRITICAL", "publish without order_allocators", undefined],
110
+ [!c.F_S_19_publish_compensation_fund_requires_arbitrations, "F-S-19", "CRITICAL", "publish with compensation_fund > 0 but no arbitrations", undefined],
111
+ ];
112
+ for (const [failed, id, sev, msg, limit] of checks) {
113
+ if (failed) {
114
+ violations.push({
115
+ constraint_id: id,
116
+ severity: sev,
117
+ message: `${msg} violates ${id}`,
118
+ limit,
119
+ });
120
+ }
121
+ }
122
+ return violations;
123
+ }
124
+ export function generateConfirmationText(puzzle) {
125
+ const lines = [];
126
+ lines.push("═══ Service Confirmation ═══");
127
+ lines.push("");
128
+ if (puzzle.intent) {
129
+ lines.push(`Action: ${puzzle.intent.action}`);
130
+ lines.push(`Scenario: ${puzzle.intent.business_scenario}`);
131
+ lines.push(`Lifecycle: ${puzzle.intent.lifecycle_phase}`);
132
+ lines.push(`Goal: ${puzzle.intent.primary_goal}`);
133
+ if (puzzle.intent.failure_conditions.length > 0) {
134
+ lines.push("Failure conditions:");
135
+ for (const fc of puzzle.intent.failure_conditions)
136
+ lines.push(` - ${fc}`);
137
+ }
138
+ lines.push("");
139
+ }
140
+ if (puzzle.binding) {
141
+ lines.push("─ Binding ──────────────");
142
+ lines.push(`Coin type: ${puzzle.binding.coin_type}`);
143
+ lines.push(`Permission: ${puzzle.binding.permission}`);
144
+ lines.push(`Owner: ${puzzle.binding.owner}`);
145
+ lines.push(`Admins (${puzzle.binding.admins.length}): ${puzzle.binding.admins.join(", ")}`);
146
+ if (puzzle.binding.um !== undefined)
147
+ lines.push(`UM: ${puzzle.binding.um ?? "(none)"}`);
148
+ if (puzzle.binding.machine !== undefined)
149
+ lines.push(`Machine: ${puzzle.binding.machine ?? "(none)"} ${puzzle.intent?.lifecycle_phase === "published" ? "[LOCKED]" : ""}`);
150
+ if (puzzle.binding.buy_guard !== undefined)
151
+ lines.push(`Buy Guard: ${puzzle.binding.buy_guard ?? "(none)"} [mutable post-publish]`);
152
+ if (puzzle.binding.order_allocators !== undefined)
153
+ lines.push(`Order Allocators: ${puzzle.binding.order_allocators ? "configured" : "(none)"} ${puzzle.intent?.lifecycle_phase === "published" ? "[LOCKED]" : ""}`);
154
+ lines.push(`Arbitrations (${puzzle.binding.arbitrations.length}): ${puzzle.binding.arbitrations.join(", ")}`);
155
+ lines.push(`Rewards (${puzzle.binding.rewards.length})`);
156
+ lines.push(`Repositories (${puzzle.binding.repositories.length})`);
157
+ lines.push(`Compensation fund: ${puzzle.binding.compensation_fund_balance}`);
158
+ lines.push(`Setting lock duration: ${puzzle.binding.setting_lock_duration} ms`);
159
+ lines.push("");
160
+ }
161
+ if (puzzle.permission_allocator) {
162
+ lines.push("─ Permission / Allocators ──────────────");
163
+ lines.push(`Permission indexes used (${puzzle.permission_allocator.permission_indexes_used.length}):`);
164
+ for (const p of puzzle.permission_allocator.permission_indexes_used) {
165
+ lines.push(` [${p.index}] ${p.name}: ${p.description}`);
166
+ }
167
+ lines.push(`Allocators configured: ${puzzle.permission_allocator.allocators_configured}`);
168
+ if (puzzle.permission_allocator.allocators_summary) {
169
+ lines.push(`Allocators summary: ${puzzle.permission_allocator.allocators_summary}`);
170
+ }
171
+ lines.push("");
172
+ }
173
+ if (puzzle.guard_protection) {
174
+ lines.push("─ Guard Protection ──────────────");
175
+ lines.push(`Buy guard set: ${puzzle.guard_protection.buy_guard_set}`);
176
+ if (puzzle.guard_protection.buy_guard_address) {
177
+ lines.push(`Buy guard: ${puzzle.guard_protection.buy_guard_address}`);
178
+ }
179
+ lines.push(`Buy guard post-publish mutable: ${puzzle.guard_protection.buy_guard_post_publish_mutable}`);
180
+ lines.push(`Allocators guards: ${puzzle.guard_protection.allocators_guards_count}`);
181
+ lines.push(`Repository guards: ${puzzle.guard_protection.repository_guards_count}`);
182
+ lines.push("");
183
+ }
184
+ if (puzzle.dispute_handling) {
185
+ lines.push("─ Dispute Handling ──────────────");
186
+ lines.push(`Arbitrations: ${puzzle.dispute_handling.arbitrations_count}`);
187
+ lines.push(`Compensation fund: ${puzzle.dispute_handling.compensation_fund_balance}`);
188
+ lines.push(`Setting lock duration: ${puzzle.dispute_handling.setting_lock_duration_ms} ms (only-increase: ${puzzle.dispute_handling.setting_lock_duration_can_only_increase})`);
189
+ lines.push(`Publish prerequisites met: ${puzzle.dispute_handling.publish_prerequisites_met}`);
190
+ if (puzzle.dispute_handling.publish_blockers.length > 0) {
191
+ lines.push(`Publish blockers:`);
192
+ for (const b of puzzle.dispute_handling.publish_blockers)
193
+ lines.push(` - ${b}`);
194
+ }
195
+ lines.push("");
196
+ }
197
+ const violations = validateConstraints(puzzle);
198
+ if (violations.length > 0) {
199
+ lines.push("─ Constraint Violations ──────────────");
200
+ for (const v of violations)
201
+ lines.push(` [${v.severity}] ${v.constraint_id}: ${v.message}`);
202
+ lines.push("");
203
+ }
204
+ return lines.join("\n");
205
+ }
206
+ export function initOrderFlowPuzzle(buy_items_count, machine_bound) {
207
+ return {
208
+ stage_1_pre_check: { bPublished: false, bPaused: false, ready: false },
209
+ stage_2_wip_verify: { items_count: buy_items_count, wip_verified: false, wip_hash_mismatches: [] },
210
+ stage_3_quote: { items_quoted: 0, stock_sufficient: false, discount_applied: false, total_pay: "0" },
211
+ stage_4_create_order: { order_created: false, passport_used: false },
212
+ stage_5_create_allocation: { allocation_created: false, allocators_configured: false },
213
+ stage_6_create_progress: { progress_created: false, machine_bound },
214
+ stage_7_post_actions: { agents_set: false, required_info_set: false, transfer_set: false },
215
+ stage_8_return_result: {},
216
+ };
217
+ }
218
+ export function checkOrderFlowCompleteness(flow) {
219
+ const blockers = [];
220
+ if (!flow.stage_1_pre_check.ready)
221
+ blockers.push("Stage 1 pre_check failed: bPublished && !bPaused required");
222
+ if (!flow.stage_2_wip_verify.wip_verified)
223
+ blockers.push("Stage 2 wip_verify failed: WIP hash mismatch");
224
+ if (flow.stage_2_wip_verify.wip_hash_mismatches.length > 0)
225
+ blockers.push(`Stage 2 mismatched items: ${flow.stage_2_wip_verify.wip_hash_mismatches.join(", ")}`);
226
+ if (!flow.stage_3_quote.stock_sufficient)
227
+ blockers.push("Stage 3 quote failed: stock insufficient");
228
+ if (!flow.stage_4_create_order.order_created)
229
+ blockers.push("Stage 4 create_order failed");
230
+ if (!flow.stage_5_create_allocation.allocation_created)
231
+ blockers.push("Stage 5 create_allocation failed (allocators not configured?)");
232
+ if (flow.stage_6_create_progress.machine_bound && !flow.stage_6_create_progress.progress_created) {
233
+ blockers.push("Stage 6 create_progress failed (machine bound but progress not created)");
234
+ }
235
+ return { complete: blockers.length === 0, blockers };
236
+ }
@@ -0,0 +1,108 @@
1
+ import { type ServiceScene } from "./service-ledger.js";
2
+ export type ServiceRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
3
+ export type ServiceRiskCategory = "structural" | "semantic" | "authority" | "lifecycle" | "cross_object";
4
+ export interface ServiceRisk {
5
+ id: string;
6
+ level: ServiceRiskLevel;
7
+ category: ServiceRiskCategory;
8
+ title: string;
9
+ description: string;
10
+ affected_stakeholders: ServiceStakeholder[];
11
+ scenario: string;
12
+ mitigation: string;
13
+ evidence?: string;
14
+ }
15
+ export type ServiceStakeholder = "owner" | "customer" | "provider" | "arbitrator" | "system";
16
+ export interface ServiceRiskRule {
17
+ id: string;
18
+ category: ServiceRiskCategory;
19
+ trigger: string;
20
+ check: (ctx: ServiceRiskCheckContext) => ServiceRisk | null;
21
+ }
22
+ export interface ServiceRiskCheckContext {
23
+ object?: string | null;
24
+ description?: string;
25
+ location?: string;
26
+ sales?: {
27
+ op: "add" | "set";
28
+ sales: Array<{
29
+ name: string;
30
+ wip: string;
31
+ wip_hash: string;
32
+ }>;
33
+ } | {
34
+ op: "remove";
35
+ sales_name: string[];
36
+ } | {
37
+ op: "clear";
38
+ };
39
+ repositories?: {
40
+ op: "add" | "set" | "remove";
41
+ objects: string[];
42
+ } | {
43
+ op: "clear";
44
+ };
45
+ rewards?: {
46
+ op: "add" | "set" | "remove";
47
+ objects: string[];
48
+ } | {
49
+ op: "clear";
50
+ };
51
+ arbitrations?: {
52
+ op: "add" | "set" | "remove";
53
+ objects: string[];
54
+ } | {
55
+ op: "clear";
56
+ };
57
+ machine?: string | null;
58
+ discount?: {
59
+ name: string;
60
+ count: number;
61
+ };
62
+ customer_required?: string[];
63
+ order_allocators?: object | null;
64
+ buy_guard?: string | null;
65
+ compensation_fund_add?: {
66
+ balance: string | number;
67
+ };
68
+ setting_locked_time_add?: number;
69
+ compensation_fund_receive?: unknown;
70
+ owner_receive?: unknown;
71
+ pause?: boolean;
72
+ publish?: boolean;
73
+ um?: string | null;
74
+ order_new?: {
75
+ buy: {
76
+ items: Array<{
77
+ name: string;
78
+ wip_hash: string;
79
+ }>;
80
+ };
81
+ };
82
+ current_bPublished?: boolean;
83
+ current_bPaused?: boolean;
84
+ current_compensation_fund_balance?: string;
85
+ current_setting_lock_duration?: string;
86
+ current_arbitrations_count?: number;
87
+ current_rewards_count?: number;
88
+ current_repositories_count?: number;
89
+ current_sales_count?: number;
90
+ current_machine_bound?: boolean;
91
+ current_order_allocators_set?: boolean;
92
+ builder?: string;
93
+ target_objects_types?: string[];
94
+ }
95
+ export declare const SERVICE_RISK_VERSION = "1.0.0";
96
+ export declare function getAllServiceRiskRules(): ServiceRiskRule[];
97
+ export declare function getServiceRiskRulesCount(): number;
98
+ export declare function getServiceRiskRulesByCategory(category: ServiceRiskCategory): ServiceRiskRule[];
99
+ export interface ServiceRiskAssessment {
100
+ summary: string;
101
+ scene?: ServiceScene;
102
+ risks: ServiceRisk[];
103
+ overall_risk: ServiceRiskLevel;
104
+ risks_by_category: Partial<Record<ServiceRiskCategory, number>>;
105
+ stakeholder_advice: Partial<Record<ServiceStakeholder, string[]>>;
106
+ needs_human_review: boolean;
107
+ }
108
+ export declare function assessServiceRisks(ctx: ServiceRiskCheckContext): ServiceRiskAssessment;