@wowok/agent-mcp 2.3.16 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/customer/index.d.ts +9 -0
  2. package/dist/customer/index.js +9 -0
  3. package/dist/customer/industry-risks.d.ts +4 -0
  4. package/dist/customer/industry-risks.js +45 -31
  5. package/dist/customer/order-monitor.js +57 -57
  6. package/dist/customer/order-strategy.js +89 -89
  7. package/dist/customer/post-purchase.js +97 -97
  8. package/dist/customer/reminder-system.js +26 -26
  9. package/dist/customer/risk-assessment.js +46 -46
  10. package/dist/customer/types.d.ts +4 -4
  11. package/dist/customer/types.js +4 -4
  12. package/dist/customer/user-preferences.d.ts +3 -0
  13. package/dist/customer/user-preferences.js +59 -50
  14. package/dist/experience/intent-distill.js +6 -6
  15. package/dist/experience/realtime-feedback.js +17 -0
  16. package/dist/index.js +360 -273
  17. package/dist/knowledge/acquisition-flywheel.d.ts +3 -0
  18. package/dist/knowledge/acquisition-flywheel.js +73 -64
  19. package/dist/knowledge/arbitration-trust.js +10 -10
  20. package/dist/knowledge/demand-matching.js +8 -8
  21. package/dist/knowledge/dynamic-pricing.js +18 -18
  22. package/dist/knowledge/flywheel-loop.js +11 -11
  23. package/dist/knowledge/glossary.js +22 -22
  24. package/dist/knowledge/guard-ledger.d.ts +19 -0
  25. package/dist/knowledge/guard-ledger.js +246 -0
  26. package/dist/knowledge/guard-lint.d.ts +76 -0
  27. package/dist/knowledge/guard-lint.js +590 -0
  28. package/dist/knowledge/guard-puzzle.d.ts +188 -0
  29. package/dist/knowledge/guard-puzzle.js +804 -0
  30. package/dist/knowledge/guard-risk.d.ts +67 -0
  31. package/dist/knowledge/guard-risk.js +1046 -0
  32. package/dist/knowledge/guard-templates.d.ts +37 -0
  33. package/dist/knowledge/guard-templates.js +329 -0
  34. package/dist/knowledge/guard-translation.d.ts +58 -0
  35. package/dist/knowledge/guard-translation.js +1118 -0
  36. package/dist/knowledge/index.d.ts +17 -0
  37. package/dist/knowledge/index.js +17 -0
  38. package/dist/knowledge/industry-evolution.js +29 -29
  39. package/dist/knowledge/industry-generalizer.js +52 -52
  40. package/dist/knowledge/industry-registry.d.ts +1 -2
  41. package/dist/knowledge/industry-registry.js +43 -36
  42. package/dist/knowledge/intent-metrics.js +67 -67
  43. package/dist/knowledge/process-model.js +80 -80
  44. package/dist/knowledge/reputation-rules.js +9 -9
  45. package/dist/knowledge/reward-templates.js +51 -51
  46. package/dist/knowledge/safety-rules.js +63 -2
  47. package/dist/knowledge/tool-constraints.js +17 -11
  48. package/dist/knowledge/trust-metrics.js +26 -26
  49. package/dist/safety/confirm-gate.d.ts +4 -2
  50. package/dist/safety/confirm-gate.js +48 -4
  51. package/dist/schema/call/allocation.d.ts +24 -14
  52. package/dist/schema/call/arbitration.d.ts +142 -132
  53. package/dist/schema/call/base.d.ts +901 -43
  54. package/dist/schema/call/base.js +77 -13
  55. package/dist/schema/call/bridge-handler.js +15 -2
  56. package/dist/schema/call/bridge.d.ts +795 -27
  57. package/dist/schema/call/bridge.js +37 -0
  58. package/dist/schema/call/contact.d.ts +10 -0
  59. package/dist/schema/call/demand.d.ts +94 -84
  60. package/dist/schema/call/guard.d.ts +229 -46
  61. package/dist/schema/call/guard.js +50 -0
  62. package/dist/schema/call/handler.js +46 -14
  63. package/dist/schema/call/machine.d.ts +158 -138
  64. package/dist/schema/call/order.d.ts +10 -0
  65. package/dist/schema/call/payment.d.ts +10 -0
  66. package/dist/schema/call/permission.d.ts +314 -304
  67. package/dist/schema/call/personal.d.ts +10 -0
  68. package/dist/schema/call/progress.d.ts +10 -0
  69. package/dist/schema/call/proof.d.ts +20 -0
  70. package/dist/schema/call/repository.d.ts +32 -22
  71. package/dist/schema/call/reward.d.ts +10 -0
  72. package/dist/schema/call/semantic.d.ts +9 -2
  73. package/dist/schema/call/semantic.js +617 -25
  74. package/dist/schema/call/service.d.ts +20 -10
  75. package/dist/schema/call/treasury.d.ts +10 -0
  76. package/dist/schema/config/index.d.ts +18 -0
  77. package/dist/schema/config/index.js +17 -0
  78. package/dist/schema/index.d.ts +6 -0
  79. package/dist/schema/index.js +5 -0
  80. package/dist/schema/local/index.d.ts +9 -9
  81. package/dist/schema/local/index.js +9 -0
  82. package/dist/schema/local/wip.d.ts +39 -19
  83. package/dist/schema/local/wip.js +5 -5
  84. package/dist/schema/messenger/index.d.ts +376 -55
  85. package/dist/schema/messenger/index.js +19 -19
  86. package/dist/schema/operations.d.ts +1881 -681
  87. package/dist/schema/operations.js +91 -96
  88. package/dist/schema/project/index.d.ts +21 -0
  89. package/dist/schema/project/index.js +32 -0
  90. package/dist/schema/query/index.d.ts +1074 -168
  91. package/dist/schema/query/index.js +8 -8
  92. package/dist/schema/schema-query/index.d.ts +33 -0
  93. package/dist/schema/schema-query/index.js +36 -0
  94. package/dist/schema/schema-version.d.ts +25 -0
  95. package/dist/schema/schema-version.js +76 -0
  96. package/dist/schema/trust/index.d.ts +407 -0
  97. package/dist/schema/trust/index.js +113 -0
  98. package/dist/schema/utils/guard-parser.js +4 -4
  99. package/dist/schema/utils/node-parser.js +14 -14
  100. package/dist/schemas/bridge_operation.output.json +233 -9
  101. package/dist/schemas/bridge_operation.schema.json +67 -8
  102. package/dist/schemas/config_operation.output.json +18 -0
  103. package/dist/schemas/config_operation.schema.json +34 -0
  104. package/dist/schemas/guard-node-schema.json +82 -0
  105. package/dist/schemas/guard2file.schema.json +8 -0
  106. package/dist/schemas/index.json +19 -1
  107. package/dist/schemas/machineNode2file.schema.json +8 -0
  108. package/dist/schemas/messenger_operation.output.json +236 -10
  109. package/dist/schemas/onchain_events.output.json +718 -0
  110. package/dist/schemas/onchain_operations.output.json +286 -11
  111. package/dist/schemas/onchain_operations.schema.json +19 -16
  112. package/dist/schemas/onchain_operations_allocation.schema.json +8 -0
  113. package/dist/schemas/onchain_operations_arbitration.schema.json +8 -0
  114. package/dist/schemas/onchain_operations_contact.schema.json +8 -0
  115. package/dist/schemas/onchain_operations_demand.schema.json +8 -0
  116. package/dist/schemas/onchain_operations_gen_passport.schema.json +16 -0
  117. package/dist/schemas/onchain_operations_guard.schema.json +11 -16
  118. package/dist/schemas/onchain_operations_machine.schema.json +8 -0
  119. package/dist/schemas/onchain_operations_order.schema.json +8 -0
  120. package/dist/schemas/onchain_operations_payment.schema.json +8 -0
  121. package/dist/schemas/onchain_operations_permission.schema.json +8 -0
  122. package/dist/schemas/onchain_operations_personal.schema.json +8 -0
  123. package/dist/schemas/onchain_operations_progress.schema.json +8 -0
  124. package/dist/schemas/onchain_operations_repository.schema.json +8 -0
  125. package/dist/schemas/onchain_operations_reward.schema.json +8 -0
  126. package/dist/schemas/onchain_operations_service.schema.json +8 -0
  127. package/dist/schemas/onchain_operations_treasury.schema.json +8 -0
  128. package/dist/schemas/onchain_table_data.output.json +718 -0
  129. package/dist/schemas/project_operation.output.json +18 -0
  130. package/dist/schemas/project_operation.schema.json +42 -0
  131. package/dist/schemas/query_toolkit.schema.json +360 -368
  132. package/dist/schemas/schema_query.schema.json +6 -3
  133. package/dist/schemas/trust_score.output.json +327 -0
  134. package/dist/schemas/trust_score.schema.json +46 -0
  135. package/dist/schemas/wip_file.output.json +24 -1
  136. package/package.json +2 -2
