@wowok/agent-mcp 2.4.1 → 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 (348) 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.d.ts +2 -2
  6. package/dist/index.js +29 -1621
  7. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  8. package/dist/knowledge/allocation-confirm.js +534 -0
  9. package/dist/knowledge/allocation-context.d.ts +58 -0
  10. package/dist/knowledge/allocation-context.js +249 -0
  11. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  12. package/dist/knowledge/allocation-ledger.js +463 -0
  13. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  14. package/dist/knowledge/allocation-puzzle.js +298 -0
  15. package/dist/knowledge/allocation-risk.d.ts +78 -0
  16. package/dist/knowledge/allocation-risk.js +568 -0
  17. package/dist/knowledge/allocation-templates.d.ts +38 -0
  18. package/dist/knowledge/allocation-templates.js +970 -0
  19. package/dist/knowledge/allocation-translation.d.ts +72 -0
  20. package/dist/knowledge/allocation-translation.js +585 -0
  21. package/dist/knowledge/arb-risk.d.ts +37 -0
  22. package/dist/knowledge/arb-risk.js +210 -0
  23. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  24. package/dist/knowledge/arbitration-confirm.js +559 -0
  25. package/dist/knowledge/arbitration-context.d.ts +81 -0
  26. package/dist/knowledge/arbitration-context.js +505 -0
  27. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  28. package/dist/knowledge/arbitration-ledger.js +521 -0
  29. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  30. package/dist/knowledge/arbitration-puzzle.js +304 -0
  31. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  32. package/dist/knowledge/arbitration-risk.js +433 -0
  33. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  34. package/dist/knowledge/arbitration-templates.js +276 -0
  35. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  36. package/dist/knowledge/arbitration-translation.js +487 -0
  37. package/dist/knowledge/bridge-risk.d.ts +36 -0
  38. package/dist/knowledge/bridge-risk.js +263 -0
  39. package/dist/knowledge/contact-risk.d.ts +32 -0
  40. package/dist/knowledge/contact-risk.js +200 -0
  41. package/dist/knowledge/demand-confirm.d.ts +32 -0
  42. package/dist/knowledge/demand-confirm.js +206 -0
  43. package/dist/knowledge/demand-risk.d.ts +30 -0
  44. package/dist/knowledge/demand-risk.js +240 -0
  45. package/dist/knowledge/demand-translation.d.ts +55 -0
  46. package/dist/knowledge/demand-translation.js +354 -0
  47. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  48. package/dist/knowledge/deployment-scanner.js +762 -0
  49. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  50. package/dist/knowledge/examples-scanner-cli.js +26 -0
  51. package/dist/knowledge/examples-scanner.d.ts +121 -0
  52. package/dist/knowledge/examples-scanner.js +825 -0
  53. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  54. package/dist/knowledge/flywheel-loop.js +32 -3
  55. package/dist/knowledge/glossary.js +3 -1
  56. package/dist/knowledge/guard-confirm.d.ts +86 -0
  57. package/dist/knowledge/guard-confirm.js +406 -0
  58. package/dist/knowledge/guard-context.d.ts +56 -0
  59. package/dist/knowledge/guard-context.js +287 -0
  60. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  61. package/dist/knowledge/guard-design-patterns.js +257 -0
  62. package/dist/knowledge/guard-ledger.js +14 -0
  63. package/dist/knowledge/guard-lint.d.ts +1 -0
  64. package/dist/knowledge/guard-lint.js +83 -3
  65. package/dist/knowledge/guard-migration.d.ts +48 -0
  66. package/dist/knowledge/guard-migration.js +228 -0
  67. package/dist/knowledge/guard-puzzle.js +3 -2
  68. package/dist/knowledge/guard-risk.d.ts +3 -1
  69. package/dist/knowledge/guard-risk.js +832 -64
  70. package/dist/knowledge/guard-templates.d.ts +1 -0
  71. package/dist/knowledge/guard-templates.js +278 -2
  72. package/dist/knowledge/guard-translation.js +6 -5
  73. package/dist/knowledge/index.d.ts +342 -0
  74. package/dist/knowledge/index.js +344 -0
  75. package/dist/knowledge/machine-confirm.d.ts +102 -0
  76. package/dist/knowledge/machine-confirm.js +559 -0
  77. package/dist/knowledge/machine-context.d.ts +160 -0
  78. package/dist/knowledge/machine-context.js +812 -0
  79. package/dist/knowledge/machine-ledger.d.ts +41 -0
  80. package/dist/knowledge/machine-ledger.js +315 -0
  81. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  82. package/dist/knowledge/machine-puzzle.js +494 -0
  83. package/dist/knowledge/machine-risk.d.ts +75 -0
  84. package/dist/knowledge/machine-risk.js +644 -0
  85. package/dist/knowledge/machine-templates.d.ts +92 -0
  86. package/dist/knowledge/machine-templates.js +1592 -0
  87. package/dist/knowledge/machine-topology.d.ts +57 -0
  88. package/dist/knowledge/machine-topology.js +234 -0
  89. package/dist/knowledge/machine-translation.d.ts +96 -0
  90. package/dist/knowledge/machine-translation.js +513 -0
  91. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  92. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  93. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  94. package/dist/knowledge/mcp-schema-audit.js +772 -0
  95. package/dist/knowledge/onchain-constants.d.ts +4 -0
  96. package/dist/knowledge/onchain-constants.js +35 -0
  97. package/dist/knowledge/order-confirm.d.ts +115 -0
  98. package/dist/knowledge/order-confirm.js +573 -0
  99. package/dist/knowledge/order-context.d.ts +66 -0
  100. package/dist/knowledge/order-context.js +390 -0
  101. package/dist/knowledge/order-ledger.d.ts +69 -0
  102. package/dist/knowledge/order-ledger.js +341 -0
  103. package/dist/knowledge/order-puzzle.d.ts +159 -0
  104. package/dist/knowledge/order-puzzle.js +255 -0
  105. package/dist/knowledge/order-risk.d.ts +66 -0
  106. package/dist/knowledge/order-risk.js +653 -0
  107. package/dist/knowledge/order-templates.d.ts +50 -0
  108. package/dist/knowledge/order-templates.js +368 -0
  109. package/dist/knowledge/order-translation.d.ts +78 -0
  110. package/dist/knowledge/order-translation.js +550 -0
  111. package/dist/knowledge/passport-confirm.d.ts +130 -0
  112. package/dist/knowledge/passport-confirm.js +531 -0
  113. package/dist/knowledge/passport-context.d.ts +59 -0
  114. package/dist/knowledge/passport-context.js +306 -0
  115. package/dist/knowledge/passport-ledger.d.ts +48 -0
  116. package/dist/knowledge/passport-ledger.js +282 -0
  117. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  118. package/dist/knowledge/passport-puzzle.js +333 -0
  119. package/dist/knowledge/passport-risk.d.ts +70 -0
  120. package/dist/knowledge/passport-risk.js +450 -0
  121. package/dist/knowledge/passport-templates.d.ts +40 -0
  122. package/dist/knowledge/passport-templates.js +568 -0
  123. package/dist/knowledge/passport-translation.d.ts +68 -0
  124. package/dist/knowledge/passport-translation.js +516 -0
  125. package/dist/knowledge/payment-risk.d.ts +33 -0
  126. package/dist/knowledge/payment-risk.js +182 -0
  127. package/dist/knowledge/permission-confirm.d.ts +110 -0
  128. package/dist/knowledge/permission-confirm.js +426 -0
  129. package/dist/knowledge/permission-context.d.ts +58 -0
  130. package/dist/knowledge/permission-context.js +224 -0
  131. package/dist/knowledge/permission-ledger.d.ts +38 -0
  132. package/dist/knowledge/permission-ledger.js +403 -0
  133. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  134. package/dist/knowledge/permission-puzzle.js +173 -0
  135. package/dist/knowledge/permission-risk.d.ts +76 -0
  136. package/dist/knowledge/permission-risk.js +411 -0
  137. package/dist/knowledge/permission-templates.d.ts +38 -0
  138. package/dist/knowledge/permission-templates.js +234 -0
  139. package/dist/knowledge/permission-translation.d.ts +57 -0
  140. package/dist/knowledge/permission-translation.js +350 -0
  141. package/dist/knowledge/personal-risk.d.ts +36 -0
  142. package/dist/knowledge/personal-risk.js +212 -0
  143. package/dist/knowledge/progress-confirm.d.ts +108 -0
  144. package/dist/knowledge/progress-confirm.js +456 -0
  145. package/dist/knowledge/progress-context.d.ts +123 -0
  146. package/dist/knowledge/progress-context.js +452 -0
  147. package/dist/knowledge/progress-ledger.d.ts +63 -0
  148. package/dist/knowledge/progress-ledger.js +327 -0
  149. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  150. package/dist/knowledge/progress-puzzle.js +219 -0
  151. package/dist/knowledge/progress-risk.d.ts +74 -0
  152. package/dist/knowledge/progress-risk.js +461 -0
  153. package/dist/knowledge/progress-templates.d.ts +38 -0
  154. package/dist/knowledge/progress-templates.js +228 -0
  155. package/dist/knowledge/progress-translation.d.ts +52 -0
  156. package/dist/knowledge/progress-translation.js +401 -0
  157. package/dist/knowledge/proof-confirm.d.ts +31 -0
  158. package/dist/knowledge/proof-confirm.js +187 -0
  159. package/dist/knowledge/proof-risk.d.ts +33 -0
  160. package/dist/knowledge/proof-risk.js +207 -0
  161. package/dist/knowledge/proof-translation.d.ts +52 -0
  162. package/dist/knowledge/proof-translation.js +283 -0
  163. package/dist/knowledge/registrar-risk.d.ts +34 -0
  164. package/dist/knowledge/registrar-risk.js +217 -0
  165. package/dist/knowledge/repository-confirm.d.ts +36 -0
  166. package/dist/knowledge/repository-confirm.js +242 -0
  167. package/dist/knowledge/repository-risk.d.ts +40 -0
  168. package/dist/knowledge/repository-risk.js +312 -0
  169. package/dist/knowledge/repository-translation.d.ts +58 -0
  170. package/dist/knowledge/repository-translation.js +422 -0
  171. package/dist/knowledge/resource-risk.d.ts +32 -0
  172. package/dist/knowledge/resource-risk.js +157 -0
  173. package/dist/knowledge/reward-confirm.d.ts +113 -0
  174. package/dist/knowledge/reward-confirm.js +496 -0
  175. package/dist/knowledge/reward-context.d.ts +127 -0
  176. package/dist/knowledge/reward-context.js +504 -0
  177. package/dist/knowledge/reward-ledger.d.ts +96 -0
  178. package/dist/knowledge/reward-ledger.js +502 -0
  179. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  180. package/dist/knowledge/reward-puzzle.js +288 -0
  181. package/dist/knowledge/reward-risk.d.ts +84 -0
  182. package/dist/knowledge/reward-risk.js +545 -0
  183. package/dist/knowledge/reward-translation.d.ts +58 -0
  184. package/dist/knowledge/reward-translation.js +501 -0
  185. package/dist/knowledge/safety-rules.js +11 -3
  186. package/dist/knowledge/scenario-modes.d.ts +53 -0
  187. package/dist/knowledge/scenario-modes.js +302 -0
  188. package/dist/knowledge/service-confirm.d.ts +152 -0
  189. package/dist/knowledge/service-confirm.js +699 -0
  190. package/dist/knowledge/service-context.d.ts +66 -0
  191. package/dist/knowledge/service-context.js +403 -0
  192. package/dist/knowledge/service-ledger.d.ts +71 -0
  193. package/dist/knowledge/service-ledger.js +609 -0
  194. package/dist/knowledge/service-puzzle.d.ts +158 -0
  195. package/dist/knowledge/service-puzzle.js +236 -0
  196. package/dist/knowledge/service-risk.d.ts +108 -0
  197. package/dist/knowledge/service-risk.js +615 -0
  198. package/dist/knowledge/service-templates.d.ts +39 -0
  199. package/dist/knowledge/service-templates.js +418 -0
  200. package/dist/knowledge/service-translation.d.ts +103 -0
  201. package/dist/knowledge/service-translation.js +622 -0
  202. package/dist/knowledge/tools-reference.d.ts +17 -0
  203. package/dist/knowledge/tools-reference.js +151 -0
  204. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  205. package/dist/knowledge/treasury-confirm.js +512 -0
  206. package/dist/knowledge/treasury-context.d.ts +64 -0
  207. package/dist/knowledge/treasury-context.js +363 -0
  208. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  209. package/dist/knowledge/treasury-ledger.js +300 -0
  210. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  211. package/dist/knowledge/treasury-puzzle.js +216 -0
  212. package/dist/knowledge/treasury-risk.d.ts +86 -0
  213. package/dist/knowledge/treasury-risk.js +440 -0
  214. package/dist/knowledge/treasury-templates.d.ts +38 -0
  215. package/dist/knowledge/treasury-templates.js +316 -0
  216. package/dist/knowledge/treasury-translation.d.ts +78 -0
  217. package/dist/knowledge/treasury-translation.js +498 -0
  218. package/dist/knowledge/util-risk.d.ts +30 -0
  219. package/dist/knowledge/util-risk.js +135 -0
  220. package/dist/project/business-puzzle.d.ts +47 -0
  221. package/dist/project/business-puzzle.js +372 -0
  222. package/dist/project/deployment-doc.d.ts +61 -0
  223. package/dist/project/deployment-doc.js +432 -0
  224. package/dist/project/graph.d.ts +1 -0
  225. package/dist/project/graph.js +27 -1
  226. package/dist/project/index.d.ts +1 -0
  227. package/dist/project/index.js +39 -2
  228. package/dist/project/namespace.d.ts +11 -1
  229. package/dist/project/namespace.js +27 -2
  230. package/dist/project/query.d.ts +2 -0
  231. package/dist/project/query.js +56 -15
  232. package/dist/project/risk-aggregator.d.ts +50 -0
  233. package/dist/project/risk-aggregator.js +280 -0
  234. package/dist/project/substep-trace.d.ts +130 -0
  235. package/dist/project/substep-trace.js +332 -0
  236. package/dist/rules.d.ts +12 -0
  237. package/dist/rules.js +9 -0
  238. package/dist/schema/call/allocation.d.ts +44 -44
  239. package/dist/schema/call/arbitration.d.ts +141 -141
  240. package/dist/schema/call/base.d.ts +386 -386
  241. package/dist/schema/call/base.js +6 -6
  242. package/dist/schema/call/bridge-handler.d.ts +5 -2
  243. package/dist/schema/call/bridge.d.ts +159 -159
  244. package/dist/schema/call/contact.d.ts +110 -110
  245. package/dist/schema/call/demand.d.ts +76 -76
  246. package/dist/schema/call/handler.d.ts +2 -3
  247. package/dist/schema/call/handler.js +1 -1
  248. package/dist/schema/call/machine.d.ts +96 -96
  249. package/dist/schema/call/order.d.ts +98 -110
  250. package/dist/schema/call/permission-handler.d.ts +5 -0
  251. package/dist/schema/call/permission-handler.js +54 -0
  252. package/dist/schema/call/permission.d.ts +108 -108
  253. package/dist/schema/call/personal.d.ts +14 -14
  254. package/dist/schema/call/progress.d.ts +57 -72
  255. package/dist/schema/call/progress.js +7 -4
  256. package/dist/schema/call/proof.d.ts +18 -18
  257. package/dist/schema/call/proof.js +12 -7
  258. package/dist/schema/call/repository.d.ts +154 -154
  259. package/dist/schema/call/reward.d.ts +55 -55
  260. package/dist/schema/call/semantic.js +1 -1
  261. package/dist/schema/call/service.d.ts +238 -238
  262. package/dist/schema/call/treasury.d.ts +93 -93
  263. package/dist/schema/config/index.d.ts +178 -5
  264. package/dist/schema/config/index.js +52 -1
  265. package/dist/schema/local/index.d.ts +3554 -836
  266. package/dist/schema/local/index.js +2 -1
  267. package/dist/schema/messenger/index.d.ts +162 -162
  268. package/dist/schema/operations.d.ts +1102 -1118
  269. package/dist/schema/operations.js +7 -1
  270. package/dist/schema/project/index.d.ts +1392 -6
  271. package/dist/schema/project/index.js +426 -2
  272. package/dist/schema/query/index.d.ts +818 -818
  273. package/dist/schema/query/index.js +15 -9
  274. package/dist/schema/schema-query/index.d.ts +23 -3
  275. package/dist/schema/schema-query/index.js +13 -2
  276. package/dist/schema/sync-layer4.d.ts +21 -0
  277. package/dist/schema/sync-layer4.js +261 -0
  278. package/dist/schema/trust/index.d.ts +26 -26
  279. package/dist/schema/utils/guard-query-utils.d.ts +7 -0
  280. package/dist/schema/utils/guard-query-utils.js +14 -1
  281. package/dist/schemas/account_operation.output.json +718 -0
  282. package/dist/schemas/bridge_operation.output.json +1 -1
  283. package/dist/schemas/config_operation.output.json +173 -0
  284. package/dist/schemas/index.json +9 -1
  285. package/dist/schemas/local_info_operation.output.json +718 -0
  286. package/dist/schemas/local_mark_operation.output.json +718 -0
  287. package/dist/schemas/messenger_operation.output.json +1 -1
  288. package/dist/schemas/onchain_events.output.json +1 -1
  289. package/dist/schemas/onchain_operations.output.json +5 -4
  290. package/dist/schemas/onchain_operations.schema.json +1813 -333
  291. package/dist/schemas/onchain_operations_allocation.schema.json +9 -11
  292. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  293. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  294. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  295. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  296. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  297. package/dist/schemas/onchain_operations_guard.schema.json +584 -70
  298. package/dist/schemas/onchain_operations_machine.schema.json +4 -6
  299. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  300. package/dist/schemas/onchain_operations_payment.schema.json +2 -1
  301. package/dist/schemas/onchain_operations_permission.schema.json +2 -1
  302. package/dist/schemas/onchain_operations_personal.schema.json +2 -1
  303. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  304. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  305. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  306. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  307. package/dist/schemas/onchain_operations_service.schema.json +4 -6
  308. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  309. package/dist/schemas/onchain_table_data.output.json +6 -12
  310. package/dist/schemas/onchain_table_data.schema.json +32 -1
  311. package/dist/schemas/project_operation.output.json +879 -0
  312. package/dist/schemas/project_operation.schema.json +473 -2
  313. package/dist/schemas/query_toolkit.output.json +14906 -6
  314. package/dist/schemas/schema_query.output.json +38 -1
  315. package/dist/telemetry/index.d.ts +1 -1
  316. package/dist/tools/handlers/bridge.d.ts +1 -0
  317. package/dist/tools/handlers/bridge.js +1 -0
  318. package/dist/tools/handlers/config.d.ts +2 -0
  319. package/dist/tools/handlers/config.js +74 -0
  320. package/dist/tools/handlers/file-export.d.ts +3 -0
  321. package/dist/tools/handlers/file-export.js +90 -0
  322. package/dist/tools/handlers/local.d.ts +3 -0
  323. package/dist/tools/handlers/local.js +38 -0
  324. package/dist/tools/handlers/messenger.d.ts +16 -0
  325. package/dist/tools/handlers/messenger.js +188 -0
  326. package/dist/tools/handlers/onchain.d.ts +2 -0
  327. package/dist/tools/handlers/onchain.js +248 -0
  328. package/dist/tools/handlers/project.d.ts +2 -0
  329. package/dist/tools/handlers/project.js +293 -0
  330. package/dist/tools/handlers/query.d.ts +5 -0
  331. package/dist/tools/handlers/query.js +256 -0
  332. package/dist/tools/handlers/schema-query.d.ts +2 -0
  333. package/dist/tools/handlers/schema-query.js +93 -0
  334. package/dist/tools/handlers/trust.d.ts +2 -0
  335. package/dist/tools/handlers/trust.js +194 -0
  336. package/dist/tools/handlers/wip.d.ts +2 -0
  337. package/dist/tools/handlers/wip.js +44 -0
  338. package/dist/tools/index.d.ts +13 -0
  339. package/dist/tools/index.js +526 -0
  340. package/dist/tools/rules-hook.d.ts +2 -0
  341. package/dist/tools/rules-hook.js +23 -0
  342. package/dist/tools/shared.d.ts +20 -0
  343. package/dist/tools/shared.js +130 -0
  344. package/dist/tools/types.d.ts +35 -0
  345. package/dist/tools/types.js +1 -0
  346. package/dist/tools/wrap.d.ts +14 -0
  347. package/dist/tools/wrap.js +267 -0
  348. package/package.json +20 -6
