@wowok/agent-mcp 2.6.3 → 2.6.6

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 (193) hide show
  1. package/README.md +13 -9
  2. package/dist/customer/customer-advice.d.ts +31 -0
  3. package/dist/customer/customer-advice.js +129 -0
  4. package/dist/customer/index.d.ts +2 -0
  5. package/dist/customer/index.js +2 -0
  6. package/dist/customer/info-puzzle.d.ts +8 -1
  7. package/dist/customer/info-puzzle.js +30 -5
  8. package/dist/customer/order-monitor.d.ts +2 -0
  9. package/dist/customer/order-monitor.js +3 -2
  10. package/dist/customer/post-purchase.d.ts +2 -0
  11. package/dist/customer/post-purchase.js +6 -5
  12. package/dist/customer/preorder-compare.d.ts +24 -0
  13. package/dist/customer/preorder-compare.js +34 -0
  14. package/dist/customer/reminder-system.d.ts +2 -0
  15. package/dist/customer/reminder-system.js +2 -1
  16. package/dist/customer/risk-assessment.js +4 -3
  17. package/dist/customer/types.d.ts +5 -0
  18. package/dist/examples/arbitration-dispute-create.json +41 -0
  19. package/dist/examples/arbitration-vote-weighted.json +35 -0
  20. package/dist/examples/arbitration-voting-guard-add.json +38 -0
  21. package/dist/examples/demand-present-service.json +33 -0
  22. package/dist/examples/gen-passport-verify-guard.json +48 -0
  23. package/dist/examples/guard-template-balance-check.json +36 -15
  24. package/dist/examples/guard-template-time-lock.json +33 -12
  25. package/dist/examples/insurance-guard-claim-timelock.json +75 -0
  26. package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
  27. package/dist/examples/insurance-machine-create-publish.json +75 -0
  28. package/dist/examples/insurance-service-allocators-publish.json +56 -0
  29. package/dist/examples/machine-multisig-threshold.json +86 -0
  30. package/dist/examples/machine-template-7node-rental.json +99 -94
  31. package/dist/examples/payment-scenario-bound.json +45 -0
  32. package/dist/examples/rental-ziroom-machine-create.json +126 -114
  33. package/dist/examples/rental-ziroom-permission-create.json +10 -3
  34. package/dist/examples/rental-ziroom-service-create.json +27 -18
  35. package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
  36. package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
  37. package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
  38. package/dist/examples/retail-adv-reward-guard-add.json +51 -0
  39. package/dist/examples/retail-myshop-allocation-activate.json +55 -0
  40. package/dist/examples/retail-myshop-arbitration-create.json +40 -0
  41. package/dist/examples/retail-myshop-contact-create.json +43 -0
  42. package/dist/examples/retail-myshop-order-create.json +56 -0
  43. package/dist/examples/retail-myshop-progress-operate.json +38 -0
  44. package/dist/examples/retail-myshop-reward-create.json +35 -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 +192 -5
  61. package/dist/extensions/constraint-registry.js +3 -1
  62. package/dist/extensions/modes.js +10 -4
  63. package/dist/extensions/registry.d.ts +14 -9
  64. package/dist/extensions/registry.js +69 -14
  65. package/dist/extensions/types.d.ts +1 -0
  66. package/dist/knowledge/fund-layer.d.ts +67 -1
  67. package/dist/knowledge/fund-layer.js +561 -12
  68. package/dist/knowledge/guard-templates.d.ts +10 -0
  69. package/dist/knowledge/guard-templates.js +50 -0
  70. package/dist/knowledge/index.d.ts +2 -2
  71. package/dist/knowledge/index.js +2 -2
  72. package/dist/knowledge/machine-risk.js +4 -1
  73. package/dist/knowledge/progress-context.js +1 -1
  74. package/dist/knowledge/progress-ledger.js +3 -3
  75. package/dist/knowledge/progress-templates.js +1 -1
  76. package/dist/knowledge/progress-translation.js +1 -1
  77. package/dist/knowledge/safety-rules.d.ts +83 -1
  78. package/dist/knowledge/safety-rules.js +166 -2
  79. package/dist/knowledge/scenario-modes.d.ts +1 -1
  80. package/dist/knowledge/scenario-modes.js +13 -11
  81. package/dist/knowledge/template-registry.d.ts +48 -0
  82. package/dist/knowledge/template-registry.js +341 -0
  83. package/dist/knowledge/tool-constraints.js +6 -6
  84. package/dist/knowledge/tools-reference.js +11 -8
  85. package/dist/participation/merchant-interest.d.ts +32 -0
  86. package/dist/participation/merchant-interest.js +100 -0
  87. package/dist/participation/radar-core.d.ts +104 -0
  88. package/dist/participation/radar-core.js +269 -0
  89. package/dist/project/context-assembly.js +8 -0
  90. package/dist/project/edit-planner.js +27 -56
  91. package/dist/project/evaluation.d.ts +36 -0
  92. package/dist/project/evaluation.js +422 -56
  93. package/dist/project/game-theory.d.ts +43 -0
  94. package/dist/project/game-theory.js +177 -0
  95. package/dist/project/graph-builder.js +1 -0
  96. package/dist/project/handlers.d.ts +38 -0
  97. package/dist/project/handlers.js +65 -35
  98. package/dist/project/intent-analyzer.d.ts +71 -0
  99. package/dist/project/intent-analyzer.js +149 -0
  100. package/dist/project/machine-nodes.d.ts +2 -0
  101. package/dist/project/machine-nodes.js +36 -0
  102. package/dist/project/merchant-guide.d.ts +165 -0
  103. package/dist/project/merchant-guide.js +264 -0
  104. package/dist/project/mode-actions.d.ts +199 -0
  105. package/dist/project/mode-actions.js +309 -0
  106. package/dist/project/participation-radar.d.ts +18 -0
  107. package/dist/project/participation-radar.js +428 -0
  108. package/dist/project/pipeline-actions.d.ts +101 -0
  109. package/dist/project/pipeline-actions.js +109 -0
  110. package/dist/project/semantic-graph.d.ts +95 -0
  111. package/dist/project/semantic-graph.js +245 -0
  112. package/dist/schema/call/allocation.d.ts +11 -11
  113. package/dist/schema/call/allocation.js +11 -1
  114. package/dist/schema/call/arbitration.d.ts +21 -21
  115. package/dist/schema/call/arbitration.js +17 -9
  116. package/dist/schema/call/base.d.ts +2 -2
  117. package/dist/schema/call/base.js +1 -1
  118. package/dist/schema/call/bridge.d.ts +127 -127
  119. package/dist/schema/call/bridge.js +12 -12
  120. package/dist/schema/call/contact.d.ts +3 -3
  121. package/dist/schema/call/demand.d.ts +3 -3
  122. package/dist/schema/call/guard.d.ts +11 -11
  123. package/dist/schema/call/guard.js +1 -1
  124. package/dist/schema/call/machine.d.ts +216 -21
  125. package/dist/schema/call/machine.js +1 -1
  126. package/dist/schema/call/order.d.ts +7 -7
  127. package/dist/schema/call/payment.d.ts +3 -3
  128. package/dist/schema/call/permission.d.ts +3 -3
  129. package/dist/schema/call/personal.d.ts +337 -3
  130. package/dist/schema/call/personal.js +10 -0
  131. package/dist/schema/call/progress.d.ts +177 -9
  132. package/dist/schema/call/progress.js +7 -3
  133. package/dist/schema/call/proof.d.ts +6 -6
  134. package/dist/schema/call/repository.d.ts +3 -3
  135. package/dist/schema/call/reward.d.ts +57 -57
  136. package/dist/schema/call/semantic.js +41 -1
  137. package/dist/schema/call/service.d.ts +114 -114
  138. package/dist/schema/call/service.js +11 -2
  139. package/dist/schema/call/treasury.d.ts +57 -57
  140. package/dist/schema/messenger/index.js +4 -1
  141. package/dist/schema/operations.d.ts +713 -291
  142. package/dist/schema/operations.js +33 -0
  143. package/dist/schema/project/index.d.ts +4635 -100
  144. package/dist/schema/project/index.js +868 -1
  145. package/dist/schema/query/index.d.ts +363 -19
  146. package/dist/schema/query/index.js +25 -3
  147. package/dist/schema/schema-query/index.d.ts +13 -7
  148. package/dist/schema/schema-query/index.js +29 -5
  149. package/dist/schema/trust/index.d.ts +1012 -6
  150. package/dist/schema/trust/index.js +212 -11
  151. package/dist/schema/utils/skills-recommendation.js +1 -0
  152. package/dist/schema-query/index.d.ts +4 -1
  153. package/dist/schema-query/index.js +255 -1
  154. package/dist/schemas/bridge_operation.schema.json +14 -7
  155. package/dist/schemas/guard2file.schema.json +2 -0
  156. package/dist/schemas/index.json +1 -1
  157. package/dist/schemas/machineNode2file.schema.json +2 -0
  158. package/dist/schemas/messenger_operation.schema.json +1 -1
  159. package/dist/schemas/onchain_operations.schema.json +143 -15
  160. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  161. package/dist/schemas/onchain_operations_arbitration.schema.json +7 -5
  162. package/dist/schemas/onchain_operations_contact.schema.json +1 -0
  163. package/dist/schemas/onchain_operations_demand.schema.json +1 -0
  164. package/dist/schemas/onchain_operations_gen_passport.schema.json +2 -0
  165. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
  166. package/dist/schemas/onchain_operations_guard.schema.json +578 -0
  167. package/dist/schemas/onchain_operations_machine.schema.json +1 -0
  168. package/dist/schemas/onchain_operations_order.schema.json +4 -3
  169. package/dist/schemas/onchain_operations_payment.schema.json +1 -0
  170. package/dist/schemas/onchain_operations_permission.schema.json +1 -0
  171. package/dist/schemas/onchain_operations_personal.schema.json +37 -0
  172. package/dist/schemas/onchain_operations_progress.schema.json +90 -3
  173. package/dist/schemas/onchain_operations_proof.schema.json +1 -0
  174. package/dist/schemas/onchain_operations_repository.schema.json +1 -0
  175. package/dist/schemas/onchain_operations_reward.schema.json +1 -0
  176. package/dist/schemas/onchain_operations_service.schema.json +4 -3
  177. package/dist/schemas/onchain_operations_treasury.schema.json +1 -0
  178. package/dist/schemas/project_operation.output.json +2243 -1
  179. package/dist/schemas/project_operation.schema.json +683 -1
  180. package/dist/schemas/query_toolkit.output.json +1 -1
  181. package/dist/schemas/query_toolkit.schema.json +37 -0
  182. package/dist/schemas/schema_query.output.json +1 -1
  183. package/dist/schemas/schema_query.schema.json +30 -5
  184. package/dist/schemas/trust_score.output.json +392 -1
  185. package/dist/schemas/trust_score.schema.json +275 -1
  186. package/dist/tools/handlers/onchain.js +73 -8
  187. package/dist/tools/handlers/project.js +46 -0
  188. package/dist/tools/handlers/query.js +117 -2
  189. package/dist/tools/handlers/schema-query.js +41 -0
  190. package/dist/tools/handlers/trust.js +192 -6
  191. package/dist/tools/index.js +52 -9
  192. package/dist/tools/wrap.js +194 -15
  193. package/package.json +2 -2