@@ -67,6 +67,8 @@ export const CallEnvSchema = z.object({
67
67
  confirmed: z.boolean().optional().describe("Phase 2 ConfirmGate: set to true to proceed after a 'pending_confirmation' result. The operation is NOT executed until you re-call with confirmed=true after user consent."),
68
68
  user_intent_phrases: z.array(z.string()).optional().describe("Phase 2 ConfirmGate: explicit user intent phrases collected from conversation context (e.g. 'use default account', 'force publish'). Used to bypass confirmation rules whose bypass_on_explicit_intent matches."),
69
69
  project: z.string().optional().describe("Phase 2 ProjectService: explicit project prefix to assign this object to (e.g. 'myshop'). When set, the object is tagged with 'project:<prefix>' automatically. Overrides the prefix parsed from the object name."),
70
+ client_schema_version: z.string().optional().describe("Client-side schema version (semver, e.g. '1.0.0'). When provided, the server checks compatibility and attaches warnings if mismatched."),
71
+ schema_strict_mode: z.boolean().optional().describe("When true, schema incompatibility returns an error instead of a warning. Default: false (warn mode)."),
70
72
  }).strict().describe(`IMPORTANT: Execution environment includes: account for signing operations, network selection (${ENTRYPOINT}), additional Guard permissions, and more. Used to specify context information during the call. If account is not specified, the default account ("") will be used.`);
