@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,354 @@
1
+ import { MAX_REWARD_COUNT, MAX_GUARD_COUNT_DEMAND, MAX_DESCRIPTION_LENGTH, MAX_LONG_NAME_LENGTH, } from "@wowok/wowok";
2
+ const MAX_FEEDBACK_COUNT = 20;
3
+ export const SEMANTIC_TO_DEMAND_SCHEMA_RULES = [
4
+ {
5
+ id: "P-DEM-01",
6
+ pattern_name: "Open Demand (no guards) — free presentation",
7
+ configuration_classification: "open",
8
+ semantic_intent: "An open Demand accepts presentations from any sender via the plain `present` function (demand.move:100). " +
9
+ "No Passport is required. Use this for broad-cast demands where the creator wants to collect as many " +
10
+ "presentations as possible (e.g. open calls for service providers, public RFPs). The guards vector is empty.",
11
+ match_keywords: ["open", "no guard", "free presentation", "public", "rfp", "open call"],
12
+ schema_elements: {
13
+ required_fields: ["description", "permission"],
14
+ optional_fields: ["location", "rewards", "um", "namedNew"],
15
+ presentation_path: "plain_present",
16
+ um_recommendation: "Optional. Set um to a Contact object if the Demand should be managed by an intermediary. " +
17
+ "Leave as Option::none for direct creator management.",
18
+ },
19
+ constraints: [
20
+ "guards vector must be empty (initial state — do not call guard_add)",
21
+ "Callers MUST use plain `present` or `present_service` — present_with_passport will abort with E_GUARD_NOT_FOUND (4)",
22
+ "description non-empty and within MAX_DESCRIPTION_LENGTH (4000 chars)",
23
+ "If location is set, within MAX_LONG_NAME_LENGTH (256 chars)",
24
+ ],
25
+ example: {
26
+ description: "Open call for freelance designers — submit portfolio link as recommend",
27
+ location: "Shanghai",
28
+ rewards: ["0xabc...reward_addr_1"],
29
+ permission: "0xperm...permission_addr",
30
+ um: null,
31
+ namedNew: { name: "open_design_call_2026" },
32
+ },
33
+ },
34
+ {
35
+ id: "P-DEM-02",
36
+ pattern_name: "Guarded Demand (with guards) — passport required for present",
37
+ configuration_classification: "guarded",
38
+ semantic_intent: "A guarded Demand requires every presenter to supply a Passport that passes one of the affiliated Guards. " +
39
+ "Use this when the creator wants to filter presentations by Guard-defined criteria (KYC, membership, " +
40
+ "stake, etc.). The guards vector is non-empty. Each guard carries an optional service_identifier that, " +
41
+ "when set, routes present_with_passport to extract the submission address from the Passport (overriding " +
42
+ "the supplied service parameter).",
43
+ match_keywords: ["guarded", "passport", "kyc", "membership", "filtered", "gated", "service_identifier"],
44
+ schema_elements: {
45
+ required_fields: ["description", "permission", "guards"],
46
+ optional_fields: ["location", "rewards", "um", "namedNew"],
47
+ presentation_path: "present_with_passport",
48
+ um_recommendation: "Optional. Same as P-DEM-01. If the Demand is mediated by an intermediary Contact, set um to that " +
49
+ "Contact address and the intermediary can manage the Demand via the Contact's permission.",
50
+ },
51
+ constraints: [
52
+ "guards vector non-empty (call guard_add at least once)",
53
+ "Each guard address must be unique (duplicate guard_add updates service_identifier instead of pushing)",
54
+ "guard_count ≤ MAX_GUARD_COUNT_DEMAND (20) — E_MAX_GUARD_COUNT_EXCEEDED (2) on overflow",
55
+ "When service_identifier is provided, it MUST be a valid u8 indexing a Service-typed submission in the Guard",
56
+ "Presenters MUST use present_with_passport / present_service_with_passport — plain present aborts with E_NEED_PASSPORT (3)",
57
+ "by_guard (Guard address) passed to present_with_passport MUST already be in the guards vector — E_GUARD_NOT_FOUND (4) otherwise",
58
+ ],
59
+ example: {
60
+ description: "KYC-gated call for certified auditors only",
61
+ location: "Remote",
62
+ rewards: ["0xabc...reward_addr_1", "0xdef...reward_addr_2"],
63
+ guards: [
64
+ { guard: "0xguard1...", service_identifier: 0 },
65
+ { guard: "0xguard2...", service_identifier: null },
66
+ ],
67
+ permission: "0xperm...permission_addr",
68
+ um: null,
69
+ namedNew: { name: "kyc_auditor_call_2026" },
70
+ },
71
+ },
72
+ {
73
+ id: "P-DEM-03",
74
+ pattern_name: "Demand with UM (um_set) — Contact object manages demand",
75
+ configuration_classification: "um_managed",
76
+ semantic_intent: "A Demand with um set has an affiliated Contact object that manages the Demand on behalf of the creator. " +
77
+ "The Contact's address is stored in Demand.um (Option<address>). The Contact can perform operations " +
78
+ "through its own permission scope. Use this when a Demand is operated by an intermediary (agent, " +
79
+ "marketplace, escrow service) rather than the original creator. um_set_imp (demand.move:139-147) " +
80
+ "disaffiliates the old um before affiliating the new one (P-DEM-P1-1 fix).",
81
+ match_keywords: ["um", "contact", "managed", "intermediary", "agent", "marketplace", "escrow"],
82
+ schema_elements: {
83
+ required_fields: ["description", "permission", "um"],
84
+ optional_fields: ["location", "rewards", "guards", "namedNew"],
85
+ presentation_path: "either",
86
+ um_recommendation: "Required for this pattern. Set um to a Contact object address via um_set. The Contact's " +
87
+ "permission scope applies to subsequent operations. To remove the Contact, call um_none — " +
88
+ "um_none_imp disaffiliates the Contact before clearing self.um.",
89
+ },
90
+ constraints: [
91
+ "um must be a valid Contact object address (set via um_set, permission index 408)",
92
+ "um_set_imp disaffiliates old um before affiliating new (P-DEM-P1-1 fix — prevents Registrar dependency leak)",
93
+ "um_none_imp disaffiliates um before clearing (symmetric with um_set_imp)",
94
+ "If guards is also non-empty, the present_with_passport path applies (P-DEM-02 constraints also hold)",
95
+ "permission_set (DE-D-2=A) can migrate the Demand to a new Permission — affiliation_change is called on the Registrar",
96
+ ],
97
+ example: {
98
+ description: "Marketplace-managed Demand for freelance design services",
99
+ location: "Shanghai",
100
+ rewards: ["0xabc...reward_addr_1"],
101
+ guards: [{ guard: "0xguard1...", service_identifier: null }],
102
+ permission: "0xperm...permission_addr",
103
+ um: "0xcontact...marketplace_contact_addr",
104
+ namedNew: { name: "marketplace_managed_design_2026" },
105
+ },
106
+ },
107
+ ];
108
+ export const DEMAND_FIELD_TRANSLATIONS = [
109
+ {
110
+ field_name: "description",
111
+ value_type: "string",
112
+ semantic: "Human-readable description of this Demand. Required field. The Move contract validates via " +
113
+ "common::DESCRIPTION (demand.move:157,177), which enforces the 4000-char limit. Should be a one-line " +
114
+ "summary of what the Demand is asking for (e.g. \"freelance designer for brand identity work\").",
115
+ format_example: "Freelance designer for brand identity work (logo + style guide)",
116
+ validation_rules: [
117
+ "Required field",
118
+ `Length ≤ MAX_DESCRIPTION_LENGTH (${MAX_DESCRIPTION_LENGTH} chars)`,
119
+ "Move validates via common::DESCRIPTION — E_DESCRIPTION_LENGTH_EXCEEDED (4) on overflow",
120
+ ],
121
+ },
122
+ {
123
+ field_name: "location",
124
+ value_type: "string",
125
+ semantic: "Geographic location associated with the Demand. Validated via common::LONG_NAME (demand.move:180). " +
126
+ "Empty string (\"\") is valid — new_imp initializes location to empty. Use location_set to update after " +
127
+ "creation. This is the ONLY Move Demand struct field that the matching engine reads directly (other " +
128
+ "matching fields like tags, maxPrice, scenario are caller-enriched — see P-DEM-P1-3 / R-DEM-07).",
129
+ format_example: "Shanghai or Remote",
130
+ validation_rules: [
131
+ "Optional (empty string \"\" is the default initial value)",
132
+ `Length ≤ MAX_LONG_NAME_LENGTH (${MAX_LONG_NAME_LENGTH} chars)`,
133
+ "Move validates via common::LONG_NAME — E_LONG_NAME_LENGTH_EXCEEDED (11) on overflow",
134
+ ],
135
+ },
136
+ {
137
+ field_name: "rewards",
138
+ value_type: "vector<address> (string[] in SDK)",
139
+ semantic: "Reward object addresses affiliated with this Demand. Each reward is added via reward_add, which " +
140
+ "triggers registrar::affiliation. The matching engine reads maxPrice from the Reward objects " +
141
+ "(caller-enriched — the Demand struct only stores addresses, not Reward metadata).",
142
+ format_example: "[\"0xabc...reward_addr_1\", \"0xdef...reward_addr_2\"]",
143
+ validation_rules: [
144
+ `Count ≤ MAX_REWARD_COUNT (${MAX_REWARD_COUNT}) — E_MAX_REWARD_COUNT_EXCEEDED (1) on overflow`,
145
+ "Each address must be a valid Reward object address",
146
+ "Duplicate addresses are silently ignored (reward_add_imp checks contains before push)",
147
+ "reward_remove / reward_clear disaffiliate via the Registrar before removing",
148
+ ],
149
+ },
150
+ {
151
+ field_name: "guards",
152
+ value_type: "vector<ServiceGuard> ({ guard: address, service_identifier: Option<u8> }[] in SDK)",
153
+ semantic: "Guard addresses with optional service_identifier. When non-empty, presenters MUST use " +
154
+ "present_with_passport (or present_service_with_passport). The service_identifier, when set, routes " +
155
+ "present_with_passport to extract the submission address from the Passport (overriding the supplied " +
156
+ "service parameter). guard_add validates the service_identifier type BEFORE any mutation (P-DEM-P1-2 fix).",
157
+ format_example: "[{ guard: \"0xguard1...\", service_identifier: 0 }, { guard: \"0xguard2...\", service_identifier: null }]",
158
+ validation_rules: [
159
+ `Count ≤ MAX_GUARD_COUNT_DEMAND (${MAX_GUARD_COUNT_DEMAND}) — E_MAX_GUARD_COUNT_EXCEEDED (2) on overflow`,
160
+ "Each guard address must be a valid Guard object address",
161
+ "Duplicate addresses update service_identifier in place (no new push)",
162
+ "When service_identifier is provided, it MUST index a Service-typed submission in the Guard",
163
+ "guard_remove / guard_clear disaffiliate via the Registrar before removing",
164
+ ],
165
+ },
166
+ {
167
+ field_name: "um",
168
+ value_type: "Option<address> (string | null in SDK)",
169
+ semantic: "Optional Contact object address that manages this Demand. When set, the Contact can perform " +
170
+ "operations through its own permission scope. um_set_imp (demand.move:139-147) disaffiliates the old " +
171
+ "um before affiliating the new one (P-DEM-P1-1 fix — prevents Registrar dependency leak). To clear, " +
172
+ "call um_none — um_none_imp disaffiliates before clearing self.um.",
173
+ format_example: "0xcontact...marketplace_contact_addr or null",
174
+ validation_rules: [
175
+ "Optional (null/undefined → Option::none) — initial state",
176
+ "When set, must be a valid Contact object address",
177
+ "um_set_imp disaffiliates old um before setting new (P-DEM-P1-1 fix)",
178
+ "um_none_imp disaffiliates um before clearing (symmetric)",
179
+ "Permission index 408 required for um_set / um_none",
180
+ ],
181
+ },
182
+ {
183
+ field_name: "presenters",
184
+ value_type: "ParentTable<address, ServiceInfo> (not directly settable — populated by present)",
185
+ semantic: "Service presentation records, keyed by presenter address. Each entry contains: recommend (String), " +
186
+ "service (Option<address>), update_time (u64), acceptance_score (Option<u8>), feedback (String), " +
187
+ "feedback_time (u64). Populated by present_imp — presenters call present / present_with_passport to " +
188
+ "add or update their entry. feedback_imp updates an existing entry's feedback fields.",
189
+ format_example: "(not directly settable — populated by present operations)",
190
+ validation_rules: [
191
+ "Not directly settable by the creator — populated by presenter operations",
192
+ "Each presenter address maps to at most one ServiceInfo entry",
193
+ "present updates update_time and overwrites recommend/service on each call",
194
+ "feedback updates acceptance_score, feedback, feedback_time (only if presenter exists)",
195
+ ],
196
+ },
197
+ {
198
+ field_name: "permission",
199
+ value_type: "address",
200
+ semantic: "Permission object address bound to this Demand. All mutations require permission::assert_permission_with_sender " +
201
+ "with the appropriate index (400-408). permission_set (demand.move:286) is exposed via CallPermission.apply " +
202
+ "(DE-D-2=A) and migrates the affiliation via registrar::affiliation_change.",
203
+ format_example: "0xperm...permission_addr",
204
+ validation_rules: [
205
+ "Required field (set at creation via new_imp)",
206
+ "permission::assert_with_sender(permission, 400, ctx) required for new (DEMAND_NEW)",
207
+ "permission::assert_permission_with_sender(permission, <index>, &self.permission, ctx) required for all mutations",
208
+ "Permission indices: 400=NEW, 401=DESCRIPTION, 402=LOCATION, 404=GUARD, 405=REWARD, 406=FEEDBACK, 407=OWNER_RECEIVE, 408=UM",
209
+ "permission_set migrates affiliation via registrar::affiliation_change (DE-D-2=A)",
210
+ ],
211
+ },
212
+ ];
213
+ export const DEMAND_CONSTRAINT_RULES = [
214
+ {
215
+ id: "DEMAND_C_01",
216
+ name: "description non-empty and within size limit",
217
+ description: `The 'description' field must be non-empty and ≤ MAX_DESCRIPTION_LENGTH (${MAX_DESCRIPTION_LENGTH} chars).`,
218
+ validation_logic: "description.length > 0 && description.length <= MAX_DESCRIPTION_LENGTH",
219
+ failure_message: `description must be 1..${MAX_DESCRIPTION_LENGTH} chars — E_DESCRIPTION_LENGTH_EXCEEDED (4) on overflow`,
220
+ related_field: "description",
221
+ },
222
+ {
223
+ id: "DEMAND_C_02",
224
+ name: "location within size limit",
225
+ description: `The 'location' field must be ≤ MAX_LONG_NAME_LENGTH (${MAX_LONG_NAME_LENGTH} chars). Empty string is valid.`,
226
+ validation_logic: "location.length <= MAX_LONG_NAME_LENGTH",
227
+ failure_message: `location exceeds MAX_LONG_NAME_LENGTH (${MAX_LONG_NAME_LENGTH} chars) — E_LONG_NAME_LENGTH_EXCEEDED (11)`,
228
+ related_field: "location",
229
+ },
230
+ {
231
+ id: "DEMAND_C_03",
232
+ name: "rewards count within limit",
233
+ description: `The 'rewards' vector count must be ≤ MAX_REWARD_COUNT (${MAX_REWARD_COUNT}).`,
234
+ validation_logic: `rewards.length <= MAX_REWARD_COUNT`,
235
+ failure_message: `rewards count exceeds MAX_REWARD_COUNT (${MAX_REWARD_COUNT}) — E_MAX_REWARD_COUNT_EXCEEDED (1)`,
236
+ related_field: "rewards",
237
+ },
238
+ {
239
+ id: "DEMAND_C_04",
240
+ name: "guards count within limit",
241
+ description: `The 'guards' vector count must be ≤ MAX_GUARD_COUNT_DEMAND (${MAX_GUARD_COUNT_DEMAND}).`,
242
+ validation_logic: `guards.length <= MAX_GUARD_COUNT_DEMAND`,
243
+ failure_message: `guards count exceeds MAX_GUARD_COUNT_DEMAND (${MAX_GUARD_COUNT_DEMAND}) — E_MAX_GUARD_COUNT_EXCEEDED (2)`,
244
+ related_field: "guards",
245
+ },
246
+ {
247
+ id: "DEMAND_C_05",
248
+ name: "service_identifier valid u8 when provided",
249
+ description: "When service_identifier is provided to guard_add, it must be a valid u8 (0-255) indexing a " +
250
+ "Service-typed submission in the Guard. guard_add_imp validates via guard::get_submission_object_type " +
251
+ "and common::assert_service_object_type BEFORE any mutation (P-DEM-P1-2 fix).",
252
+ validation_logic: "service_identifier == null || (Number.isInteger(service_identifier) && 0 <= service_identifier && service_identifier <= 255)",
253
+ failure_message: "service_identifier must be a u8 (0-255) indexing a Service-typed submission — E_INVALID_SERVICE_OBJECT_TYPE (13)",
254
+ related_field: "guards.service_identifier",
255
+ },
256
+ {
257
+ id: "DEMAND_C_06",
258
+ name: "present requires passport when guards non-empty",
259
+ description: "When the guards vector is non-empty, callers MUST use present_with_passport / present_service_with_passport. " +
260
+ "The plain present function asserts `vector::is_empty(&self.guards)` and aborts with E_NEED_PASSPORT (3). " +
261
+ "The by_guard parameter to present_with_passport MUST already be in the guards vector " +
262
+ "(otherwise E_GUARD_NOT_FOUND (4)).",
263
+ validation_logic: "!guards_non_empty || using_present_with_passport; by_guard in guards",
264
+ failure_message: "present without passport when guards non-empty — E_NEED_PASSPORT (3); by_guard not in guards — E_GUARD_NOT_FOUND (4)",
265
+ related_field: "guards + presentation_path",
266
+ },
267
+ ];
268
+ export function explainDemand(input) {
269
+ const warnings = [];
270
+ const recommendations = [];
271
+ const hasGuards = !!input.guards && input.guards.length > 0;
272
+ const hasUm = !!input.um;
273
+ let classification = "open";
274
+ let presentationPath = "plain_present";
275
+ if (hasGuards && hasUm) {
276
+ classification = "guarded + um_managed (P-DEM-02 + P-DEM-03 combined)";
277
+ presentationPath = "present_with_passport (um does not change presentation path)";
278
+ }
279
+ else if (hasGuards) {
280
+ classification = "guarded (P-DEM-02) — passport required for present";
281
+ presentationPath = "present_with_passport / present_service_with_passport";
282
+ }
283
+ else if (hasUm) {
284
+ classification = "um_managed (P-DEM-03) — Contact manages the Demand";
285
+ presentationPath = "plain present (no guards) OR present_with_passport (if guards added later)";
286
+ }
287
+ else {
288
+ classification = "open (P-DEM-01) — free presentation, no passport required";
289
+ presentationPath = "present / present_service (plain path)";
290
+ }
291
+ const bindingParts = [];
292
+ if (input.permission) {
293
+ bindingParts.push(`permission=${input.permission.substring(0, 10)}... (bound at creation)`);
294
+ }
295
+ if (hasUm) {
296
+ bindingParts.push(`um=${input.um.substring(0, 10)}... (Contact manages Demand)`);
297
+ }
298
+ if (input.rewards && input.rewards.length > 0) {
299
+ bindingParts.push(`rewards=${input.rewards.length} affiliated via Registrar`);
300
+ }
301
+ if (hasGuards) {
302
+ bindingParts.push(`guards=${input.guards.length} affiliated via Registrar`);
303
+ }
304
+ const bindingStatus = bindingParts.length > 0
305
+ ? `Bindings: ${bindingParts.join("; ")}`
306
+ : "No Registrar affiliations (bare Demand)";
307
+ const sizeStatus = [];
308
+ if (input.description !== undefined) {
309
+ sizeStatus.push(`description=${input.description.length} chars (limit ${MAX_DESCRIPTION_LENGTH})`);
310
+ }
311
+ if (input.location !== undefined) {
312
+ sizeStatus.push(`location=${input.location.length} chars (limit ${MAX_LONG_NAME_LENGTH})`);
313
+ }
314
+ if (input.rewards) {
315
+ sizeStatus.push(`rewards=${input.rewards.length}/${MAX_REWARD_COUNT}`);
316
+ }
317
+ if (input.guards) {
318
+ sizeStatus.push(`guards=${input.guards.length}/${MAX_GUARD_COUNT_DEMAND}`);
319
+ }
320
+ if (hasGuards) {
321
+ const invalidSids = input.guards.filter(g => g.service_identifier !== null && g.service_identifier !== undefined
322
+ && !(typeof g.service_identifier === "number" && Number.isInteger(g.service_identifier)
323
+ && g.service_identifier >= 0 && g.service_identifier <= 255));
324
+ if (invalidSids.length > 0) {
325
+ warnings.push(`${invalidSids.length} guard(s) have invalid service_identifier (must be u8 0-255)`);
326
+ }
327
+ }
328
+ if (!input.description || input.description.length === 0) {
329
+ warnings.push("description is empty — Demand will be hard to identify in queries");
330
+ }
331
+ if (!input.description || input.description.length === 0) {
332
+ recommendations.push("Provide a non-empty description for discoverability");
333
+ }
334
+ if (input.location === undefined || input.location === "") {
335
+ recommendations.push("Consider setting location if the Demand is geographic (only on-chain field used by matching)");
336
+ }
337
+ if (!hasGuards) {
338
+ recommendations.push("Consider adding guards if presentations should be filtered (KYC, membership, etc.)");
339
+ }
340
+ if (!hasUm && classification === "open") {
341
+ recommendations.push("Consider setting um to a Contact if the Demand should be managed by an intermediary");
342
+ }
343
+ const summary = `Demand is ${classification}. ${presentationPath}. ${bindingStatus}. ` +
344
+ (sizeStatus.length > 0 ? `Sizes: ${sizeStatus.join(", ")}.` : "");
345
+ return {
346
+ summary,
347
+ configuration_classification: classification,
348
+ presentation_path: presentationPath,
349
+ binding_status: bindingStatus,
350
+ size_status: sizeStatus.join(", "),
351
+ warnings,
352
+ recommendations,
353
+ };
354
+ }
@@ -0,0 +1,63 @@
1
+ import { type DeploymentDocInput } from "../project/deployment-doc.js";
2
+ export interface DeploymentScanInput {
3
+ project_name: string;
4
+ document_path?: string;
5
+ deployment_doc?: DeploymentDocInput;
6
+ project_graph?: unknown;
7
+ user_confirmed_high_risks?: string[];
8
+ }
9
+ export interface Finding {
10
+ check_id: string;
11
+ severity: "critical" | "warning" | "info";
12
+ message: string;
13
+ location?: string;
14
+ suggestion?: string;
15
+ }
16
+ export interface DeploymentScanResult {
17
+ project_name: string;
18
+ document_path?: string;
19
+ overall_readiness: "ready" | "blocked" | "warnings";
20
+ findings: Finding[];
21
+ coverage: {
22
+ objects_defined: number;
23
+ objects_with_scenario: number;
24
+ testnet_steps: number;
25
+ mainnet_steps: number;
26
+ verification_items: number;
27
+ };
28
+ checks: {
29
+ D01_object_defined: "pass" | "fail";
30
+ D02_dependency_complete: "pass" | "fail";
31
+ D03_scenario_covered: "pass" | "fail";
32
+ D04_testnet_topo_order: "pass" | "fail";
33
+ D05_testnet_network: "pass" | "fail";
34
+ D06_testnet_replace: "pass" | "fail";
35
+ D07_permission_index: "pass" | "fail";
36
+ D08_guard_gen_passport: "pass" | "fail";
37
+ D09_machine_node_count: "pass" | "fail";
38
+ D10_substep_coherence: "pass" | "fail";
39
+ D11_mainnet_testnet_match: "pass" | "fail";
40
+ D12_mainnet_network: "pass" | "fail";
41
+ D13_mainnet_replace: "pass" | "fail";
42
+ D14_testnet_verification: "pass" | "fail";
43
+ D15_mainnet_verification: "pass" | "fail";
44
+ D16_no_critical_risk: "pass" | "fail";
45
+ D17_no_high_risk: "pass" | "fail";
46
+ D18_completeness_checklist: "pass" | "fail";
47
+ };
48
+ scanned_at: number;
49
+ scanner_version: string;
50
+ }
51
+ export declare function analyzeObjectDependencyCompleteness(input: DeploymentScanInput): Finding[];
52
+ export declare function analyzeSubstepCoherence(input: DeploymentScanInput): Finding[];
53
+ export declare function analyzeNetworkConsistency(input: DeploymentScanInput): Finding[];
54
+ export declare function analyzeNamingConvention(input: DeploymentScanInput): Finding[];
55
+ export declare function analyzePermissionIndexRange(input: DeploymentScanInput): Finding[];
56
+ export declare function analyzeScenarioCoverage(input: DeploymentScanInput): Finding[];
57
+ export declare function analyzeVerificationChecklist(input: DeploymentScanInput): Finding[];
58
+ export declare function analyzeDeployableReadiness(input: DeploymentScanInput): Finding[];
59
+ export declare function scanDeployment(input: DeploymentScanInput): DeploymentScanResult;
60
+ export declare function isReady(scan: DeploymentScanResult): boolean;
61
+ export declare function isBlocked(scan: DeploymentScanResult): boolean;
62
+ export declare function summarizeScan(scan: DeploymentScanResult): string;
63
+ export declare const DEPLOYMENT_SCANNER_VERSION = "2.0.0";