@@ -1,5 +1,94 @@
1
1
  import { z } from "zod";
2
2
  import { NameOrAddressSchema } from "../common/index.js";
3
+ const RiskCheckOutputSchema = z.object({
4
+ id: z.string().describe("Check identifier."),
5
+ dimension: z
6
+ .enum(["workflow", "fund", "trust", "behavior"])
7
+ .describe("Dimension this check belongs to."),
8
+ description: z.string().describe("Check description."),
9
+ weight: z.number().describe("Check weight within its dimension (percentage)."),
10
+ passed: z.boolean().describe("Whether the check passed."),
11
+ advice: z.string().optional().describe("Advice when the check failed."),
12
+ });
13
+ const ReminderOutputSchema = z.object({
14
+ id: z.string().describe("Reminder rule identifier."),
15
+ stage: z
16
+ .enum(["browse", "evaluate", "preorder", "in_progress", "complete", "after_sale"])
17
+ .describe("Workflow stage this reminder belongs to."),
18
+ priority: z
19
+ .enum(["required", "recommended", "info", "reminder"])
20
+ .describe("Priority: required = blocking, recommended = strongly suggested."),
21
+ message: z.string().describe("Human-readable reminder message."),
22
+ action: z.string().optional().describe("Suggested follow-up action, if any."),
23
+ });
24
+ const IndustryEnumSchema = z.enum([
25
+ "freelance", "rental", "education", "travel", "subscription", "retail",
26
+ ]);
27
+ const PreorderPreferencesInputSchema = z
28
+ .object({
29
+ price_sensitivity: z.enum(["low", "medium", "high"]).optional(),
30
+ budget_range: z
31
+ .object({
32
+ min: z.union([z.string(), z.number()]).describe("Budget lower bound (smallest token unit)."),
33
+ max: z.union([z.string(), z.number()]).describe("Budget upper bound (smallest token unit)."),
34
+ })
35
+ .strict()
36
+ .optional(),
37
+ value_orientation: z.enum(["quality", "balanced", "budget"]).optional(),
38
+ discount_sensitivity: z.number().min(0).max(1).optional(),
39
+ delivery_speed_priority: z.enum(["urgent", "normal", "flexible"]).optional(),
40
+ max_acceptable_cycle: z.number().nonnegative().describe("Max acceptable delivery cycle (days).").optional(),
41
+ response_time_expectation: z.number().nonnegative().describe("Expected merchant response time (hours).").optional(),
42
+ merchant_preference: z.enum(["established", "emerging", "neutral"]).optional(),
43
+ min_order_history: z.number().int().nonnegative().optional(),
44
+ bargain_hunting: z.number().min(0).max(1).optional(),
45
+ reward_seeking: z.boolean().optional(),
46
+ referral_participation: z.boolean().optional(),
47
+ communication_style: z.enum(["formal", "casual", "friendly"]).optional(),
48
+ transparency_demand: z.number().min(0).max(1).optional(),
49
+ after_sales_expectation: z.enum(["full", "basic", "minimal"]).optional(),
50
+ risk_appetite: z.enum(["conservative", "balanced", "aggressive"]).optional(),
51
+ min_trust_score: z.number().min(0).max(100).optional(),
52
+ require_arbitration: z.boolean().optional(),
53
+ require_compensation_fund: z.boolean().optional(),
54
+ preferred_industries: z.array(z.string()).optional(),
55
+ preferred_tokens: z.array(z.string()).optional(),
56
+ preferred_merchants: z.array(z.string()).optional(),
57
+ })
58
+ .strict();
59
+ const UserMetricInputSchema = z
60
+ .object({
61
+ name: z.string().describe("Stable metric identifier (e.g. 'merchant_tenure_days')."),
62
+ label: z.string().describe("Human-readable label shown to the user."),
63
+ evaluator: z
64
+ .enum(["threshold", "ratio", "boolean", "presence", "regex_match", "custom_query"])
65
+ .describe("How the metric is evaluated against the puzzle context."),
66
+ params: z
67
+ .object({
68
+ path: z.string().optional().describe("JSON path in the raw data context (e.g. 'service.name')."),
69
+ threshold: z.union([z.string(), z.number()]).optional().describe("Threshold value (threshold/presence evaluators)."),
70
+ invert: z.boolean().optional().describe("true: pass when value <= threshold."),
71
+ min: z.number().optional().describe("Min ratio (ratio evaluator)."),
72
+ max: z.number().optional().describe("Max ratio (ratio evaluator)."),
73
+ pattern: z.string().optional().describe("Regex pattern (regex_match evaluator)."),
74
+ query_key: z.string().optional().describe("Custom query identifier (custom_query evaluator)."),
75
+ })
76
+ .strict(),
77
+ weight: z.number().min(0).max(1).describe("Relative weight vs other user metrics (0-1)."),
78
+ advice_on_fail: z.string().optional(),
79
+ advice_on_pass: z.string().optional(),
80
+ })
81
+ .strict();
82
+ const UserMetricsInputSchema = z
83
+ .object({
84
+ metrics: z.array(UserMetricInputSchema).min(1).describe("User-defined scoring factors."),
85
+ adjustment_cap: z
86
+ .number()
87
+ .positive()
88
+ .optional()
89
+ .describe("Global cap for the composite confidence adjustment (default ±10 points)."),
90
+ })
91
+ .strict();
3
92
  export const TrustScoreInputSchema = z
