@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
@@ -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
  });
@@ -249,6 +249,19 @@ export function parseMachineNodesFromText(text) {
249
249
  if (errors.length > 0) {
250
250
  return { success: false, errors };
251
251
  }
252
+ const hasEntryForward = nodes.some(node => node.pairs.some(pair => pair.prev_node === ""));
253
+ if (!hasEntryForward) {
254
+ return {
255
+ success: false,
256
+ errors: [{
257
+ message: 'Machine has no entry forward. At least one node must have a pair with prev_node="" (empty string), ' +
258
+ 'which defines how Progress advances from the initial state (current="") to the first node. ' +
259
+ 'Without an entry forward, the workflow will be permanently stuck. ' +
260
+ 'Example: {name: "Subscribed", pairs: [{prev_node: "", forwards: [{name: "Subscribe", weight: 1}]}]}',
261
+ path: '/',
262
+ }]
263
+ };
264
+ }
252
265
  return { success: true, data: nodes, errors: [] };
253
266
  }
254
267
  export function formatNodeErrors(errors) {
@@ -0,0 +1,12 @@
1
+ export declare function shortTypeName(objectType: string | null | undefined): string;
2
+ export declare function normalizeObjectType(objectType: string | null | undefined): string;
3
+ export declare function isObjectOfType(objectType: string | null | undefined, expectedShortName: string): boolean;
4
+ export declare function groupObjectsByType<T extends {
5
+ objectType: string | null;
6
+ }>(objects: T[]): Map<string, T[]>;
7
+ export declare function findObjectByType<T extends {
8
+ objectType: string | null;
9
+ }>(objects: T[], expectedShortName: string): T | undefined;
10
+ export declare function countObjectsByType<T extends {
11
+ objectType: string | null;
12
+ }>(objects: T[], expectedShortName: string): number;
@@ -0,0 +1,35 @@
1
+ export function shortTypeName(objectType) {
2
+ if (!objectType)
3
+ return "unknown";
4
+ const base = objectType.replace(/<.*>/, "").trim();
5
+ const segments = base.split("::");
6
+ const shortName = segments[segments.length - 1] || "unknown";
7
+ if (shortName.length > 0 && shortName === shortName.toLowerCase()) {
8
+ return shortName.charAt(0).toUpperCase() + shortName.slice(1);
9
+ }
10
+ return shortName;
11
+ }
12
+ export function normalizeObjectType(objectType) {
13
+ return shortTypeName(objectType).toLowerCase();
14
+ }
15
+ export function isObjectOfType(objectType, expectedShortName) {
16
+ const normalized = normalizeObjectType(objectType);
17
+ const expected = expectedShortName.toLowerCase();
18
+ return normalized === expected;
19
+ }
20
+ export function groupObjectsByType(objects) {
21
+ const byType = new Map();
22
+ for (const obj of objects) {
23
+ const t = shortTypeName(obj.objectType);
24
+ if (!byType.has(t))
25
+ byType.set(t, []);
26
+ byType.get(t).push(obj);
27
+ }
28
+ return byType;
29
+ }
30
+ export function findObjectByType(objects, expectedShortName) {
31
+ return objects.find(o => isObjectOfType(o.objectType, expectedShortName));
32
+ }
33
+ export function countObjectsByType(objects, expectedShortName) {
34
+ return objects.filter(o => isObjectOfType(o.objectType, expectedShortName)).length;
35
+ }
@@ -0,0 +1,49 @@
1
+ export interface ForwardPermissionRef {
2
+ nodeName: string;
3
+ prevNode: string;
4
+ forwardName: string;
5
+ permissionIndex: number | null;
6
+ namedOperator: string | null;
7
+ }
8
+ export interface PermissionRefCollection {
9
+ indexRefs: ForwardPermissionRef[];
10
+ namedRefs: ForwardPermissionRef[];
11
+ missingRefs: ForwardPermissionRef[];
12
+ requiredIndexes: number[];
13
+ }
14
+ export interface IndexAuthorizationStatus {
15
+ index: number;
16
+ authorized: boolean;
17
+ entityCount: number;
18
+ }
19
+ export interface PermissionAuthorizationReport {
20
+ statuses: IndexAuthorizationStatus[];
21
+ missingIndexes: number[];
22
+ authorizedIndexes: number[];
23
+ allAuthorized: boolean;
24
+ summary: string;
25
+ }
26
+ export declare function collectPermissionIndexes(nodes: Array<{
27
+ name: string;
28
+ pairs?: Array<{
29
+ prev_node: string;
30
+ forwards?: Array<{
31
+ name: string;
32
+ permissionIndex?: number | null;
33
+ namedOperator?: string | null;
34
+ }>;
35
+ }>;
36
+ }>): PermissionRefCollection;
37
+ export interface PermissionObjectData {
38
+ address?: string;
39
+ entity_count?: number;
40
+ perm_remark?: Array<{
41
+ index: number;
42
+ remark: string;
43
+ }>;
44
+ entityPermissions?: Map<string, number[]>;
45
+ owner?: string;
46
+ admin?: string[];
47
+ }
48
+ export declare function checkPermissionAuthorization(requiredIndexes: number[], permission: PermissionObjectData | null | undefined): PermissionAuthorizationReport;
49
+ export declare function formatPermissionWarning(report: PermissionAuthorizationReport): string;
@@ -0,0 +1,121 @@
1
+ export function collectPermissionIndexes(nodes) {
2
+ const indexRefs = [];
3
+ const namedRefs = [];
4
+ const missingRefs = [];
5
+ const requiredIndexSet = new Set();
6
+ for (const node of nodes) {
7
+ if (!node.pairs)
8
+ continue;
9
+ for (const pair of node.pairs) {
10
+ if (!pair.forwards)
11
+ continue;
12
+ for (const forward of pair.forwards) {
13
+ const ref = {
14
+ nodeName: node.name,
15
+ prevNode: pair.prev_node,
16
+ forwardName: forward.name,
17
+ permissionIndex: forward.permissionIndex ?? null,
18
+ namedOperator: forward.namedOperator ?? null,
19
+ };
20
+ if (ref.permissionIndex != null) {
21
+ indexRefs.push(ref);
22
+ requiredIndexSet.add(ref.permissionIndex);
23
+ }
24
+ else if (ref.namedOperator != null && ref.namedOperator !== "") {
25
+ namedRefs.push(ref);
26
+ }
27
+ else {
28
+ missingRefs.push(ref);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ return {
34
+ indexRefs,
35
+ namedRefs,
36
+ missingRefs,
37
+ requiredIndexes: Array.from(requiredIndexSet).sort((a, b) => a - b),
38
+ };
39
+ }
40
+ export function checkPermissionAuthorization(requiredIndexes, permission) {
41
+ const BUILTIN_THRESHOLD = 1000;
42
+ const statuses = [];
43
+ const missingIndexes = [];
44
+ const authorizedIndexes = [];
45
+ for (const index of requiredIndexes) {
46
+ if (index < BUILTIN_THRESHOLD) {
47
+ statuses.push({ index, authorized: true, entityCount: -1 });
48
+ authorizedIndexes.push(index);
49
+ continue;
50
+ }
51
+ let authorized = false;
52
+ let entityCount = 0;
53
+ if (permission?.entityPermissions) {
54
+ for (const perms of permission.entityPermissions.values()) {
55
+ if (perms.includes(index)) {
56
+ entityCount++;
57
+ }
58
+ }
59
+ authorized = entityCount > 0;
60
+ }
61
+ else if (permission?.perm_remark && permission.perm_remark.length > 0) {
62
+ authorized = permission.perm_remark.some(r => r.index === index);
63
+ entityCount = authorized ? -1 : 0;
64
+ }
65
+ else {
66
+ authorized = true;
67
+ entityCount = -1;
68
+ }
69
+ statuses.push({ index, authorized, entityCount });
70
+ if (authorized) {
71
+ authorizedIndexes.push(index);
72
+ }
73
+ else {
74
+ missingIndexes.push(index);
75
+ }
76
+ }
77
+ const allAuthorized = missingIndexes.length === 0;
78
+ const summary = allAuthorized
79
+ ? `All ${requiredIndexes.length} required permission index(es) are authorized.`
80
+ : `${missingIndexes.length}/${requiredIndexes.length} required permission index(es) are NOT authorized: [${missingIndexes.join(", ")}]. ` +
81
+ `Forwards using these indexes will be un-executable — Progress will be stuck. ` +
82
+ `Grant entities for these indexes via permission.op="add perm by index" before publishing the Machine.`;
83
+ return {
84
+ statuses,
85
+ missingIndexes,
86
+ authorizedIndexes,
87
+ allAuthorized,
88
+ summary,
89
+ };
90
+ }
91
+ export function formatPermissionWarning(report) {
92
+ if (report.allAuthorized) {
93
+ return "";
94
+ }
95
+ const lines = [
96
+ "CRITICAL PRE-PUBLISH: Machine forwards reference permission indexes that are NOT authorized in the Permission object.",
97
+ "",
98
+ `Missing indexes (no entities granted): ${report.missingIndexes.join(", ")}`,
99
+ "",
100
+ "Impact: Forwards using these indexes can NEVER be executed — Progress will be permanently stuck at the source node.",
101
+ "Buyer funds may be trapped if the workflow cannot advance past the stuck node.",
102
+ "",
103
+ "To fix BEFORE publishing:",
104
+ ' 1. Call onchain_operations with op="permission"',
105
+ ' 2. Set object=<your_permission_name_or_address>',
106
+ ' 3. Set permission.op="add perm by index"',
107
+ " 4. Set index=<missing_index> for each missing index",
108
+ ' 5. Set entity=["<entity_address>"] — the address that should be authorized',
109
+ " 6. After granting all missing indexes, re-attempt the Machine publish.",
110
+ "",
111
+ "Required permission indexes for this Machine:",
112
+ ];
113
+ for (const status of report.statuses) {
114
+ const state = status.authorized ? "AUTHORIZED" : "MISSING";
115
+ const count = status.entityCount === -1
116
+ ? "(built-in or heuristic)"
117
+ : `(${status.entityCount} entity/entities)`;
118
+ lines.push(` - Index ${status.index}: ${state} ${count}`);
119
+ }
120
+ return lines.join("\n");
121
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getSkillsHintForOnchain(operationType: string, data?: unknown): string | undefined;
2
+ export declare function getSkillsHintForProject(action: string): string | undefined;
@@ -0,0 +1,77 @@
1
+ const SKILLS_BY_OPERATION_TYPE = {
2
+ service: ["wowok-provider", "wowok-safety"],
3
+ machine: ["wowok-machine"],
4
+ guard: ["wowok-guard"],
5
+ arbitration: ["wowok-arbitrator"],
6
+ allocation: ["wowok-provider"],
7
+ permission: ["wowok-safety"],
8
+ treasury: ["wowok-provider", "wowok-safety"],
9
+ reward: ["wowok-provider"],
10
+ repository: ["wowok-provider"],
11
+ demand: ["wowok-provider"],
12
+ contact: ["wowok-messenger"],
13
+ order: ["wowok-order"],
14
+ progress: [],
15
+ personal: [],
16
+ payment: [],
17
+ proof: [],
18
+ };
19
+ const SKILLS_BY_PROJECT_ACTION = {
20
+ create_project: ["wowok-onboard", "wowok-planner"],
21
+ create_project_from_onchain: ["wowok-onboard"],
22
+ evaluate_project: ["wowok-auditor"],
23
+ pre_evaluate_check: ["wowok-auditor"],
24
+ verify_deployment: ["wowok-auditor"],
25
+ generate_deployment_doc: ["wowok-planner"],
26
+ migrate_to_mainnet: ["wowok-onboard", "wowok-safety"],
27
+ migrate_network: ["wowok-onboard"],
28
+ clone_project_to_network: ["wowok-onboard"],
29
+ build_graph: ["wowok-planner"],
30
+ list_projects: [],
31
+ get_project_detail: [],
32
+ update_project: [],
33
+ add_object: [],
34
+ remove_object: [],
35
+ update_object: [],
36
+ create_version: [],
37
+ get_graph: [],
38
+ save_evaluation: [],
39
+ compare_projects: [],
40
+ refresh_objects: [],
41
+ get_object_diff: [],
42
+ delete_project: [],
43
+ assemble_context: [],
44
+ get_machine_graph: ["wowok-machine"],
45
+ get_guard_graph: ["wowok-guard"],
46
+ plan_object_edit: ["wowok-machine", "wowok-guard", "wowok-auditor"],
47
+ apply_object_edit: ["wowok-safety"],
48
+ patch_machine_nodes: ["wowok-machine"],
49
+ patch_guard_tree: ["wowok-guard"],
50
+ participation_radar: ["wowok-order", "wowok-messenger"],
51
+ };
52
+ export function getSkillsHintForOnchain(operationType, data) {
53
+ const skills = SKILLS_BY_OPERATION_TYPE[operationType];
54
+ if (!skills || skills.length === 0)
55
+ return undefined;
56
+ const isPublish = data?.publish === true;
57
+ const hasOrderAllocators = !!data?.order_allocators;
58
+ const isComplex = isPublish || hasOrderAllocators;
59
+ const prefix = isComplex
60
+ ? "SKILLS RECOMMENDED (complex operation — skills provide business-semantic guidance):"
61
+ : "SKILLS RECOMMENDED (optional — skills provide deeper guidance):";
62
+ return `${prefix} ${skills.join(", ")}. ` +
63
+ `skills focus on business intent → object parameter translation; ` +
64
+ `MCP handles object structure and on-chain execution. ` +
65
+ `If skills are installed, consult them BEFORE this call for design rationale. ` +
66
+ `If not installed, MCP executes independently — this hint is informational only.`;
67
+ }
68
+ export function getSkillsHintForProject(action) {
69
+ const skills = SKILLS_BY_PROJECT_ACTION[action];
70
+ if (!skills || skills.length === 0)
71
+ return undefined;
72
+ return `SKILLS RECOMMENDED (optional — skills provide deeper guidance): ${skills.join(", ")}. ` +
73
+ `skills focus on business intent → object parameter translation; ` +
74
+ `MCP handles project structure and evaluation. ` +
75
+ `If skills are installed, consult them for design/planning rationale. ` +
76
+ `If not installed, MCP executes independently — this hint is informational only.`;
77
+ }
@@ -1,3 +1,5 @@
1
+ import { type TemplateObjectType } from "../knowledge/template-registry.js";
2
+ export declare const EXAMPLES_DIR: string;
1
3
  export interface SchemaInfo {
2
4
  name: string;
3
5
  title: string;
@@ -6,13 +8,26 @@ export interface SchemaInfo {
6
8
  outputPath?: string;
7
9
  }
8
10
  export interface SchemaQueryRequest {
9
- action: "list" | "get" | "search" | "list_operations" | "get_output" | "get_guard_templates" | "get_field";
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";
10
12
  name?: string;
11
13
  query?: string;
12
14
  field_path?: string;
13
15
  template?: string;
16
+ object_type?: TemplateObjectType;
17
+ params?: string;
14
18
  output_file?: string;
15
19
  }
20
+ export interface ExampleSearchResult {
21
+ file: string;
22
+ title: string;
23
+ description: string;
24
+ tags: string[];
25
+ industry: string;
26
+ operation_type: string;
27
+ verified: boolean;
28
+ score: number;
29
+ matched_fields: string[];
30
+ }
16
31
  export interface SchemaQueryResponse {
17
32
  [key: string]: unknown;
18
33
  success: boolean;
@@ -31,6 +46,7 @@ export declare function listSchemas(): SchemaInfo[];
31
46
  export declare function getSchema(name: string): any | null;
32
47
  export declare function getOutputSchema(name: string): any | null;
33
48
  export declare function getGuardTemplates(templateName?: string): any | null;
49
+ export declare function searchExamples(query: string): ExampleSearchResult[];
34
50
  export declare function getSchemaField(name: string, fieldPath: string): any | null;
35
51
  export declare function searchSchemas(query: string): SchemaInfo[];
36
52
  export declare function listOperations(): SchemaInfo[];