@wowok/agent-mcp 2.6.1 → 2.6.4

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 (246) hide show
  1. package/dist/customer/customer-advice.d.ts +31 -0
  2. package/dist/customer/customer-advice.js +129 -0
  3. package/dist/customer/index.d.ts +2 -0
  4. package/dist/customer/index.js +2 -0
  5. package/dist/customer/info-puzzle.d.ts +9 -2
  6. package/dist/customer/info-puzzle.js +34 -7
  7. package/dist/customer/order-monitor.d.ts +2 -0
  8. package/dist/customer/order-monitor.js +3 -2
  9. package/dist/customer/post-purchase.d.ts +2 -0
  10. package/dist/customer/post-purchase.js +6 -5
  11. package/dist/customer/preorder-compare.d.ts +24 -0
  12. package/dist/customer/preorder-compare.js +34 -0
  13. package/dist/customer/reminder-system.d.ts +2 -0
  14. package/dist/customer/reminder-system.js +2 -1
  15. package/dist/customer/risk-assessment.js +30 -7
  16. package/dist/customer/types.d.ts +7 -0
  17. package/dist/examples/arbitration-dispute-create.json +41 -0
  18. package/dist/examples/arbitration-vote-weighted.json +35 -0
  19. package/dist/examples/arbitration-voting-guard-add.json +38 -0
  20. package/dist/examples/demand-present-service.json +33 -0
  21. package/dist/examples/gen-passport-verify-guard.json +48 -0
  22. package/dist/examples/guard-template-balance-check.json +59 -0
  23. package/dist/examples/guard-template-time-lock.json +60 -0
  24. package/dist/examples/insurance-guard-claim-timelock.json +75 -0
  25. package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
  26. package/dist/examples/insurance-machine-create-publish.json +75 -0
  27. package/dist/examples/insurance-service-allocators-publish.json +56 -0
  28. package/dist/examples/machine-multisig-threshold.json +86 -0
  29. package/dist/examples/machine-template-7node-rental.json +119 -0
  30. package/dist/examples/payment-scenario-bound.json +45 -0
  31. package/dist/examples/rental-ziroom-machine-create.json +149 -0
  32. package/dist/examples/rental-ziroom-permission-create.json +42 -0
  33. package/dist/examples/rental-ziroom-service-create.json +89 -0
  34. package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
  35. package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
  36. package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
  37. package/dist/examples/retail-adv-reward-guard-add.json +51 -0
  38. package/dist/examples/retail-myshop-allocation-activate.json +55 -0
  39. package/dist/examples/retail-myshop-arbitration-create.json +40 -0
  40. package/dist/examples/retail-myshop-contact-create.json +43 -0
  41. package/dist/examples/retail-myshop-order-create.json +56 -0
  42. package/dist/examples/retail-myshop-progress-operate.json +38 -0
  43. package/dist/examples/retail-myshop-reward-create.json +35 -0
  44. package/dist/examples/retail-myshop-service-create.json +88 -0
  45. package/dist/examples/service-discount-issue.json +46 -0
  46. package/dist/examples/threebody-guard-create.json +56 -0
  47. package/dist/examples/threebody-machine-create.json +72 -0
  48. package/dist/examples/threebody-permission-create.json +38 -0
  49. package/dist/examples/threebody-service-allocators.json +49 -0
  50. package/dist/examples/travel-guard-time-lock.json +69 -0
  51. package/dist/examples/travel-guard-weather-oracle.json +70 -0
  52. package/dist/examples/travel-machine-create.json +136 -0
  53. package/dist/examples/travel-repository-create.json +47 -0
  54. package/dist/examples/travel-service-create.json +102 -0
  55. package/dist/examples/travel-treasury-create.json +34 -0
  56. package/dist/examples/treasury-deposit.json +37 -0
  57. package/dist/examples/treasury-withdraw.json +38 -0
  58. package/dist/extensions/business-modules.d.ts +49 -0
  59. package/dist/extensions/business-modules.js +287 -0
  60. package/dist/extensions/capability-manifest.js +216 -29
  61. package/dist/extensions/constraint-registry.js +21 -19
  62. package/dist/extensions/metric-registry.js +14 -14
  63. package/dist/extensions/mode-evaluator.js +16 -16
  64. package/dist/extensions/modes.js +141 -49
  65. package/dist/extensions/registry.d.ts +16 -9
  66. package/dist/extensions/registry.js +132 -44
  67. package/dist/extensions/types.d.ts +2 -0
  68. package/dist/index.js +50 -0
  69. package/dist/knowledge/deployment-scanner.js +1 -1
  70. package/dist/knowledge/fund-layer.d.ts +138 -0
  71. package/dist/knowledge/fund-layer.js +969 -0
  72. package/dist/knowledge/guard-render.d.ts +57 -0
  73. package/dist/knowledge/guard-render.js +700 -0
  74. package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
  75. package/dist/knowledge/guard-submission-prompt.js +171 -0
  76. package/dist/knowledge/guard-templates.d.ts +10 -0
  77. package/dist/knowledge/guard-templates.js +50 -0
  78. package/dist/knowledge/index.d.ts +2 -2
  79. package/dist/knowledge/index.js +2 -2
  80. package/dist/knowledge/machine-ledger.js +1 -1
  81. package/dist/knowledge/machine-render.d.ts +41 -0
  82. package/dist/knowledge/machine-render.js +565 -0
  83. package/dist/knowledge/machine-risk.js +4 -1
  84. package/dist/knowledge/machine-templates.js +4 -4
  85. package/dist/knowledge/progress-context.js +1 -1
  86. package/dist/knowledge/progress-ledger.js +3 -3
  87. package/dist/knowledge/progress-templates.js +1 -1
  88. package/dist/knowledge/progress-translation.js +1 -1
  89. package/dist/knowledge/reward-confirm.js +2 -2
  90. package/dist/knowledge/reward-puzzle.js +1 -1
  91. package/dist/knowledge/reward-risk.js +9 -9
  92. package/dist/knowledge/reward-templates.js +2 -2
  93. package/dist/knowledge/safety-rules.d.ts +83 -1
  94. package/dist/knowledge/safety-rules.js +166 -2
  95. package/dist/knowledge/scenario-modes.d.ts +1 -1
  96. package/dist/knowledge/scenario-modes.js +13 -11
  97. package/dist/knowledge/service-confirm.d.ts +1 -1
  98. package/dist/knowledge/service-confirm.js +3 -3
  99. package/dist/knowledge/service-context.js +1 -1
  100. package/dist/knowledge/service-ledger.js +1 -1
  101. package/dist/knowledge/service-risk.d.ts +1 -1
  102. package/dist/knowledge/service-risk.js +3 -3
  103. package/dist/knowledge/service-templates.js +2 -2
  104. package/dist/knowledge/service-translation.d.ts +1 -1
  105. package/dist/knowledge/service-translation.js +7 -7
  106. package/dist/knowledge/template-registry.d.ts +48 -0
  107. package/dist/knowledge/template-registry.js +341 -0
  108. package/dist/knowledge/tool-constraints.js +6 -6
  109. package/dist/knowledge/tools-reference.js +11 -8
  110. package/dist/participation/merchant-interest.d.ts +32 -0
  111. package/dist/participation/merchant-interest.js +100 -0
  112. package/dist/participation/radar-core.d.ts +104 -0
  113. package/dist/participation/radar-core.js +269 -0
  114. package/dist/project/context-assembly.js +8 -0
  115. package/dist/project/deployment-bridge.js +6 -5
  116. package/dist/project/deployment-doc.js +5 -5
  117. package/dist/project/edit-planner.d.ts +123 -0
  118. package/dist/project/edit-planner.js +1342 -0
  119. package/dist/project/evaluation.d.ts +36 -0
  120. package/dist/project/evaluation.js +734 -68
  121. package/dist/project/game-theory.d.ts +43 -0
  122. package/dist/project/game-theory.js +177 -0
  123. package/dist/project/graph-builder.js +7 -1
  124. package/dist/project/handlers.d.ts +137 -2
  125. package/dist/project/handlers.js +423 -51
  126. package/dist/project/intent-analyzer.d.ts +71 -0
  127. package/dist/project/intent-analyzer.js +149 -0
  128. package/dist/project/machine-nodes.d.ts +2 -0
  129. package/dist/project/machine-nodes.js +36 -0
  130. package/dist/project/merchant-guide.d.ts +165 -0
  131. package/dist/project/merchant-guide.js +264 -0
  132. package/dist/project/mode-actions.d.ts +199 -0
  133. package/dist/project/mode-actions.js +309 -0
  134. package/dist/project/participation-radar.d.ts +18 -0
  135. package/dist/project/participation-radar.js +428 -0
  136. package/dist/project/pipeline-actions.d.ts +101 -0
  137. package/dist/project/pipeline-actions.js +109 -0
  138. package/dist/project/semantic-graph.d.ts +95 -0
  139. package/dist/project/semantic-graph.js +245 -0
  140. package/dist/project/stage-gate.js +4 -4
  141. package/dist/schema/call/allocation.d.ts +11 -11
  142. package/dist/schema/call/allocation.js +13 -3
  143. package/dist/schema/call/arbitration.d.ts +21 -21
  144. package/dist/schema/call/arbitration.js +30 -9
  145. package/dist/schema/call/base.d.ts +2 -2
  146. package/dist/schema/call/base.js +1 -1
  147. package/dist/schema/call/bridge.d.ts +127 -127
  148. package/dist/schema/call/bridge.js +12 -12
  149. package/dist/schema/call/contact.d.ts +3 -3
  150. package/dist/schema/call/contact.js +2 -2
  151. package/dist/schema/call/demand.d.ts +3 -3
  152. package/dist/schema/call/demand.js +2 -2
  153. package/dist/schema/call/guard.d.ts +11 -11
  154. package/dist/schema/call/guard.js +2 -2
  155. package/dist/schema/call/machine.d.ts +2072 -679
  156. package/dist/schema/call/machine.js +51 -5
  157. package/dist/schema/call/order.d.ts +7 -7
  158. package/dist/schema/call/order.js +3 -6
  159. package/dist/schema/call/payment.d.ts +3 -3
  160. package/dist/schema/call/permission.d.ts +3 -3
  161. package/dist/schema/call/permission.js +2 -2
  162. package/dist/schema/call/personal.d.ts +337 -3
  163. package/dist/schema/call/personal.js +10 -0
  164. package/dist/schema/call/progress.d.ts +177 -9
  165. package/dist/schema/call/progress.js +7 -3
  166. package/dist/schema/call/proof.d.ts +6 -6
  167. package/dist/schema/call/repository.d.ts +3 -3
  168. package/dist/schema/call/repository.js +2 -2
  169. package/dist/schema/call/reward.d.ts +57 -57
  170. package/dist/schema/call/reward.js +3 -3
  171. package/dist/schema/call/semantic.js +48 -2
  172. package/dist/schema/call/service.d.ts +285 -113
  173. package/dist/schema/call/service.js +92 -28
  174. package/dist/schema/call/treasury.d.ts +57 -57
  175. package/dist/schema/call/treasury.js +3 -3
  176. package/dist/schema/common/index.d.ts +2 -0
  177. package/dist/schema/common/index.js +46 -10
  178. package/dist/schema/local/index.js +5 -1
  179. package/dist/schema/messenger/index.js +4 -1
  180. package/dist/schema/operations.d.ts +1318 -317
  181. package/dist/schema/operations.js +76 -7
  182. package/dist/schema/project/index.d.ts +5662 -164
  183. package/dist/schema/project/index.js +1136 -5
  184. package/dist/schema/query/index.d.ts +580 -19
  185. package/dist/schema/query/index.js +88 -36
  186. package/dist/schema/schema-query/index.d.ts +59 -3
  187. package/dist/schema/schema-query/index.js +45 -6
  188. package/dist/schema/trust/index.d.ts +1012 -6
  189. package/dist/schema/trust/index.js +212 -11
  190. package/dist/schema/utils/node-parser.js +13 -0
  191. package/dist/schema/utils/object-type-utils.d.ts +12 -0
  192. package/dist/schema/utils/object-type-utils.js +35 -0
  193. package/dist/schema/utils/permission-machine-check.d.ts +49 -0
  194. package/dist/schema/utils/permission-machine-check.js +121 -0
  195. package/dist/schema/utils/skills-recommendation.d.ts +2 -0
  196. package/dist/schema/utils/skills-recommendation.js +77 -0
  197. package/dist/schema-query/index.d.ts +17 -1
  198. package/dist/schema-query/index.js +359 -3
  199. package/dist/schemas/account_operation.schema.json +1 -1
  200. package/dist/schemas/bridge_operation.schema.json +14 -7
  201. package/dist/schemas/guard2file.schema.json +2 -0
  202. package/dist/schemas/index.json +1 -1
  203. package/dist/schemas/machineNode2file.schema.json +2 -0
  204. package/dist/schemas/messenger_operation.schema.json +1 -1
  205. package/dist/schemas/onchain_events.output.json +1 -1
  206. package/dist/schemas/onchain_operations.output.json +2820 -0
  207. package/dist/schemas/onchain_operations.schema.json +255 -65
  208. package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
  209. package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
  210. package/dist/schemas/onchain_operations_contact.schema.json +4 -3
  211. package/dist/schemas/onchain_operations_demand.schema.json +4 -3
  212. package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
  213. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  214. package/dist/schemas/onchain_operations_guard.schema.json +579 -1
  215. package/dist/schemas/onchain_operations_machine.schema.json +5 -4
  216. package/dist/schemas/onchain_operations_order.schema.json +7 -6
  217. package/dist/schemas/onchain_operations_payment.schema.json +2 -1
  218. package/dist/schemas/onchain_operations_permission.schema.json +3 -2
  219. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  220. package/dist/schemas/onchain_operations_progress.schema.json +91 -4
  221. package/dist/schemas/onchain_operations_proof.schema.json +2 -1
  222. package/dist/schemas/onchain_operations_repository.schema.json +4 -3
  223. package/dist/schemas/onchain_operations_reward.schema.json +7 -6
  224. package/dist/schemas/onchain_operations_service.schema.json +80 -19
  225. package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
  226. package/dist/schemas/onchain_table_data.output.json +1 -1
  227. package/dist/schemas/onchain_table_data.schema.json +10 -9
  228. package/dist/schemas/project_operation.output.json +3318 -57
  229. package/dist/schemas/project_operation.schema.json +728 -4
  230. package/dist/schemas/query_toolkit.output.json +16 -16
  231. package/dist/schemas/query_toolkit.schema.json +40 -3
  232. package/dist/schemas/schema_query.output.json +65 -2
  233. package/dist/schemas/schema_query.schema.json +31 -5
  234. package/dist/schemas/trust_score.output.json +392 -1
  235. package/dist/schemas/trust_score.schema.json +275 -1
  236. package/dist/schemas/wowok_buildin_info.output.json +81 -8
  237. package/dist/schemas/wowok_buildin_info.schema.json +46 -2
  238. package/dist/tools/handlers/onchain.js +636 -6
  239. package/dist/tools/handlers/project.js +71 -2
  240. package/dist/tools/handlers/query.js +117 -2
  241. package/dist/tools/handlers/schema-query.js +65 -1
  242. package/dist/tools/handlers/trust.js +192 -6
  243. package/dist/tools/index.d.ts +8 -0
  244. package/dist/tools/index.js +229 -15
  245. package/dist/tools/wrap.js +194 -15
  246. package/package.json +2 -2