4
93
  .object({
5
94
  service: NameOrAddressSchema.describe("Service object ID or local_mark name to evaluate. " +
@@ -16,7 +105,13 @@ export const TrustScoreInputSchema = z
16
105
  .describe("InfoPuzzle collection depth. " +
17
106
  "browse: only Service basics + trust score; " +
18
107
  "evaluate (default): + workflow/fund/trust dimensions risk assessment; " +
19
- "preorder: + merchant behavior + market context (most thorough)."),
108
+ "preorder: + full preorder advice (confidence, game strategies, preference match, industry risks, blocking reminders)."),
109
+ industry: IndustryEnumSchema.optional().describe("Explicit industry override for industry-specific risk checks and needs matrix. " +
110
+ "If omitted at depth=preorder, the industry is inferred from the puzzle."),
111
+ preferences: PreorderPreferencesInputSchema.optional().describe("Optional user preference overrides (partial; merged over profile-derived defaults). " +
112
+ "Only used at depth=preorder for preference matching and pref-aware strategies."),
113
+ user_metrics: UserMetricsInputSchema.optional().describe("Optional user-controllable scoring factors (评分体系用户可控). " +
114
+ "Evaluated at depth=preorder; the composite adjustment (±cap) nudges the order confidence score."),
20
115
  network: z
21
116
  .string()
22
117
  .optional()
@@ -25,6 +120,14 @@ export const TrustScoreInputSchema = z
25
120
  .boolean()
26
121
  .optional()
27
122
  .describe("Skip object cache and force a fresh on-chain query."),
123
+ compare_with: z
124
+ .array(z.string())
125
+ .min(1)
126
+ .max(9)
127
+ .optional()
128
+ .describe("Optional candidate Service addresses/LocalMark names (1-9) for deterministic multi-service comparison. " +
129
+ "Only used at depth=preorder. The SAME preferences/user_metrics/industry are applied uniformly to all " +
130
+ "candidates; output gains a `comparison` block with per-metric bests (NO overall ranking — the buyer decides)."),
28
131
  })