71
73
  export const ObjectsOpSchema = z.union([
72
74
  z.object({
@@ -120,7 +122,7 @@ export const ExperienceSchema = z.object({
120
122
  avoid: z.array(z.string()).optional().describe("Pitfalls to avoid based on history. Example: ['Guard rejection on delivery_proof']"),
121
123
  relevance: z.number().min(0).max(1).optional().describe("Relevance score 0-1 of the matched experience. Example: 0.85"),
122
124
  matched_scenario: z.string().optional().describe("Matched historical scenario. Example: 'publish_service_freelance'"),
123
- }).strict().describe("Experience layer feedback from past operations (Phase 2 议题 2). Provides advice and pitfalls based on historical patterns.");
125
+ }).strict().describe("Experience layer feedback from past operations (Phase 2 Topic 2). Provides advice and pitfalls based on historical patterns.");
124
126
  export const ServiceStatusSchema = z.object({
125
127
  active: z.array(z.string()).describe("Phase 2 services currently active (enabled). Example: ['confirm_gate','project_service','experience_layer']"),
126
128
  inactive: z.array(z.string()).optional().describe("Phase 2 services currently inactive (can be toggled via config_operation). Example: ['harness','graph_persist']"),
@@ -129,31 +131,82 @@ export const CustomerReminderSchema = z.object({
129
131
  id: z.string().describe("Reminder rule id. Example: 'high_risk_score'"),
130
132
  stage: z.enum(["browse", "evaluate", "preorder", "in_progress", "complete", "after_sale"]).describe("Order lifecycle stage when this reminder fires. Example: 'evaluate'"),
131
133
  priority: z.enum(["required", "recommended", "info", "reminder"]).describe("Priority. 'required' = blocks purchase; 'recommended' = strong caution. Example: 'required'"),
132
- message: z.string().describe("Human-readable reminder message. Example: '🔴 综合风险分 25/100,强烈建议不购买'"),
134
+ message: z.string().describe("Human-readable reminder message. Example: 'Composite risk score 25/100, strongly discourage purchase'"),
133
135
  action: z.string().optional().describe("Suggested next action. Example: 'require merchant to bind Arbitration before ordering'"),
134
136
  }).strict().describe("A buyer-side reminder triggered at a specific order lifecycle stage (Phase 3 C-3).");
135
137
  export const PreferenceMatchSchema = z.object({
136
138
  score: z.number().min(0).max(100).describe("Match score 0-100 (higher = better fit). Example: 75"),
137
- matches: z.array(z.string()).describe("Aspects that match user preferences. Example: ['价格低于均价 10%','有仲裁']"),
138
- mismatches: z.array(z.string()).describe("Aspects that mismatch user preferences. Example: ['交付周期超出期望']"),
139
+ matches: z.array(z.string()).describe("Aspects that match user preferences. Example: ['Price 10% below average','Has arbitration']"),
140
+ mismatches: z.array(z.string()).describe("Aspects that mismatch user preferences. Example: ['Delivery cycle exceeds expectation']"),
139
141
  }).strict().describe("Service-to-preference match result (Phase 3 C-2). 7-dimension scoring: price/time/region/brand/bargain/emotion/risk.");
140
142
  export const CustomerAdviceSchema = z.object({
141
143
  risk_score: z.number().min(0).max(100).optional().describe("Composite risk score 0-100 (higher = safer). Relation: from risk-assessment.ts 4-dimension scoring. Example: 75"),
142
144
  risk_level: z.enum(["low", "medium_low", "medium_high", "high"]).optional().describe("Risk level bucket. 'high' = strongly discourage purchase. Example: 'medium_high'"),
143
- recommendations: z.array(z.string()).describe("Actionable recommendations for the buyer. Example: ['要求商家配置仲裁','通过 Messenger 协商退款条款']"),
144
- reminders: z.array(CustomerReminderSchema).describe("Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'🔴 模糊 Guard 必须人工审查'}]"),
145
+ recommendations: z.array(z.string()).describe("Actionable recommendations for the buyer. Example: ['Require merchant to configure arbitration','Negotiate refund terms via Messenger']"),
146
+ reminders: z.array(CustomerReminderSchema).describe("Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'Ambiguous Guard must be human-reviewed'}]"),
145
147
  preference_match: PreferenceMatchSchema.optional().describe("Service-to-preference match (populated when user preferences exist). Example: {score:75, matches:[...], mismatches:[...]}"),
146
148
  }).strict().describe("Buyer-side advice (Phase 3 C-3.3). Populated in semantic.customer_advice for order/query operations when customer_intelligence service is enabled.");
147
149
  export const EvolutionContextSchema = z.object({
148
- industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: '行业健康度 82/100healthy);累积 25 个行业信号'"),
149
- evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: '建议强制配置仲裁 + 赔偿金 + 交付 Guard'"),
150
+ industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: 'Industry health 82/100 (healthy); 25 cumulative industry signals'"),
151
+ evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: 'Recommend mandatory arbitration + compensation fund + delivery Guard'"),
150
152
  confidence: z.number().min(0).max(1).describe("Confidence of the evolution context 0-1. <0.5 means no data yet. Example: 0.75"),
151
153
  health_score: z.number().min(0).max(100).optional().describe("Industry health score 0-100 if available. Example: 82"),
152
154
  pending_suggestions: z.number().int().min(0).optional().describe("Count of pending industry update suggestions (filtered by role if role is set). Example: 3"),
153
155
  intent: z.enum(["default", "growth", "retention", "compliance", "efficiency", "trust_building", "custom"]).optional().describe("Phase 4 P4-6.C: Current business intent driving the scoring model. Absent = 'default'. Example: 'growth'"),
154
- role_advice: z.array(z.string()).optional().describe("Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['强化忠诚度飞轮','优化首单转化']"),
156
+ role_advice: z.array(z.string()).optional().describe("Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['Strengthen loyalty flywheel','Optimize first-order conversion']"),
155
157
  role: z.enum(["user", "merchant", "arbitrator"]).optional().describe("Phase 4 P4-6.C: Role used for advice routing. Example: 'merchant'"),
156
158
  }).strict().describe("Phase 4 industry evolution context (populated when industry_evolution service is enabled). Provides AI with industry-level health signals, evolution advice, and role-targeted recommendations.");
159
+ export const GuardPuzzleStatusSchema = z.object({
160
+ intent: z.boolean().describe("Intent dimension complete (action + rule + failure conditions)"),
161
+ binding: z.boolean().describe("Binding dimension complete (host object + field + circular ref)"),
162
+ data: z.boolean().describe("Data dimension complete (table entries + witnesses)"),
163
+ query: z.boolean().describe("Query dimension complete (query instructions if needed)"),
164
+ logic: z.boolean().describe("Logic dimension complete (root node returns Bool)"),
165
+ constraints: z.boolean().describe("Constraints dimension complete (10 Pitfalls checked)"),
166
+ }).strict().describe("Guard information puzzle completeness status. 6 dimensions (A-F). false = missing, needs user input.");
167
+ export const GuardAvailableQuerySchema = z.object({
168
+ id: z.number().int().describe("Query instruction ID. Example: 1253"),
169
+ name: z.string().describe("Query instruction name. Example: 'progress.current_node_name'"),
170
+ objectType: z.string().describe("Target object type. Example: 'Progress'"),
171
+ returnType: z.string().describe("Return value type. Example: 'String'"),
172
+ description: z.string().optional().describe("Query description"),
173
+ }).strict().describe("A Guard query instruction available for the current context (subset of GUARDQUERY 375 entries).");
174
+ export const GuardAdviceSchema = z.object({
175
+ current_round: z.enum(["R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10"]).optional()
176
+ .describe("Current R1-R10 dialogue round. R1=intent, R2=table, R3=tree, R4=rely, R5=binding, R6=review, R7=CREATE, R8=test, R9=bind, R10=verify. Example: 'R3'"),
177
+ puzzle_status: GuardPuzzleStatusSchema.optional()
178
+ .describe("Information puzzle completeness (6 dimensions). Missing dimensions need user input before CREATE."),
179
+ matched_scene: z.string().optional()
180
+ .describe("Matched Guard scene id from the 8 binding scenarios ledger. Example: 'machine_forward_guard'"),
181
+ scene_description: z.string().optional()
182
+ .describe("Human-readable scene description. Example: 'Workflow node forward validation (Forward.guard)'"),
183
+ scene_constraints: z.array(z.string()).optional()
184
+ .describe("Special constraints for the matched scene. Example: ['Forward.guard cannot be modified after Machine is published']"),
185
+ suggested_patterns: z.array(z.string()).optional()
186
+ .describe("Suggested Guard patterns based on user intent. Example: ['time lock','progress status check']"),
187
+ available_queries: z.array(GuardAvailableQuerySchema).optional()
188
+ .describe("Available query instructions for the current context (subset of 375 GUARDQUERY entries)"),
189
+ risk_warnings: z.array(z.string()).optional()
190
+ .describe("Risk warnings for the current Guard design. Example: ['Guard cannot be modified after creation','Time lock test uses 1000ms']"),
191
+ pending_questions: z.array(z.string()).optional()
192
+ .describe("Questions for the user to complete the puzzle. Example: ['Which Host Object will the Guard bind to?']"),
193
+ confirmation_text: z.string().optional()
194
+ .describe("Structured semantic confirmation text for user review (generated when puzzle is complete). User must explicitly confirm before CREATE."),
195
+ test_result: z.object({
196
+ status: z.enum(["pass", "fail", "not_tested"]),
197
+ failure_node: z.string().optional().describe("Node that caused failure (if fail)"),
198
+ passport_id: z.string().optional().describe("Generated Passport ID (if pass)"),
199
+ }).optional().describe("gen_passport static test result. Must pass before CREATE."),
200
+ risk_assessment: z.object({
201
+ overall_risk: z.enum(["critical", "high", "medium", "low", "info"]).describe("Overall risk level (highest from all risks)"),
202
+ risk_count: z.number().int().describe("Total number of detected risks"),
203
+ critical_count: z.number().int().describe("Number of critical risks"),
204
+ high_count: z.number().int().describe("Number of high risks"),
205
+ needs_human_review: z.boolean().describe("Whether human review is required (critical or 2+ high risks)"),
206
+ top_risks: z.array(z.string()).describe("Top risk titles (critical and high, max 3)"),
207
+ stakeholder_advice: z.record(z.string(), z.array(z.string())).optional().describe("Per-stakeholder advice. Key=stakeholder (customer/provider/arbitrator/claimant), value=advice list"),
208
+ }).optional().describe("Business-layer risk assessment (game theory, data source trust, logic gaps). Populated during Guard design to warn about business risks beyond syntax."),
209
+ }).strict().describe("Guard advice (Phase 5 Guard capability system). Injected when user intent involves Guard. Provides context for Guard design, generation, confirmation, and execution.");
157
210
  export const SemanticSummarySchema = z.object({
158
211
  intent: z.string().describe("Inferred user intent / operation goal. Constraint: snake_case string. Relation: derived from operation_type + data signals. Example: 'publish_service'"),
159
212
  status: z.enum(["success", "partial", "failed", "pending_input"]).describe("Business-level status (not raw tx status). 'pending_input' = needs Guard submission. Example: 'success'"),
@@ -164,16 +217,17 @@ export const SemanticSummarySchema = z.object({
164
217
  events: z.array(EventSemanticSchema).optional().describe("On-chain events annotated with business semantics (S-8)"),
165
218
  next_actions: z.array(NextActionSchema).optional().describe("Recommended next actions to drive the workflow forward"),
166
219
  warnings: z.array(z.string()).optional().describe("Business-level warnings. Example: 'order_allocators not configured; order funds cannot be distributed'"),
167
- experience: ExperienceSchema.optional().describe("Experience layer feedback from past operations (Phase 2 议题 2)"),
220
+ experience: ExperienceSchema.optional().describe("Experience layer feedback from past operations (Phase 2 Topic 2)"),
168
221
  service_status: ServiceStatusSchema.optional().describe("Phase 2 runtime service status (populated when semantic_rich is enabled). Lets AI see active services in each response."),
169
222
  customer_advice: CustomerAdviceSchema.optional().describe("Buyer-side advice (Phase 3 C-3.3). Populated when customer_intelligence service is enabled AND operation is order/query on a Service. Contains risk_score, recommendations, reminders, and preference_match."),
170
223
  evolution_context: EvolutionContextSchema.optional().describe("Phase 4 industry evolution context (populated when industry_evolution service is enabled). Provides AI with industry health signals and evolution advice."),
224
+ guard_advice: GuardAdviceSchema.optional().describe("Phase 5 Guard capability advice (populated when user intent involves Guard). Provides puzzle status, scene matching, suggested patterns, available queries, risk warnings, and confirmation text. AI uses this to guide Guard design dialogue (R1-R10)."),
171
225
  }).strict().describe("Business semantic summary: translates the raw transaction response into AI-directly-understandable business meaning");
172
226
  export const CallResponseErrorSchema = z.object({
173
227
  type: z.literal("error").describe("Discriminator for this result variant. Constraint: always 'error'. Example: 'error'"),
174
228
  error: z.string().describe("Human-readable error message from the chain or SDK. Relation: enriched via enrichMoveError before classification. Example: 'Insufficient balance for gas'"),
175
- error_code: z.enum(["invalid_parameter", "guard_rejected", "state_conflict", "insufficient_balance", "object_not_found", "permission_denied", "immutable_violation", "network_error", "unknown"]).optional().describe("Error classification for programmatic recovery. Constraint: enum of 9 values. Relation: drives Recover Loop strategy selection. Example: 'insufficient_balance'"),
176
- retryable: z.boolean().optional().describe("Whether the same call can be retried as-is. Constraint: true only for network_error and insufficient_balance. Example: true"),
229
+ error_code: z.enum(["invalid_parameter", "guard_rejected", "state_conflict", "insufficient_balance", "object_not_found", "permission_denied", "immutable_violation", "network_error", "rate_limit", "gas_exceeded", "bcs_error", "signature_error", "config_error", "unknown"]).optional().describe("Error classification for programmatic recovery. Constraint: enum of 14 values. Relation: drives Recover Loop strategy selection. Example: 'insufficient_balance'"),
230
+ retryable: z.boolean().optional().describe("Whether the same call can be retried as-is. Constraint: true for network_error, rate_limit, gas_exceeded, and insufficient_balance. Example: true"),
177
231
  recovery_hint: z.string().optional().describe("Recovery suggestion for AI or user. Relation: paired with error_code to guide Recover Loop. Example: 'Claim faucet tokens then retry'"),
178
232
  related_object: z.string().optional().describe("Object ID related to the error, if any. Example: '0x123...'"),
179
233
  }).describe("Error result. Contains the raw error message plus structured classification (error_code/retryable/recovery_hint) so AI can choose a recovery strategy without parsing the error string.");
@@ -192,7 +246,7 @@ export const OperationPreviewSchema = z.object({
192
246
  immutable_after: z.array(z.string()).optional().describe("Fields that become immutable after this op (for publish). Example: ['machine','order_allocators']"),
193
247
  warnings: z.array(z.string()).optional().describe("Default-value warnings. Example: ['Using default account (env.account=\"\")']"),
194
248
  irreversible: z.boolean().optional().describe("True when the operation cannot be reverted. Example: true"),
195
- }).strict().describe("Preview of an operation awaiting user confirmation (Phase 2 议题 4 ConfirmGate).");
249
+ }).strict().describe("Preview of an operation awaiting user confirmation (Phase 2 Topic 4 ConfirmGate).");
196
250
  export const CallPendingConfirmationSchema = z.object({
197
251
  type: z.literal("pending_confirmation").describe("Discriminator. The operation was NOT executed; it is blocked pending user confirmation. Re-call with env.confirmed=true to proceed, or modify/cancel."),
198
252
  preview: OperationPreviewSchema.describe("Preview of the operation awaiting confirmation."),
@@ -276,9 +330,19 @@ export const HarnessReportSchema = z.object({
276
330
  verify: VerifyReportSchema.describe("Verify Loop report comparing expected vs actual."),
277
331
  recovery: RecoveryActionSchema.optional().describe("Recover Loop action. Present only when verify.status is 'fail' or 'warn', or when an error occurred."),
278
332
  }).describe("L4 Harness report attached to CallOutput when the Harness is injected. Contains verify result and optional recovery action. AI should check verify.status first; if 'fail', consult recovery.strategy.");
333
+ export const SchemaWarningSchema = z.object({
334
+ compatible: z.boolean().describe("Whether the client schema version is compatible with the server."),
335
+ warnings: z.array(z.string()).describe("Schema compatibility warnings or errors."),
336
+ client_version: z.string().optional().describe("The client schema version that was checked."),
337
+ server_versions: z.object({
338
+ sdk: z.string().describe("Server-side SDK schema version."),
339
+ mcp: z.string().describe("Server-side MCP tool schema version."),
340
+ }).describe("Server-side schema versions."),
341
+ }).strict().describe("Schema compatibility warning attached to tool output when client_schema_version is provided and a mismatch is detected.");
279
342
  export const CallOutputSchema = z.object({
280
343
  result: CallResultSchema.describe("Discriminated result. Check result.type first: 'transaction'|'submission'|'error'|'data'|'null'. Each variant has different fields."),
281
344
  message: z.string().optional().describe("Human-readable summary or hint. Constraint: always present for error/transaction results; may be omitted for data/null. Example: 'Transaction completed successfully'"),
282
345
  semantic: SemanticSummarySchema.optional().describe("Business semantic summary. AI should read semantic first; fall back to parsing result only when semantic is absent. Relation: populated by MCP server from operation context; undefined when intent cannot be confidently inferred or for non-transaction tools. Example: {intent:'publish_service', status:'success', summary:'...'}"),
283
346
  harness_report: HarnessReportSchema.optional().describe("L4 Harness report (Verify + Recover). Present only when the Harness is injected and an Expected Result was declared for this operation. Relation: produced by handler.ts calling harness.verify() and harness.recover(). Example: {verify:{status:'fail', mismatches:[...]}, recovery:{strategy:'recreate'}}"),
347
+ schema_warning: SchemaWarningSchema.optional().describe("Schema compatibility warning. Present only when client_schema_version is provided in env and a mismatch is detected."),
284
348
  }).strict().describe("Unified MCP tool output. result.type discriminates 5 outcomes: 'transaction' (raw Sui response), 'submission' (needs Guard data), 'error' (failed with error_code), 'data' (query result), 'null' (no-op). When semantic is present, prefer it over raw result parsing. When harness_report is present, check verify.status first and follow recovery.strategy if status is 'fail'.");
@@ -116,8 +116,11 @@ export async function handleBridgeOperations(args) {
116
116
  amount: BigInt(data.amount),
117
117
  withdrawTo: data.withdrawTo,
118
118
  waitForFinalization: false,
119
+ idempotencyKey: data.idempotencyKey,
120
+ idempotentByParams: data.idempotentByParams,
119
121
  });
120
- return ok(`WOW→EVM cross-chain step 1 (deposit) submitted. transferId=${result.transferId}, activeEvmAccount=${result.activeEvmAccount}. ` +
122
+ const idemMsg = result.idempotentHit ? " [IDEMPOTENT HIT no new deposit]" : "";
123
+ return ok(`WOW→EVM cross-chain step 1 (deposit) submitted. transferId=${result.transferId}, activeEvmAccount=${result.activeEvmAccount}.${idemMsg} ` +
121
124
  `Next: poll query_transfer_status until bridge signs (~1-5 min), then call claim_wow_to_evm to complete.`, result, ctx);
122
125
  }
123
126
  case "cross_chain_evm_to_wow": {
@@ -130,8 +133,11 @@ export async function handleBridgeOperations(args) {
130
133
  amount: BigInt(data.amount),
131
134
  recipientWowAddress,
132
135
  waitForFinalization: false,
136
+ idempotencyKey: data.idempotencyKey,
137
+ idempotentByParams: data.idempotentByParams,
133
138
  });
134
- return ok(`EVM→WOW cross-chain submitted. transferId=${result.transferId}, activeEvmAccount=${result.activeEvmAccount}. ` +
139
+ const idemMsg = result.idempotentHit ? " [IDEMPOTENT HIT — no new deposit]" : "";
140
+ return ok(`EVM→WOW cross-chain submitted. transferId=${result.transferId}, activeEvmAccount=${result.activeEvmAccount}.${idemMsg} ` +
135
141
  `Bridge will auto-claim on WOW (~10-20 min). Poll query_transfer_status to monitor progress.`, result, ctx);
136
142
  }
137
143
  case "claim_wow_to_evm": {
@@ -141,6 +147,13 @@ export async function handleBridgeOperations(args) {
141
147
  const result = await client.claimWowToEvm(data.transferId);
142
148
  return ok(`WOW→EVM claim (step 2) completed. transferId=${result.transferId}, claimTxHash=${result.claimTxHash}`, result, ctx);
143
149
  }
150
+ case "resume_transfer": {
151
+ validateMainnet(env);
152
+ const data = validated.data;
153
+ const client = getBridgeClient(env);
154
+ const result = await client.resumeTransfer(data.transferId);
155
+ return ok(`Transfer ${data.transferId} resumed. Current step: ${result.step}, status: ${result.status}.`, result, ctx);
156
+ }
144
157
  case "withdraw": {
145
158
  const data = validated.data;
146
159
  const client = getBridgeClientForQuery();