@@ -33,7 +33,7 @@ export const TOOL_REGISTRY = [
33
33
  handler: handleOnchainOperations,
34
34
  config: {
35
35
  title: "⛓️ On-chain Operations",
36
- description: "On-chain operations for WoWok object: service (marketplace listings), machine (workflow templates), progress (order tracking), repository (on-chain database), arbitration (dispute resolution), contact (IM management), treasury (team funds), reward (incentive pools), allocation (auto-distribution), permission (access control), guard (programmable trust rules), personal (public profile), payment (direct coin transfers), demand (service requests), order (order management), gen_passport (verified credentials), proof (on-chain proof objects), gen_proof (generate proof shortcut).\n\n📌 Project association: Pass env.project='<prefix>' to auto-tag the object on-chain AND auto-associate it to the SQLite project (created objects are automatically added). For complex builds, create a project first (project_operation action='create_project'). For single objects, just pass env.project. See PROJECT ASSOCIATION POLICY in system prompt.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_operations' to retrieve the complete parameter schema. For individual operation schemas (e.g., 'onchain_operations_permission'), use schema_query with action='list_operations' to see all available operation schemas.",
36
+ description: "On-chain operations for WoWok object: service (marketplace listings), machine (workflow templates), progress (order tracking), repository (on-chain database), arbitration (dispute resolution), contact (IM management), treasury (team funds), reward (incentive pools), allocation (auto-distribution), permission (access control), guard (programmable trust rules), personal (public profile), payment (direct coin transfers), demand (service requests), order (order management), gen_passport (verified credentials), proof (on-chain proof objects), gen_proof (generate proof shortcut).\n\n💰 FUND SAFETY (service/arbitration/treasury/reward/allocation/payment): amounts are parsed against the target object's IMMUTABLE generic token type (e.g. Treasury<USDT> accepts ONLY USDT — mismatched coins/token_types are BLOCKED before execution). Monetary input with unresolvable token precision is BLOCKED (never guesses decimals) with known-token suggestions; retry once the token info resolves. Display-format amounts like \"2WOW\" are converted to raw u64 using the token's own decimals.\n\n📌 Project association: Pass env.project='<prefix>' to auto-tag the object on-chain AND auto-associate it to the SQLite project (created objects are automatically added). For complex builds, create a project first (project_operation action='create_project'). For single objects, just pass env.project. See PROJECT ASSOCIATION POLICY in system prompt.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_operations' to retrieve the complete parameter schema. For individual operation schemas (e.g., 'onchain_operations_permission'), use schema_query with action='list_operations' to see all available operation schemas.",
37
37
  inputSchema: OnchainOperationsSchema,
38
38
  outputSchema: CallOutputSchema,
39
39
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
@@ -139,18 +139,22 @@ export const TOOL_REGISTRY = [
139
139
  handler: handleWatchQueryOperations,
140
140
  config: {
141
141
  title: "🔍 Data Query Toolkit",
142
- description: "WOWOK data query toolkit — 9 query types covering local device data and on-chain blockchain data:\n\n"
142
+ description: "WOWOK data query toolkit — 13 query types covering local device data and on-chain blockchain data:\n\n"
143
143
  + "LOCAL (device-only, never on-chain):\n"
144
144
  + "1. local_mark_list — Query your LOCAL address book: maps human-readable names to blockchain addresses with optional tags. Use to resolve names→addresses or find addresses by tag.\n"
145
145
  + "2. account_list — Query your LOCAL accounts (addresses, messenger status, suspension state). Use filter.includePubkey=true to also include public keys. Use to discover available accounts before operations.\n"
146
146
  + "3. local_info_list — Query your LOCAL private info: sensitive data like delivery addresses, phone numbers, contacts stored ONLY on this device.\n"
147
147
  + "4. token_list — Query cached token metadata: symbol, decimals, icon URL, description for tokens previously fetched from chain. Use to look up token precision/decimals before performing token operations. Returns: TokenTypeInfo[] (type, alias, name, symbol, decimals, iconUrl).\n"
148
- + "5. account_balance — Query an account's coin balance OR Paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Supports multi-token via token_type parameter.\n"
148
+ + "5. account_balance — Query an account's coin balance OR Paginated coin objects. Use balance=true for total amount, or coin={cursor,limit} to list individual coin objects. Supports multi-token via token_type parameter. Results include `_money_display` with unit-converted values + decimals reminder.\n"
149
149
  + "6. local_names — Query local names by a list of addresses. For each address, returns the resolved account name (if exists) and local mark name (if exists). Returns: { account?, local_mark?, address }[].\n\n"
150
150
  + "ONCHAIN (blockchain):\n"
151
151
  + "7. onchain_personal_profile — Query any user's PUBLIC on-chain profile: social links, reputation (likes/dislikes), personal info records, voting history, referrer.\n"
152
- + "8. onchain_objects — Batch query on-chain WOWOK objects by ID or name: supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more.\n"
153
- + "9. onchain_received — Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and type filter.\n\n"
152
+ + "8. onchain_objects — Batch query on-chain WOWOK objects by ID or name: supports Service, Machine, Order, Treasury, Reward, Arb, Personal, Contact, and more. Monetary fields include `_money_display` annotations (token type from the object's immutable generic).\n"
153
+ + "9. onchain_received — Query objects (Payments, Tokens, NFTs) received by a specific object. Supports pagination and type filter. CoinWrapper mode returns token-aware `_money_display`.\n"
154
+ + "10. onchain_transaction — Verify what a specific transaction did on-chain (status, object changes, balance changes, gas, events). Balance changes include `_money_display` (unit-converted via each change's own coin_type; signed amounts supported).\n"
155
+ + "11. onchain_object_history — FORENSICS: all transactions that touched an object (auditing only — prefer assemble_context for AI context building).\n"
156
+ + "12. onchain_address_activity — FORENSICS: all transactions sent by an address (auditing only).\n"
157
+ + "13. token_value_convert — Convert between raw on-chain smallest units (u64) and human unit values in EITHER direction (e.g. \"2200000000\" ↔ \"2.2\" WOW). Unit→raw is REFUSED when token precision cannot be resolved (never guesses decimals).\n\n"
154
158
  + "For dynamic table data queries (pagination, table items), use the 'onchain_table_data' tool.\n\n"
155
159
  + "💡 Schema hint: Use schema_query with action='get' and name='query_toolkit' to retrieve the exact parameter schema with all query types and field definitions.",
156
160
  inputSchema: WatchQueryOperationsSchema,
@@ -189,7 +193,7 @@ export const TOOL_REGISTRY = [
189
193
  handler: handleOnchainEvents,
190
194
  config: {
191
195
  title: "📅 Watch WoWok On-chain Events",
192
- description: "Watch on-chain WoWok events by type. Supports arbitration events, new order events, progress events, demand presentation events, demand feedback events, and new entity registration events. Use pagination cursor for fetching large result sets.\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_events' to retrieve the exact parameter schema with all event types and field definitions.",
196
+ description: "Watch on-chain WoWok events by type. Supports arbitration events, new order events, progress events, demand presentation events, demand feedback events, and new entity registration events. Use pagination cursor for fetching large result sets. NewOrderEvent.amount includes `_money_display` annotation (unit-converted via the order's Service generic token type; raw-only with retry hint when precision is unavailable).\n\n💡 Schema hint: Use schema_query with action='get' and name='onchain_events' to retrieve the exact parameter schema with all event types and field definitions.",
193
197
  inputSchema: OnchainEventsInputSchema,
194
198
  outputSchema: OnchainEventsResultSchema,
195
199
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -201,7 +205,7 @@ export const TOOL_REGISTRY = [
201
205
  handler: handleWowokInfo,
202
206
  config: {
203
207
  title: "ℹ️ WoWok Build-in Information",
204
- description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'guard instructions', 'current network', 'value types', or 'mainnet bridge tokens'. For 'mainnet bridge tokens': returns cross-chain bridge tokens (ETH, WETH, WBTC, USDC, USDT) with each token's symbol, WOW-side type tag (wowTypeTag), EVM address, decimals, and description. The wowTypeTag (format {address}::{module}::{struct}) can be used directly as the `type_parameter` of Service / Treasury / Reward / Allocation objects to set their payment token — e.g. use USDT's wowTypeTag to create a Service that accepts USDT payments.",
208
+ description: "Query WoWok protocol information: 'constants', 'built-in permissions', 'common mistakes', 'guard instructions', 'current network', 'value types', or 'mainnet bridge tokens'. Use 'common mistakes' to proactively learn known field-name/unit/workflow pitfalls before submitting an operation (e.g. filter operation:\"compensation_fund_add\"). For 'mainnet bridge tokens': returns cross-chain bridge tokens (ETH, WETH, WBTC, USDC, USDT) with each token's symbol, WOW-side type tag (wowTypeTag), EVM address, decimals, and description. The wowTypeTag (format {address}::{module}::{struct}) can be used directly as the `type_parameter` of Service / Treasury / Reward / Allocation objects to set their payment token — e.g. use USDT's wowTypeTag to create a Service that accepts USDT payments.",
205
209
  inputSchema: ProtocolInfoQuerySchema,
206
210
  outputSchema: ProtocolInfoResultSchema,
207
211
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -220,8 +224,14 @@ export const TOOL_REGISTRY = [
220
224
  " 'list' - Show all available schemas (tools + on-chain operations). Start here to discover what exists.\n" +
221
225
  " 'get' - Fetch the full input JSON Schema by name (e.g. 'onchain_operations'). Use with the 'name' param.\n" +
222
226
  " 'get_output' - Fetch the output JSON Schema of a tool by name (e.g. 'onchain_operations'). Use with the 'name' param. Use this to understand a tool's return value structure.\n" +
227
+ " 'get_field' - Query a single field by dot-path (e.g. field_path='data.node.nodes.0.pairs'). Cheaper than 'get' when you only need one subtree.\n" +
223
228
  " 'search' - Find schemas by keyword, matching name/title/description. Use with the 'query' param.\n" +
224
- " 'list_operations' - Show only on-chain operation schemas (prefixed 'onchain_operations_'). Narrower than 'list'.",
229
+ " 'list_operations' - Show only on-chain operation schemas (prefixed 'onchain_operations_'). Narrower than 'list'.\n" +
230
+ " 'get_guard_templates' - Guard creation templates + best practices (e.g. signer_verification, progress_node_check). Omit 'template' to list all.\n" +
231
+ " 'search_examples' - Search verified example files by keyword (matches title/description/tags/operation_type/industry). Use with the 'query' param.\n" +
232
+ " 'get_tool_reference' - MCP tool usage reference (summaries, actions, prerequisites, notes). Pass name='<tool>' for one tool, query='<keyword>' to search, or omit for the full catalog.\n" +
233
+ " 'get_guard_design_patterns' - Curated Guard design patterns (business requirement → logic tree template). Pass name='<pattern_id>', query='<host>' (e.g. 'service_buy_guard', 'machine_forward'), or omit for the full catalog.\n" +
234
+ " 'get_safety_rules' - Safety rule tables sunk from the wowok-safety skill: object reuse, immutability-after-publish, LOCAL/ONCHAIN/QUERY classification, naming conventions.",
225
235
  inputSchema: SchemaQueryInputSchema,
226
236
  outputSchema: SchemaQueryOutputSchema,
227
237
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
@@ -286,6 +296,39 @@ export const TOOL_REGISTRY = [
286
296
  " • refresh_objects — Refresh object cache from chain (batch query, rate-limited).\n" +
287
297
  " • get_object_diff — Get field-level diff of an object between two timestamps.\n\n" +
288
298
  "═══════════════════════════════════════════════════════════════\n" +
299
+ " INDUSTRY MODE RECOMMENDATION + REGISTRY (9 actions, GLM6/92 §E)\n" +
300
+ "═══════════════════════════════════════════════════════════════\n" +
301
+ " • recommend_industry — CALL THIS FIRST when the user describes a business without naming an industry. " +
302
+ "Returns top-3 similar industries + verified reference examples ('from scratch vs giants' shoulders').\n" +
303
+ " • list_modes — List builtin industry modes + your custom modes.\n" +
304
+ " • derive_user_mode — Derive a custom mode from a builtin (modify machine_shape/allocator/config). R-M1-11 enforced.\n" +
305
+ " • evolve_user_mode — Iterate a custom mode (version bump + evolution history).\n" +
306
+ " • register_user_mode — Register a fully custom mode (requires machine_shape + key_risk).\n" +
307
+ " • unregister_user_mode — Delete a custom mode.\n" +
308
+ " • register_custom_metric / register_custom_constraint — Extend the evaluation registries.\n" +
309
+ " • list_metrics_constraints — List metrics + constraints (filterable by type/scope).\n\n" +
310
+ "═══════════════════════════════════════════════════════════════\n" +
311
+ " INTENT → RISK → SUBSTEP PIPELINE (3 actions, GLM5-31 §V3/V4)\n" +
312
+ "═══════════════════════════════════════════════════════════════\n" +
313
+ " • analyze_intent (C1) — Business intent text → parsed intent (primary/secondary objects, " +
314
+ "detected scenes, industry) + per-object puzzle snapshots + recommended creation order. " +
315
+ "Required: intent.\n" +
316
+ " • aggregate_risks (C2) — Puzzle snapshots → calibrated risks (CRITICAL/HIGH/MEDIUM/LOW/INFO) " +
317
+ "with blocking status (RISK_BLOCKED / RISK_PENDING_CONFIRM / RISK_PASSED). Required: project + " +
318
+ "(puzzles OR intent — when intent is given, analyze_intent runs first automatically). " +
319
+ "Optional: planned_objects (OBJECT_REUSE check), planned_operations (IMMUTABILITY check).\n" +
320
+ " • trace_substeps (C3) — Substep execution records → DAG coherence analysis (dangling inputs, " +
321
+ "circular refs, missing outputs, cross-step breaks, topological order, D-10 verdict). " +
322
+ "Required: project + substeps.\n\n" +
323
+ "═══════════════════════════════════════════════════════════════\n" +
324
+ " MERCHANT ONBOARDING WIZARD (1 action, GLM6/93 §5)\n" +
325
+ "═══════════════════════════════════════════════════════════════\n" +
326
+ " • merchant_guide — 10-step guided flow from 'I want to sell X' to a validated creation plan: " +
327
+ "intent analysis → industry matching → module adoption → semantic blueprint → evaluation preview → " +
328
+ "harness check → ordered creation plan. Stateless: pass guide_state UNCHANGED between calls, " +
329
+ "advance via guide_confirm. NEVER executes on-chain — materialize the plan via create_project + " +
330
+ "onchain_operations. Required: intent (first call) or guide_state.\n\n" +
331
+ "═══════════════════════════════════════════════════════════════\n" +
289
332
  " CONTEXT ASSEMBLY (1 action)\n" +
290
333
  "═══════════════════════════════════════════════════════════════\n" +
291
334
  " • assemble_context — Query on-chain object states + extract embedded history + optional events, " +
@@ -462,10 +505,10 @@ const WOWOK_TOOL_DESCRIPTION = [
462
505
  "Projects are the core organizing unit for all WoWok workflows. The policy is context-aware:",
463
506
  "",
464
507
  "CASE 1 — COMPLEX REQUIREMENT (user wants to build/deploy a full service):",
465
- " Examples: '搭建旅行地陪服务', '开一个玩具店', '创建租赁服务'",
508
+ " Examples: 'build a travel guide service', 'open a toy store', 'create a rental service'",
466
509
  " → You MUST auto-create a project FIRST, then create objects.",
467
510
  " → Check for similar existing projects first: project_operation action='list_projects'",
468
- " If similar projects exist (same industry), remind the user: '发现类似项目 X, 是否复用或新建?'",
511
+ " If similar projects exist (same industry), remind the user: 'Found similar project X. Reuse or create new?'",
469
512
  " → Workflow:",
470
513
  " 1. project_operation action='create_project' (perspective='producer', project_industry=<best match>)",
471
514
  " 2. Create on-chain objects via onchain_operations with env.project='<prefix>' (auto-tags + auto-associates to SQLite project)",
@@ -475,11 +518,11 @@ const WOWOK_TOOL_DESCRIPTION = [
475
518
  " 6. Report results, fix critical findings, then publish Service",
476
519
  "",
477
520
  "CASE 2 — SINGLE OBJECT CREATION (user wants one specific object):",
478
- " Examples: '创建一个Permission', '添加一个Contact', '建一个Guard'",
521
+ " Examples: 'create a Permission', 'add a Contact', 'build a Guard'",
479
522
  " → Do NOT auto-create a project. If the user has an existing project, create with env.project='<prefix>' to auto-associate.",
480
523
  " → If no existing project, after creation, REMIND the user:",
481
- " '此对象已创建。建议将其加入一个项目以便管理: project_operation action=\"add_object\"",
482
- " 如还没有项目, 可用 action=\"create_project\" 新建。现有项目: [list projects if any]'",
524
+ " 'This object has been created. Consider adding it to a project for management: project_operation action=\"add_object\"",
525
+ " If no project exists yet, use action=\"create_project\" to create one. Existing projects: [list projects if any]'",
483
526
  " → If the user then says 'yes, create a project' or 'add to project X', proceed accordingly.",
484
527
  "",
485
528
  "CASE 3 — CONSUMER FLOW (user wants to buy/evaluate a service):",
@@ -545,6 +588,150 @@ function formatZodErrors(error, input) {
545
588
  return `${path} [${code}]: ${message}${extras}`;
546
589
  });
547
590
  }
591
+ function generateSuggestion(code, issue, receivedValue) {
592
+ const issueAny = issue;
593
+ switch (code) {
594
+ case "invalid_type": {
595
+ const expected = issueAny.expected;
596
+ const received = issueAny.received;
597
+ if (expected === "number" && typeof receivedValue === "string") {
598
+ return `Convert to number: ${Number(receivedValue)}`;
599
+ }
600
+ if (expected === "string") {
601
+ return `Wrap in quotes or call String(...)`;
602
+ }
603
+ if (expected === "array") {
604
+ return `Wrap in array: [${JSON.stringify(receivedValue)}]`;
605
+ }
606
+ if (expected === "object") {
607
+ return `Provide an object, not a primitive`;
608
+ }
609
+ return `Convert value to ${expected ?? "the expected type"}`;
610
+ }
611
+ case "invalid_enum_value": {
612
+ const options = issueAny.options;
613
+ const optionsStr = Array.isArray(options)
614
+ ? options.map((v) => JSON.stringify(v)).join(" | ")
615
+ : String(options);
616
+ return `Use one of: ${optionsStr}`;
617
+ }
618
+ case "invalid_literal": {
619
+ const expected = issueAny.expected;
620
+ return `Use the exact value: ${JSON.stringify(expected)}`;
621
+ }
622
+ case "too_small": {
623
+ const minimum = issueAny.minimum;
624
+ const type = issueAny.type;
625
+ if (type === "array") {
626
+ return `Add at least ${minimum} element(s) to the array`;
627
+ }
628
+ if (type === "string") {
629
+ return `String must be at least ${minimum} character(s) long`;
630
+ }
631
+ if (type === "number") {
632
+ return `Use a value >= ${minimum}`;
633
+ }
634
+ return `Value must be >= ${minimum}`;
635
+ }
636
+ case "too_big": {
637
+ const maximum = issueAny.maximum;
638
+ const type = issueAny.type;
639
+ if (type === "array") {
640
+ return `Reduce array to at most ${maximum} element(s)`;
641
+ }
642
+ if (type === "string") {
643
+ return `Shorten string to at most ${maximum} character(s)`;
644
+ }
645
+ if (type === "number") {
646
+ return `Use a value <= ${maximum}`;
647
+ }
648
+ return `Value must be <= ${maximum}`;
649
+ }
650
+ case "unrecognized_keys": {
651
+ const keys = issueAny.keys;
652
+ return `Remove unknown field(s): ${(keys ?? []).join(", ")}. Check the schema for valid field names.`;
653
+ }
654
+ case "invalid_union": {
655
+ return `Value does not match any of the union variants. Check the schema for valid shapes.`;
656
+ }
657
+ case "invalid_string": {
658
+ const validation = issueAny.validation;
659
+ if (validation === "url")
660
+ return `Provide a valid URL string`;
661
+ if (validation === "email")
662
+ return `Provide a valid email string`;
663
+ if (validation === "uuid")
664
+ return `Provide a valid UUID string`;
665
+ if (validation === "regex")
666
+ return `String does not match the required pattern`;
667
+ return `Provide a valid string matching the validation: ${validation ?? "unknown"}`;
668
+ }
669
+ case "invalid_date": {
670
+ return `Provide a valid Date object or ISO date string`;
671
+ }
672
+ case "not_finite": {
673
+ return `Use a finite number (not Infinity or NaN)`;
674
+ }
675
+ case "invalid_arguments": {
676
+ return `Arguments do not match the expected schema`;
677
+ }
678
+ case "invalid_return_type": {
679
+ return `Return type does not match the expected schema`;
680
+ }
681
+ case "custom": {
682
+ return `Custom validation failed — see the field's description in the schema`;
683
+ }
684
+ default: {
685
+ return `Fix the value at '${issue.path.join(".")}' based on the schema`;
686
+ }
687
+ }
688
+ }
689
+ function formatZodErrorsStructured(error, input) {
690
+ return error.issues.map(issue => {
691
+ const path = issue.path.length > 0
692
+ ? issue.path.map(p => typeof p === "number" ? `[${p}]` : p).join(".").replace(".[", "[")
693
+ : "(root)";
694
+ const code = issue.code;
695
+ const message = issue.message;
696
+ const issueAny = issue;
697
+ let expected;
698
+ if (code === "invalid_type") {
699
+ const exp = issueAny.expected;
700
+ const rec = issueAny.received;
701
+ if (typeof exp === "string" && typeof rec === "string") {
702
+ expected = exp;
703
+ }
704
+ }
705
+ else if (code === "invalid_literal") {
706
+ const exp = issueAny.expected;
707
+ if (exp !== undefined) {
708
+ expected = typeof exp === "string" ? exp : JSON.stringify(exp);
709
+ }
710
+ }
711
+ else if (code === "invalid_enum_value") {
712
+ const options = issueAny.options;
713
+ if (Array.isArray(options)) {
714
+ expected = options.map((v) => JSON.stringify(v)).join(" | ");
715
+ }
716
+ }
717
+ else if (code === "too_big" || code === "too_small") {
718
+ const threshold = issueAny.maximum ?? issueAny.minimum;
719
+ if (threshold !== undefined) {
720
+ expected = String(threshold);
721
+ }
722
+ }
723
+ const receivedVal = extractValueAtPath(input, issue.path);
724
+ const suggestion = generateSuggestion(code, issue, receivedVal);
725
+ return {
726
+ path,
727
+ code,
728
+ message,
729
+ expected,
730
+ received_value: receivedVal,
731
+ suggestion,
732
+ };
733
+ });
734
+ }
548
735
  function extractValueAtPath(input, path) {
549
736
  if (input === undefined || input === null || path.length === 0) {
550
737
  return undefined;
@@ -837,18 +1024,36 @@ async function handleWowok(args) {
837
1024
  if (unknownFields.length > 0) {
838
1025
  allErrors.push(`Unknown field(s): ${unknownFields.join(", ")}`);
839
1026
  }
1027
+ const structuredErrors = [];
1028
+ if (!validationResult.success) {
1029
+ structuredErrors.push(...formatZodErrorsStructured(validationResult.error, normalizedData));
1030
+ }
1031
+ if (unknownFields.length > 0) {
1032
+ for (const f of unknownFields) {
1033
+ structuredErrors.push({
1034
+ path: f,
1035
+ code: "unrecognized_keys",
1036
+ message: `Unknown field '${f}' is not allowed`,
1037
+ suggestion: `Remove field '${f}' or check the schema for valid field names`,
1038
+ });
1039
+ }
1040
+ }
840
1041
  const fullSchema = loadPreGeneratedSchema(normalizedToolName) ?? zodToJsonSchemaSafe(entry.config.inputSchema, normalizedToolName);
841
1042
  const relevantSchema = extractRelevantSchema(fullSchema, normalizedToolName, normalizedData);
1043
+ const firstSuggestion = structuredErrors[0]?.suggestion
1044
+ ? ` FIRST ERROR SUGGESTION: ${structuredErrors[0].suggestion}`
1045
+ : '';
842
1046
  const errorPreview = allErrors.slice(0, 5).map((e, i) => ` ${i + 1}. ${e}`).join("\n");
843
1047
  const schemaPreview = buildSchemaPreview(relevantSchema, normalizedToolName, normalizedData);
844
1048
  const textContent = [
845
- `Schema mismatch for ${normalizedToolName}. ${allErrors.length} error(s):`,
1049
+ `Schema mismatch for ${normalizedToolName}. ${allErrors.length} error(s).${firstSuggestion}`,
846
1050
  errorPreview,
847
1051
  "",
848
1052
  schemaPreview,
849
1053
  "",
850
1054
  "Fix the parameters based on the errors above and the schema summary, then retry.",
851
1055
  `Full JSON Schema is in the structuredContent.schema.input field (cache it for future ${normalizedToolName} calls).`,
1056
+ `Structured errors with fix suggestions are in structuredContent.result.structured_errors (ARCH-02).`,
852
1057
  ].filter(Boolean).join("\n");
853
1058
  return {
854
1059
  content: [{
@@ -859,6 +1064,7 @@ async function handleWowok(args) {
859
1064
  result: {
860
1065
  status: "schema_mismatch",
861
1066
  errors: allErrors,
1067
+ structured_errors: structuredErrors,
862
1068
  hint: `Fix your parameters based on the schema below and retry. CACHE THIS SCHEMA for future ${normalizedToolName} calls — you don't need to query it again.`,
863
1069
  },
864
1070
  schema: {
@@ -903,12 +1109,19 @@ async function handleWowok(args) {
903
1109
  const fullSchema = loadPreGeneratedSchema(normalizedToolName) ?? zodToJsonSchemaSafe(entry.config.inputSchema, normalizedToolName);
904
1110
  const relevantSchema = extractRelevantSchema(fullSchema, normalizedToolName, normalizedData);
905
1111
  const schemaPreview = buildSchemaPreview(relevantSchema, normalizedToolName, normalizedData);
1112
+ const structuredErrors = [{
1113
+ path: "(runtime)",
1114
+ code: "schema_validation_error",
1115
+ message: errorMessage,
1116
+ suggestion: "Check the error message and the schema below for the correct field format",
1117
+ }];
906
1118
  const textContent = [
907
1119
  `Schema mismatch for ${normalizedToolName}: ${errorMessage}`,
908
1120
  "",
909
1121
  schemaPreview,
910
1122
  "",
911
1123
  "Fix the parameters and retry. Full JSON Schema is in structuredContent.schema.input.",
1124
+ "Structured errors with fix suggestions are in structuredContent.result.structured_errors (ARCH-02).",
912
1125
  ].join("\n");
913
1126
  return {
914
1127
  content: [{
@@ -919,6 +1132,7 @@ async function handleWowok(args) {
919
1132
  result: {
920
1133
  status: "schema_mismatch",
921
1134
  errors: [errorMessage],
1135
+ structured_errors: structuredErrors,
922
1136
  hint: `Fix your parameters based on the schema below and retry. CACHE THIS SCHEMA for future ${normalizedToolName} calls.`,
923
1137
  },
924
1138
  schema: {
@@ -1055,7 +1269,7 @@ export function listTools() {
1055
1269
  name: "wowok",
1056
1270
  title: "WoWok MCP",
1057
1271
  description: WOWOK_TOOL_DESCRIPTION,
1058
- inputSchema: zodToJsonSchemaSafe(WowokToolDisplaySchema, "wowok"),
1272
+ inputSchema: resolveSchemaRefs(zodToJsonSchemaSafe(WowokToolDisplaySchema, "wowok")),
1059
1273
  }];
1060
1274
  }
1061
1275
  export function registerAllTools(server) {