29
132
  .strict();
30
133
  export const TrustScoreOutputSchema = z
@@ -83,16 +186,7 @@ export const TrustScoreOutputSchema = z
83
186
  .describe("Risk dimension name."),
84
187
  score: z.number().describe("Dimension score achieved."),
85
188
  max_score: z.number().describe("Dimension max possible score."),
86
- checks: z.array(z.object({
87
- id: z.string().describe("Check identifier."),
88
- dimension: z
89
- .enum(["workflow", "fund", "trust", "behavior"])
90
- .describe("Dimension this check belongs to."),
91
- description: z.string().describe("Check description."),
92
- weight: z.number().describe("Check weight within its dimension (percentage)."),
93
- passed: z.boolean().describe("Whether the check passed."),
94
- advice: z.string().optional().describe("Advice when the check failed."),
95
- })).describe("Individual risk checks within this dimension."),
189
+ checks: z.array(RiskCheckOutputSchema).describe("Individual risk checks within this dimension."),
96
190
  }))
97
191
  .describe("4-dimension breakdown: workflow / fund / trust / behavior."),
98
192
  })
@@ -106,8 +200,115 @@ export const TrustScoreOutputSchema = z
106
200
  })
107
201
  .optional()
108
202
  .describe("InfoPuzzle summary — present only when depth >= 'evaluate'."),