@@ -0,0 +1,302 @@
1
+ export const SCENARIO_MODES = [
2
+ {
3
+ name: "freelance",
4
+ phase: 1,
5
+ industry: "Design / dev / consulting / writing",
6
+ trust_pattern: "Milestone allocation, acceptance gate",
7
+ traits: {
8
+ has_logistics: false,
9
+ communication_heavy: true,
10
+ pure_digital: true,
11
+ long_cycle: true,
12
+ deposit_required: false,
13
+ multi_tier_allocation: false,
14
+ },
15
+ machine_shape: [
16
+ { name: "ordered", role: "Customer places order, payment escrowed" },
17
+ { name: "delivering", role: "Provider submits deliverable (WIP hash)" },
18
+ { name: "delivered", role: "Deliverable available for review" },
19
+ { name: "accepted", role: "Customer signs acceptance" },
20
+ { name: "completed", role: "Funds released to provider" },
21
+ { name: "refunded", role: "Customer-initiated refund path" },
22
+ { name: "cancelled", role: "Pre-delivery cancellation" },
23
+ ],
24
+ guards: [
25
+ { template_id: "buy_guard_identity", host: "service", purpose: "Customer identity check on purchase" },
26
+ { template_id: "deliver_guard_wip", host: "machine", purpose: "Provider must submit WIP hash for deliverable" },
27
+ { template_id: "accept_guard_signer", host: "machine", purpose: "Only customer can sign acceptance" },
28
+ { template_id: "withdraw_guard_permission", host: "machine", purpose: "Only provider can withdraw after acceptance" },
29
+ { template_id: "refund_guard_signer", host: "machine", purpose: "Only customer can initiate refund" },
30
+ ],
31
+ allocator: {
32
+ recipient: "signer",
33
+ count: 2,
34
+ mode: "amount",
35
+ description: "100% to provider on accepted; 100% refund to customer on refunded",
36
+ },
37
+ key_risk: "Customer never accepts delivery — provider cannot get paid",
38
+ build_notes: [
39
+ "Use Service `setting_locked_time` to lock rules for the engagement duration",
40
+ "WIP hash on deliverable is mandatory — protects provider in disputes",
41
+ "Acceptance gate is the trust pivot — both parties must agree on criteria",
42
+ ],
43
+ },
44
+ {
45
+ name: "rental",
46
+ phase: 1,
47
+ industry: "Equipment / vehicle / property rental",
48
+ trust_pattern: "Deposit escrow, return inspection",
49
+ traits: {
50
+ has_logistics: true,
51
+ communication_heavy: true,
52
+ pure_digital: false,
53
+ long_cycle: false,
54
+ deposit_required: true,
55
+ multi_tier_allocation: false,
56
+ },
57
+ machine_shape: [
58
+ { name: "reserved", role: "Customer reserves item, pays deposit + rent" },
59
+ { name: "handover_out", role: "Owner hands over item, records pre-rental WIP" },
60
+ { name: "in_use", role: "Rental period active" },
61
+ { name: "returned", role: "Customer returns item" },
62
+ { name: "inspected", role: "Owner inspects returned item" },
63
+ { name: "deposit_refunded", role: "No damage — full deposit returned" },
64
+ { name: "deposit_deducted", role: "Damage found — deposit partially deducted" },
65
+ ],
66
+ guards: [
67
+ { template_id: "deposit_guard_amount", host: "service", purpose: "Verify deposit amount matches listing" },
68
+ { template_id: "return_guard_wip", host: "machine", purpose: "Return must include post-rental WIP" },
69
+ { template_id: "inspect_guard_signer", host: "machine", purpose: "Only owner can submit inspection result" },
70
+ { template_id: "refund_guard_permission", host: "machine", purpose: "Refund requires owner permission" },
71
+ { template_id: "damage_guard_wip", host: "machine", purpose: "Damage claim requires pre+post WIP comparison" },
72
+ ],
73
+ allocator: {
74
+ recipient: "entity",
75
+ count: 3,
76
+ mode: "amount",
77
+ description: "Rent to owner; refund to customer; deduction to owner (damage case)",
78
+ },
79
+ key_risk: "Owner claims damage without pre-rental WIP — customer loses deposit unfairly",
80
+ build_notes: [
81
+ "Pre-rental WIP is non-negotiable — without it, damage claims fail",
82
+ "Deposit must be escrowed, not direct-transferred — enables fair deduction",
83
+ "Inspection gate prevents customer from denying damage",
84
+ ],
85
+ },
86
+ {
87
+ name: "education",
88
+ phase: 2,
89
+ industry: "Courses / training / tutoring",
90
+ trust_pattern: "Periodic release per session, attendance Guard",
91
+ traits: {
92
+ has_logistics: false,
93
+ communication_heavy: true,
94
+ pure_digital: false,
95
+ long_cycle: true,
96
+ deposit_required: true,
97
+ multi_tier_allocation: false,
98
+ },
99
+ machine_shape: [
100
+ { name: "enrolled", role: "Student enrolls, pays tuition" },
101
+ { name: "session_N", role: "Per-session attendance (1..N)" },
102
+ { name: "completed", role: "All sessions delivered" },
103
+ { name: "refunded", role: "Institution-approved refund" },
104
+ ],
105
+ guards: [
106
+ { template_id: "attendance_guard_signer", host: "machine", purpose: "Per-session student attendance signature" },
107
+ { template_id: "refund_guard_permission", host: "machine", purpose: "Institution approval OR arbiter for refund" },
108
+ ],
109
+ allocator: {
110
+ recipient: "entity",
111
+ count: 1,
112
+ mode: "amount",
113
+ description: "1/N of tuition released per session attendance; unearned portion refundable",
114
+ },
115
+ key_risk: "Tutoring institutions run away with prepaid tuition",
116
+ build_notes: [
117
+ "Use Service `setting_locked_time` to lock rules mid-semester (regulatory compliance)",
118
+ "Attendance Guard needs WIP hash for session content commitment",
119
+ "Per-session release requires threshold-based trigger",
120
+ ],
121
+ },
122
+ {
123
+ name: "travel",
124
+ phase: 2,
125
+ industry: "Custom tours / multi-segment trips",
126
+ trust_pattern: "Multi-tier allocation per segment",
127
+ traits: {
128
+ has_logistics: false,
129
+ communication_heavy: true,
130
+ pure_digital: false,
131
+ long_cycle: true,
132
+ deposit_required: true,
133
+ multi_tier_allocation: true,
134
+ },
135
+ machine_shape: [
136
+ { name: "ordered", role: "Customer books tour, pays deposit + final" },
137
+ { name: "segment_D1", role: "Segment 1 (e.g., hotel check-in)" },
138
+ { name: "segment_D2", role: "Segment 2 (e.g., guided tour)" },
139
+ { name: "returned", role: "Trip completed, customer returns" },
140
+ { name: "completed", role: "All segments delivered, funds released" },
141
+ { name: "refunded", role: "Trip interruption refund" },
142
+ ],
143
+ guards: [
144
+ { template_id: "segment_guard_wip", host: "machine", purpose: "Per-segment arrival WIP (hotel check-in, etc.)" },
145
+ { template_id: "refund_guard_permission", host: "machine", purpose: "Agency approval OR arbiter for trip interruption" },
146
+ ],
147
+ allocator: {
148
+ recipient: "entity",
149
+ count: 3,
150
+ mode: "amount",
151
+ description: "Deposit 20% to agency, final 80% to agency, then agency-side Allocation splits to hotel/guide/driver per segment",
152
+ },
153
+ key_risk: "Paid in full then service shrinks — multi-tier transparency prevents this",
154
+ build_notes: [
155
+ "Multi-tier Allocation is WoWok's unique advantage over traditional travel platforms",
156
+ "segment_guard needs standardized WIP templates per segment type (hotel, transport, activity)",
157
+ "Multi-tier waterfall needs guard chaining validation",
158
+ ],
159
+ },
160
+ {
161
+ name: "subscription",
162
+ phase: 3,
163
+ industry: "SaaS / content membership / periodic service",
164
+ trust_pattern: "Periodic charge, cancel Guard",
165
+ traits: {
166
+ has_logistics: false,
167
+ communication_heavy: false,
168
+ pure_digital: true,
169
+ long_cycle: true,
170
+ deposit_required: false,
171
+ multi_tier_allocation: false,
172
+ },
173
+ machine_shape: [
174
+ { name: "subscribed", role: "Subscriber signs up" },
175
+ { name: "charge_period_N", role: "Periodic charge (1..N)" },
176
+ { name: "deliver_period_N", role: "Per-period delivery" },
177
+ { name: "cancelled", role: "Subscriber cancels — takes effect next period" },
178
+ { name: "expired", role: "Subscription term ends" },
179
+ ],
180
+ guards: [
181
+ { template_id: "charge_guard_signer", host: "machine", purpose: "User confirms each charge — no auto-renew trap" },
182
+ { template_id: "cancel_guard_signer", host: "machine", purpose: "User cancels anytime, next-period effective" },
183
+ { template_id: "deliver_guard_wip", host: "machine", purpose: "Creator WIP hash per period — prevents content abandonment" },
184
+ ],
185
+ allocator: {
186
+ recipient: "entity",
187
+ count: 1,
188
+ mode: "amount",
189
+ description: "Each charge → 100% to creator; unearned periods → refund to subscriber",
190
+ },
191
+ key_risk: "Auto-renew trap and platform-takes-30% — WoWok native solution",
192
+ build_notes: [
193
+ "Pure digital — native WoWok soil",
194
+ "charge_guard needs periodic trigger (off-chain scheduler + on-chain Guard)",
195
+ "Targets indie creators, niche SaaS, paid newsletters",
196
+ ],
197
+ },
198
+ {
199
+ name: "general",
200
+ phase: 1,
201
+ industry: "Anything not covered / hybrid",
202
+ trust_pattern: "User-defined from scratch",
203
+ traits: {
204
+ has_logistics: false,
205
+ communication_heavy: false,
206
+ pure_digital: false,
207
+ long_cycle: false,
208
+ deposit_required: false,
209
+ multi_tier_allocation: false,
210
+ },
211
+ machine_shape: [],
212
+ guards: [],
213
+ allocator: {
214
+ recipient: "signer",
215
+ count: 0,
216
+ mode: "amount",
217
+ description: "User-defined — no defaults",
218
+ },
219
+ key_risk: "No safety net — user must design all trust mechanisms manually",
220
+ build_notes: [
221
+ "Escape hatch: any user can switch to general mode at any time",
222
+ "Already-created objects under a previous mode remain on-chain (REUSE pattern)",
223
+ "wowok-machine / wowok-guard / wowok-provider become primary references",
224
+ ],
225
+ },
226
+ ];
227
+ export function matchScenarioMode(description) {
228
+ const d = description.toLowerCase();
229
+ const traits = inferScenarioTraits(description);
230
+ const scores = SCENARIO_MODES.map((mode) => {
231
+ let score = 0;
232
+ let total = 0;
233
+ for (const key of Object.keys(traits)) {
234
+ total += 1;
235
+ if (mode.traits[key] === traits[key])
236
+ score += 1;
237
+ }
238
+ if (mode.name !== "general") {
239
+ const keywords = MODE_KEYWORDS[mode.name] ?? [];
240
+ for (const kw of keywords) {
241
+ if (d.includes(kw))
242
+ score += 0.5;
243
+ }
244
+ }
245
+ return { mode, score, total };
246
+ });
247
+ let best = scores[0];
248
+ for (const s of scores) {
249
+ if (s.score > best.score)
250
+ best = s;
251
+ }
252
+ const confidence = best.total > 0 ? Math.min(1, best.score / best.total) : 0;
253
+ return { mode: best.mode, confidence };
254
+ }
255
+ const MODE_KEYWORDS = {
256
+ freelance: ["freelance", "design", "develop", "consult", "write", "consulting"],
257
+ rental: ["rent", "rental", "lease", "borrow", "equipment", "vehicle", "property"],
258
+ education: ["course", "training", "tutor", "teach", "education", "class"],
259
+ travel: ["tour", "travel", "trip", "itinerary", "vacation"],
260
+ subscription: ["subscribe", "subscription", "membership", "saas", "newsletter", "recurring"],
261
+ };
262
+ export function inferScenarioTraits(description) {
263
+ const d = description.toLowerCase();
264
+ return {
265
+ has_logistics: /ship|delivery|equipment|vehicle|physical|goods/.test(d),
266
+ communication_heavy: /consult|discuss|back-and-forth|custom|bespoke|negotiate/.test(d),
267
+ pure_digital: /digital|file|download|online|software|code|design|content/.test(d),
268
+ long_cycle: /month|long-term|engagement|project|semester|period/.test(d),
269
+ deposit_required: /deposit|escrow|prepay|tuition|reserve/.test(d),
270
+ multi_tier_allocation: /tier|segment|multi-|agency|hotel|guide|driver/.test(d),
271
+ };
272
+ }
273
+ export const MODE_COMPOSITIONS = [
274
+ {
275
+ modes: ["freelance", "subscription"],
276
+ use_case: "Retainer consulting (monthly + milestone)",
277
+ conflict_resolution: "Allocator: split into retainer (subscription) + milestone (freelance)",
278
+ },
279
+ {
280
+ modes: ["rental", "education"],
281
+ use_case: "Equipment training rental",
282
+ conflict_resolution: "Machine: extend rental nodes with attendance gates",
283
+ },
284
+ {
285
+ modes: ["travel", "rental"],
286
+ use_case: "Tour with equipment",
287
+ conflict_resolution: "Allocator: segment allocation + deposit escrow side-by-side",
288
+ },
289
+ ];
290
+ export function getScenarioMode(name) {
291
+ return SCENARIO_MODES.find((m) => m.name === name);
292
+ }
293
+ export function listScenarioModes() {
294
+ return SCENARIO_MODES;
295
+ }
296
+ export function getShippedModes() {
297
+ return SCENARIO_MODES.filter((m) => m.phase === 1);
298
+ }
299
+ export function getModeCompositions(name) {
300
+ return MODE_COMPOSITIONS.filter((c) => c.modes.includes(name));
301
+ }
302
+ export const SCENARIO_MODES_VERSION = 1;
@@ -0,0 +1,152 @@
1
+ import { type ServiceRiskAssessment } from "./service-risk.js";
2
+ export type ServiceConfirmGateStatus = "approved" | "blocked_checklist" | "blocked_risk" | "blocked_user" | "blocked_environment";
3
+ export interface ServiceConfirmGateResult {
4
+ status: ServiceConfirmGateStatus;
5
+ checklist_result: ServiceChecklistResult;
6
+ risk_result?: ServiceRiskAssessment;
7
+ user_confirmation?: ServiceUserConfirmation;
8
+ environment_result?: ServiceEnvironmentResult;
9
+ confirmation_text?: string;
10
+ block_reason?: string;
11
+ decision_record: ServiceDecisionRecord;
12
+ }
13
+ export interface ServiceChecklistResult {
14
+ all_passed: boolean;
15
+ items: ServiceChecklistItem[];
16
+ }
17
+ export interface ServiceChecklistItem {
18
+ id: string;
19
+ description: string;
20
+ passed: boolean;
21
+ message: string;
22
+ }
23
+ export interface ServiceUserConfirmation {
24
+ questions_asked: ServiceConfirmationQuestion[];
25
+ responses: ServiceConfirmationResponse[];
26
+ all_confirmed: boolean;
27
+ }
28
+ export interface ServiceConfirmationQuestion {
29
+ id: string;
30
+ question: string;
31
+ requires_explicit_yes: boolean;
32
+ related_risk_ids?: string[];
33
+ }
34
+ export interface ServiceConfirmationResponse {
35
+ question_id: string;
36
+ response: "yes" | "no" | "skip";
37
+ }
38
+ export interface ServiceEnvironmentResult {
39
+ passed: boolean;
40
+ checks: {
41
+ name: string;
42
+ passed: boolean;
43
+ message: string;
44
+ }[];
45
+ }
46
+ export interface ServiceDecisionRecord {
47
+ timestamp: string;
48
+ gate_version: string;
49
+ final_status: ServiceConfirmGateStatus;
50
+ layers_passed: string[];
51
+ layers_failed: string[];
52
+ }
53
+ export interface ServiceJsonForConfirm {
54
+ object?: string | null;
55
+ description?: string;
56
+ location?: string;
57
+ customer_required?: string[];
58
+ sales?: {
59
+ op: "add" | "set";
60
+ sales: Array<{
61
+ name: string;
62
+ price?: string;
63
+ stock?: number;
64
+ wip?: string;
65
+ wip_hash?: string;
66
+ }>;
67
+ } | {
68
+ op: "remove";
69
+ sales_name: string[];
70
+ } | {
71
+ op: "clear";
72
+ };
73
+ machine?: string | null;
74
+ buy_guard?: string | null;
75
+ arbitrations?: {
76
+ op: "add" | "set" | "remove";
77
+ objects: string[];
78
+ } | {
79
+ op: "clear";
80
+ };
81
+ repositories?: {
82
+ op: "add" | "set" | "remove";
83
+ objects: string[];
84
+ } | {
85
+ op: "clear";
86
+ };
87
+ rewards?: {
88
+ op: "add" | "set" | "remove";
89
+ objects: string[];
90
+ } | {
91
+ op: "clear";
92
+ };
93
+ order_allocators?: unknown;
94
+ discount?: {
95
+ name: string;
96
+ discount_type: number;
97
+ data: number;
98
+ count: number;
99
+ receivers?: string[];
100
+ expire_at?: number;
101
+ };
102
+ pause?: boolean;
103
+ publish?: boolean;
104
+ compensation_fund_add?: {
105
+ balance: string | number;
106
+ };
107
+ compensation_fund_withdraw?: unknown;
108
+ compensation_fund_receive?: unknown;
109
+ setting_locked_time_add?: number;
110
+ order_new?: {
111
+ buy: {
112
+ items: Array<{
113
+ name: string;
114
+ wip_hash: string;
115
+ count: number;
116
+ }>;
117
+ discount?: string;
118
+ total_pay: string;
119
+ };
120
+ };
121
+ builder?: string;
122
+ um?: string | null;
123
+ owner_receive?: unknown;
124
+ }
125
+ export interface ServiceConfirmGateInput {
126
+ service_json: ServiceJsonForConfirm;
127
+ intent?: string;
128
+ target_objects_types?: string[];
129
+ current_bPublished?: boolean;
130
+ current_bPaused?: boolean;
131
+ current_compensation_fund_balance?: string;
132
+ current_setting_lock_duration?: string;
133
+ current_arbitrations_count?: number;
134
+ current_rewards_count?: number;
135
+ current_repositories_count?: number;
136
+ current_sales_count?: number;
137
+ current_machine_bound?: boolean;
138
+ current_order_allocators_set?: boolean;
139
+ skip_user_confirmation?: boolean;
140
+ skip_environment_check?: boolean;
141
+ }
142
+ export declare const SERVICE_PUBLISH_CHECKLIST: ServiceChecklistItem[];
143
+ export declare const SERVICE_CONFIRMATION_QUESTIONS: ServiceConfirmationQuestion[];
144
+ export declare const SERVICE_CONFIRM_VERSION = "1.0.0";
145
+ export declare function runServiceConfirmGate(input: ServiceConfirmGateInput): ServiceConfirmGateResult;
146
+ export interface ServiceProgressiveCheckResult {
147
+ stage: "checklist" | "risk" | "confirmation" | "environment" | "complete";
148
+ status: "pass" | "fail" | "pending";
149
+ message: string;
150
+ next_action?: string;
151
+ }
152
+ export declare function progressiveServiceCheck(input: ServiceConfirmGateInput): ServiceProgressiveCheckResult;