203
+ preorder_advice: z
204
+ .object({
205
+ confidence: z
206
+ .object({
207
+ score: z.number().min(0).max(100).describe("Composite order confidence (0-100, higher = safer to order)."),
208
+ base: z.number().describe("Base confidence = 100 - risk.total."),
209
+ user_adjustment: z.number().describe("User-controllable adjustment from user_metrics (±cap)."),
210
+ preference_nudge: z.number().describe("Preference-match nudge (±5, only when preferences were provided)."),
211
+ explanation: z.string().describe("Transparent breakdown of the confidence components."),
212
+ })
213
+ .describe("ConfidenceScore — user-controllable composite order confidence."),
214
+ industry: IndustryEnumSchema.optional().describe("Industry used for the industry-specific risk checks (explicit input or inferred)."),
215
+ strategies: z
216
+ .array(z.object({
217
+ scenario: z
218
+ .enum([
219
+ "info_asymmetry", "fund_safety", "refund_dispute", "arbitration_fairness",
220
+ "pricing", "delivery_sla", "quality_verification", "after_sales",
221
+ ])
222
+ .describe("Game scenario detected from the puzzle."),
223
+ merchant_tactic: z.string().describe("Merchant's potential tactic in this scenario."),
224
+ user_strategy: z.string().describe("Recommended user-side strategy (protection/mitigation)."),
225
+ nash_equilibrium: z.string().describe("Win-win equilibrium the strategy pushes toward."),
226
+ confidence: z.number().min(0).max(1).describe("Strategy confidence (0-1)."),
227
+ fallback: z.string().optional().describe("Alternative when the user rejects the main strategy."),
228
+ rationale: z.string().describe("Trigger-condition explanation from puzzle evidence."),
229
+ }))
230
+ .describe("Top merchant-vs-user game strategies (user side, max 3)."),
231
+ preference_match: z
232
+ .object({
233
+ score: z.number().min(0).max(100).describe("Preference match score (0-100)."),
234
+ matches: z.array(z.string()).describe("Aspects matching the user's preferences."),
235
+ mismatches: z.array(z.string()).describe("Aspects mismatching the user's preferences."),
236
+ warnings: z.array(z.string()).describe("Match warnings (e.g. budget stretch)."),
237
+ })
238
+ .optional()
239
+ .describe("PreferenceMatchResult — present when preferences (input or profile) were available."),
240
+ preference_issues: z
241
+ .array(z.string())
242
+ .optional()
243
+ .describe("Validation issues found in the merged preferences (e.g. budget min > max)."),
244
+ industry_risks: z
245
+ .object({
246
+ score_adjustment: z.number().describe("Industry risk adjustment applied to the base risk score (-10 to +10)."),
247
+ summary: z.string().describe("Industry risk assessment summary."),
248
+ checks: z.array(RiskCheckOutputSchema).describe("Industry-specific risk checks."),
249
+ unmet_needs: z
250
+ .array(z.object({
251
+ id: z.string().describe("Need identifier."),
252
+ tier: z.enum(["common", "personalized", "advanced"]).describe("Need tier."),
253
+ description: z.string().describe("Need description."),
254
+ advice: z.string().optional().describe("Advice for fulfilling the need."),
255
+ }))
256
+ .describe("Industry needs not satisfied by this Service."),
257
+ })
258
+ .optional()
259
+ .describe("IndustryRiskResult — industry pain-point checks (needs met / risks triggered)."),
260
+ reminders: z
261
+ .array(ReminderOutputSchema)
262
+ .describe("Transaction-safety reminders at the preorder stage (sorted, capped)."),
263
+ blocking_reminders: z
264
+ .array(ReminderOutputSchema)
265
+ .describe("Blocking (priority=required) reminders — resolve these before ordering."),
266
+ summary: z.string().describe("AI-ready paragraph summarizing the whole preorder report."),
267
+ })
268
+ .optional()
269
+ .describe("PreorderAdvice (GLM6/94 §3) — present only when depth = 'preorder'. " +
270
+ "AI presents evidence and options; the USER decides whether to order."),
271
+ comparison: z
272
+ .object({
273
+ rows: z
274
+ .array(z
275
+ .object({
276
+ service_id: z.string(),
277
+ service_name: z.string(),
278
+ error: z.string().optional().describe("Per-service evaluation failure (row excluded from best-per-metric)."),
279
+ industry: IndustryEnumSchema.optional(),
280
+ confidence: z.number().optional().describe("Order confidence 0-100 (higher = safer)."),
281
+ risk_total: z.number().optional().describe("Risk score 0-100 (lower = safer)."),
282
+ risk_level: z.string().optional(),
283
+ trust_score: z.number().optional().describe("Trust score 0-100 (higher = more trustworthy)."),
284
+ trust_level: z.string().optional(),
285
+ preference_match: z.number().optional().describe("Preference match 0-100 (higher = better fit)."),
286
+ reputation_like_ratio: z.number().optional().describe("likes/(likes+dislikes); 1 when no votes."),
287
+ reputation_votes: z.number().optional(),
288
+ red_flags_count: z.number().optional(),
289
+ blocking_reminders_count: z.number().optional(),
290
+ info_gaps_count: z.number().optional(),
291
+ })
292
+ .strict())
293
+ .describe("One row per evaluated service (primary first, then compare_with candidates)."),
294
+ best_per_metric: z
295
+ .record(z.string(), z.array(z.string()))
296
+ .describe("metric name → service_ids with the best value (ties all listed). Per-metric ONLY."),
297
+ evaluated_metrics: z
298
+ .array(z.string())
299
+ .describe("Metrics actually compared (skipped when fewer than 2 rows have data)."),
300
+ note: z
301
+ .string()
302
+ .describe("Neutrality note: no overall ranking; metric weights belong to the buyer."),
303
+ })
304
+ .strict()
305
+ .optional()
306
+ .describe("Deterministic multi-service comparison (GLM6/94 L6) — present only when depth='preorder' " +
307
+ "and compare_with is provided. Per-metric bests ONLY, no overall ranking — the buyer decides."),
109
308
  })
110
309
  .describe("Trust score result. Contains: trust_score (ServiceTrustScore), " +
111
310
  "risk_score (RiskScore, when depth >= evaluate), info_puzzle summary, " +
311
+ "preorder_advice (PreorderAdvice, when depth = preorder), " +
312
+ "comparison (PreorderComparison, when depth = preorder and compare_with given), " +
112
313
  "and service_basics snapshot."),
113
314
  });
@@ -47,6 +47,7 @@ const SKILLS_BY_PROJECT_ACTION = {
47
47
  apply_object_edit: ["wowok-safety"],
48
48
  patch_machine_nodes: ["wowok-machine"],
49
49
  patch_guard_tree: ["wowok-guard"],
50
+ participation_radar: ["wowok-order", "wowok-messenger"],
50
51
  };
51
52
  export function getSkillsHintForOnchain(operationType, data) {
52
53
  const skills = SKILLS_BY_OPERATION_TYPE[operationType];
@@ -1,3 +1,4 @@
1
+ import { type TemplateObjectType } from "../knowledge/template-registry.js";
1
2
  export declare const EXAMPLES_DIR: string;
2
3
  export interface SchemaInfo {
3
4
  name: string;
@@ -7,11 +8,13 @@ export interface SchemaInfo {
7
8
  outputPath?: string;
8
9
  }
9
10
  export interface SchemaQueryRequest {
10
- action: "list" | "get" | "search" | "list_operations" | "get_output" | "get_guard_templates" | "get_field" | "search_examples";
11
+ action: "list" | "get" | "search" | "list_operations" | "get_output" | "get_guard_templates" | "get_field" | "search_examples" | "get_tool_reference" | "get_guard_design_patterns" | "get_safety_rules" | "get_templates";
11
12
  name?: string;
12
13
  query?: string;
13
14
  field_path?: string;
14
15
  template?: string;
16
+ object_type?: TemplateObjectType;
17
+ params?: string;
15
18
  output_file?: string;
16
19
  }
17
20
  export interface ExampleSearchResult {
@@ -1,6 +1,10 @@
1
1
  import { readFileSync, existsSync, writeFileSync, mkdirSync, readdirSync } from "fs";
2
2
  import { resolve, join, dirname } from "path";
3
3
  import { fileURLToPath } from "url";
4
+ import { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence, } from "../knowledge/tools-reference.js";
5
+ import { GUARD_DESIGN_PATTERNS, getGuardDesignPattern, GUARD_DESIGN_PATTERNS_VERSION, } from "../knowledge/guard-design-patterns.js";
6
+ import { OBJECT_REUSE_RULES, CREATE_VS_MODIFY_PATTERN, IMMUTABILITY_RULES, OPERATION_TYPE_CLASSIFICATION, OPERATION_CLASS_META, NAMING_CONVENTIONS, SAFETY_RULES_VERSION, } from "../knowledge/safety-rules.js";
7
+ import { listTemplates as listRegistryTemplates, getTemplateDetail, instantiateTemplate, getTemplateCounts, TEMPLATE_OBJECT_TYPES, } from "../knowledge/template-registry.js";
4
8
  const __filename = fileURLToPath(import.meta.url);
5
9
  const __dirname = fileURLToPath(new URL(".", import.meta.url));
6
10
  const SCHEMAS_DIR = resolve(__dirname, "../../dist/schemas");
@@ -302,7 +306,7 @@ function writeResponseToFile(data, preferredPath) {
302
306
  }
303
307
  }
304
308
  export function processSchemaQuery(request) {
305
- const { action, name, query, field_path, template, output_file } = request;
309
+ const { action, name, query, field_path, template, output_file, object_type, params } = request;
306
310
  if (action === "get_guard_templates") {
307
311
  const templates = getGuardTemplates(template);
308
312
  if (!templates) {
@@ -341,6 +345,134 @@ export function processSchemaQuery(request) {
341
345
  : `Retrieved ${Array.isArray(templates.templates) ? templates.templates.length : 0} Guard templates`,
342
346
  };
343
347
  }
348
+ if (action === "get_templates") {
349
+ if (!template) {
350
+ const metas = listRegistryTemplates(object_type);
351
+ const counts = getTemplateCounts();
352
+ const data = {
353
+ total: metas.length,
354
+ filter: object_type ?? null,
355
+ counts_by_object_type: counts,
356
+ templates: metas,
357
+ };
358
+ if (output_file) {
359
+ const filePath = writeResponseToFile(data, output_file);
360
+ if (filePath) {
361
+ return {
362
+ success: true,
363
+ action,
364
+ data: null,
365
+ message: `${metas.length} templates written to file: ${filePath}`,
366
+ output_file_path: filePath,
367
+ suggestions: [`Use Read tool to open ${filePath}`],
368
+ };
369
+ }
370
+ }
371
+ return {
372
+ success: true,
373
+ action,
374
+ data,
375
+ message: `${metas.length} template(s)${object_type ? ` for object_type='${object_type}'` : ""} ` +
376
+ `(total registry: ${Object.values(counts).reduce((a, b) => a + b, 0)} across ${TEMPLATE_OBJECT_TYPES.length} object types). ` +
377
+ `Provide 'template' (id) for full detail; add 'params' (JSON string) to instantiate.`,
378
+ };
379
+ }
380
+ if (!params) {
381
+ const detail = getTemplateDetail(template);
382
+ if (!detail) {
383
+ return {
384
+ success: false,
385
+ action,
386
+ data: null,
387
+ message: `Template '${template}' not found in the unified registry.`,
388
+ suggestions: [
389
+ "Omit 'template' to list all template metadata (id + object_type + parameters).",
390
+ `Filter by object_type: ${TEMPLATE_OBJECT_TYPES.join(", ")}`,
391
+ ],
392
+ };
393
+ }
394
+ if (output_file) {
395
+ const filePath = writeResponseToFile(detail, output_file);
396
+ if (filePath) {
397
+ return {
398
+ success: true,
399
+ action,
400
+ data: null,
401
+ message: `Template '${template}' detail written to file: ${filePath}`,
402
+ output_file_path: filePath,
403
+ suggestions: [`Use Read tool to open ${filePath}`],
404
+ };
405
+ }
406
+ }
407
+ return {
408
+ success: true,
409
+ action,
410
+ data: detail,
411
+ message: `Template '${template}' (${detail.object_type}, ${detail.instantiable ? "instantiable" : "guidance-only"}). ` +
412
+ `To instantiate, call again with 'params' = JSON object of the declared parameters.`,
413
+ };
414
+ }
415
+ let parsedParams;
416
+ try {
417
+ const parsed = JSON.parse(params);
418
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
419
+ return {
420
+ success: false,
421
+ action,
422
+ data: null,
423
+ message: `'params' must be a JSON object (e.g. '{"key":"value"}'), got ${Array.isArray(parsed) ? "array" : typeof parsed}.`,
424
+ };
425
+ }
426
+ parsedParams = parsed;
427
+ }
428
+ catch (e) {
429
+ return {
430
+ success: false,
431
+ action,
432
+ data: null,
433
+ message: `Failed to parse 'params' as JSON: ${e instanceof Error ? e.message : String(e)}`,
434
+ suggestions: ["Example: params='{\"whitelist\":[\"0xabc...\"]}'"],
435
+ };
436
+ }
437
+ const result = instantiateTemplate(template, parsedParams);
438
+ if (!result.ok) {
439
+ return {
440
+ success: false,
441
+ action,
442
+ data: result.guidance !== undefined ? { guidance: result.guidance } : null,
443
+ message: `Instantiation failed for '${template}': ${result.error}`,
444
+ suggestions: result.missing_params
445
+ ? [`Missing required params: ${result.missing_params.join(", ")}`, "Call with 'template' only (no 'params') to see full parameter declarations."]
446
+ : ["Call with 'template' only (no 'params') to see full parameter declarations."],
447
+ };
448
+ }
449
+ const data = {
450
+ object_type: result.object_type,
451
+ template_id: result.template_id,
452
+ body: result.body,
453
+ ...(result.notes ? { notes: result.notes } : {}),
454
+ };
455
+ if (output_file) {
456
+ const filePath = writeResponseToFile(data, output_file);
457
+ if (filePath) {
458
+ return {
459
+ success: true,
460
+ action,
461
+ data: null,
462
+ message: `Instantiated template '${template}' written to file: ${filePath}`,
463
+ output_file_path: filePath,
464
+ suggestions: [`Use Read tool to open ${filePath}`],
465
+ };
466
+ }
467
+ }
468
+ return {
469
+ success: true,
470
+ action,
471
+ data,
472
+ message: `Instantiated '${template}' (${result.object_type}). ` +
473
+ `Review the body against the onchain_operations schema before submitting.`,
474
+ };
475
+ }
344
476
  if (action === "search_examples") {
345
477
  if (!query) {
346
478
  return {
@@ -369,6 +501,128 @@ export function processSchemaQuery(request) {
369
501
  : undefined,
370
502
  };
371
503
  }
504
+ if (action === "get_tool_reference") {
505
+ if (name) {
506
+ const entry = getToolReference(name);
507
+ if (!entry) {
508
+ return {
509
+ success: false,
510
+ action,
511
+ data: null,
512
+ message: `Tool '${name}' not found in the tool reference.`,
513
+ suggestions: [
514
+ "Omit 'name' to list all tools.",
515
+ `Available tools: ${TOOLS_REFERENCE.map((t) => t.name).join(", ")}`,
516
+ ],
517
+ };
518
+ }
519
+ const sequence = getToolSequence(name);
520
+ return {
521
+ success: true,
522
+ action,
523
+ data: { tool: entry, call_sequence: sequence ?? null },
524
+ message: `Retrieved tool reference: ${name}`,
525
+ };
526
+ }
527
+ if (query) {
528
+ const matches = searchToolReference(query);
529
+ return {
530
+ success: true,
531
+ action,
532
+ data: { tools: matches, count: matches.length },
533
+ message: `Found ${matches.length} tool(s) matching '${query}'`,
534
+ suggestions: matches.length === 0
535
+ ? ["Try a broader keyword (e.g. 'onchain', 'guard', 'schema'), or omit 'query' to list all tools."]
536
+ : undefined,
537
+ };
538
+ }
539
+ const catalog = TOOLS_REFERENCE.map((t) => ({
540
+ name: t.name,
541
+ summary: t.summary,
542
+ actions: t.actions ?? [],
543
+ notes: t.notes ?? [],
544
+ }));
545
+ return {
546
+ success: true,
547
+ action,
548
+ data: { tools: catalog, count: catalog.length },
549
+ message: `Retrieved reference for ${catalog.length} MCP tools. Pass name='<tool>' for full detail (params, prerequisites, follow-ups).`,
550
+ };
551
+ }
552
+ if (action === "get_guard_design_patterns") {
553
+ if (name) {
554
+ const pattern = getGuardDesignPattern(name);
555
+ if (!pattern) {
556
+ return {
557
+ success: false,
558
+ action,
559
+ data: null,
560
+ message: `Guard design pattern '${name}' not found.`,
561
+ suggestions: [
562
+ "Omit 'name' to list the full catalog.",
563
+ `Available pattern ids: ${GUARD_DESIGN_PATTERNS.map((p) => p.id).join(", ")}`,
564
+ ],
565
+ };
566
+ }
567
+ return {
568
+ success: true,
569
+ action,
570
+ data: { pattern },
571
+ message: `Retrieved Guard design pattern: ${name}`,
572
+ };
573
+ }
574
+ if (query) {
575
+ const byHost = GUARD_DESIGN_PATTERNS.filter((p) => p.host === query);
576
+ const matches = byHost.length > 0
577
+ ? byHost
578
+ : GUARD_DESIGN_PATTERNS.filter((p) => p.business_requirement.toLowerCase().includes(query.toLowerCase()) ||
579
+ p.logic_summary.toLowerCase().includes(query.toLowerCase()));
580
+ return {
581
+ success: true,
582
+ action,
583
+ data: { patterns: matches, count: matches.length, filtered_by: byHost.length > 0 ? "host" : "keyword" },
584
+ message: `Found ${matches.length} Guard design pattern(s) matching '${query}'`,
585
+ suggestions: matches.length === 0
586
+ ? ["Filter by host: service_buy_guard, service_allocator_guard, machine_forward, progress_submission, reward_claim, repository_write, arbitration_usage, arbitration_voting, gen_passport"]
587
+ : undefined,
588
+ };
589
+ }
590
+ const catalog = GUARD_DESIGN_PATTERNS.map((p) => ({
591
+ id: p.id,
592
+ business_requirement: p.business_requirement,
593
+ host: p.host,
594
+ data_source: p.data_source,
595
+ verifier_level: p.verifier_level,
596
+ logic_summary: p.logic_summary,
597
+ key_queries: p.key_queries,
598
+ notes: p.notes ?? [],
599
+ }));
600
+ return {
601
+ success: true,
602
+ action,
603
+ data: { patterns: catalog, count: catalog.length, version: GUARD_DESIGN_PATTERNS_VERSION },
604
+ message: `Retrieved ${catalog.length} Guard design patterns. Pass name='<pattern_id>' for full detail (witness types, mitigated risks, industries).`,
605
+ };
606
+ }
607
+ if (action === "get_safety_rules") {
608
+ return {
609
+ success: true,
610
+ action,
611
+ data: {
612
+ version: SAFETY_RULES_VERSION,
613
+ object_reuse_rules: OBJECT_REUSE_RULES,
614
+ create_vs_modify_pattern: CREATE_VS_MODIFY_PATTERN,
615
+ immutability_rules: IMMUTABILITY_RULES,
616
+ operation_type_classification: OPERATION_TYPE_CLASSIFICATION,
617
+ operation_class_meta: OPERATION_CLASS_META,
618
+ naming_conventions: NAMING_CONVENTIONS,
619
+ },
620
+ message: "Retrieved safety rule tables (reuse / immutability / operation classification / naming). " +
621
+ "Key points: prefer REUSING existing objects (string reference = reuse, object shape = create); " +
622
+ "Machine publish locks nodes/pairs/forwards, Service publish locks machine/order_allocators/arbitrations (sales stays mutable); " +
623
+ "Guard is CREATE-only immutable; on-chain writes require explicit user confirmation.",
624
+ };
625
+ }
372
626
  if (!areSchemasAvailable()) {
373
627
  return {
374
628
  success: false,
@@ -108,6 +108,7 @@
108
108
  },
109
109
  "schema_strict_mode": {
110
110
  "type": "boolean",
111
+ "default": false,
111
112
  "description": "When true, schema incompatibility returns an error instead of a warning. Default: false (warn mode)."
112
113
  },
113
114
  "dry_run": {
@@ -289,7 +290,7 @@
289
290
  "mainnet"
290
291
  ],
291
292
  "default": "mainnet",
292
- "description": "Target chain (defaults to Ethereum mainnet)"
293
+ "description": "Target chain (defaults to Ethereum mainnet when omitted — EvmChainSchema carries .default(\"mainnet\"))"
293
294
  }
294
295
  },
295
296
  "required": [
@@ -319,6 +320,7 @@
319
320
  "properties": {
320
321
  "network": {
321
322
  "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
323
+ "default": "mainnet",
322
324
  "description": "Specific chain; if omitted, queries all supported chains"
323
325
  },
324
326
  "tokens": {
@@ -364,7 +366,7 @@
364
366
  "type": "object",
365
367
  "properties": {
366
368
  "network": {
367
- "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
369
+ "$ref": "#/definitions/bridge_operation/anyOf/5/properties/data/properties/network",
368
370
  "description": "Specific chain; if omitted, returns token lists for all supported chains"
369
371
  }
370
372
  },
@@ -485,7 +487,8 @@
485
487
  },
486
488
  "network": {
487
489
  "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
488
- "description": "Target chain (defaults to Ethereum mainnet)"
490
+ "default": "mainnet",
491
+ "description": "Target chain (defaults to Ethereum mainnet when omitted — EvmChainSchema carries .default(\"mainnet\"))"
489
492
  }
490
493
  },
491
494
  "required": [
@@ -504,7 +507,8 @@
504
507
  },
505
508
  "network": {
506
509
  "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
507
- "description": "Target chain (defaults to Ethereum mainnet)"
510
+ "default": "mainnet",
511
+ "description": "Target chain (defaults to Ethereum mainnet when omitted — EvmChainSchema carries .default(\"mainnet\"))"
508
512
  },
509
513
  "rpcUrls": {
510
514
  "type": "array",
@@ -533,7 +537,8 @@
533
537
  },
534
538
  "network": {
535
539
  "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
536
- "description": "Target chain (defaults to Ethereum mainnet)"
540
+ "default": "mainnet",
541
+ "description": "Target chain (defaults to Ethereum mainnet when omitted — EvmChainSchema carries .default(\"mainnet\"))"
537
542
  },
538
543
  "rpcUrls": {
539
544
  "type": "array",
@@ -562,7 +567,8 @@
562
567
  },
563
568
  "network": {
564
569
  "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
565
- "description": "Target chain (defaults to Ethereum mainnet)"
570
+ "default": "mainnet",
571
+ "description": "Target chain (defaults to Ethereum mainnet when omitted — EvmChainSchema carries .default(\"mainnet\"))"
566
572
  },
567
573
  "rpcUrls": {
568
574
  "type": "array",
@@ -591,7 +597,8 @@
591
597
  },
592
598
  "network": {
593
599
  "$ref": "#/definitions/bridge_operation/anyOf/4/properties/data/properties/network",
594
- "description": "Target chain (defaults to Ethereum mainnet)"
600
+ "default": "mainnet",
601
+ "description": "Target chain (defaults to Ethereum mainnet when omitted — EvmChainSchema carries .default(\"mainnet\"))"
595
602
  },
596
603
  "rpcUrls": {
597
604
  "type": "array",
@@ -22,6 +22,7 @@
22
22
  "json",
23
23
  "markdown"
24
24
  ],
25
+ "default": "json",
25
26
  "description": "Output format: 'json' (default) or 'markdown'"
26
27
  },
27
28
  "env": {
@@ -77,6 +78,7 @@
77
78
  },
78
79
  "schema_strict_mode": {
79
80
  "type": "boolean",
81
+ "default": false,
80
82
  "description": "When true, schema incompatibility returns an error instead of a warning. Default: false (warn mode)."
81
83
  },
82
84
  "dry_run": {