@wowok/agent-mcp 2.3.13 → 2.3.16
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.
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/runtime.d.ts +26 -0
- package/dist/config/runtime.js +217 -0
- package/dist/customer/industry-risks.d.ts +36 -0
- package/dist/customer/industry-risks.js +424 -0
- package/dist/customer/info-puzzle.d.ts +102 -0
- package/dist/customer/info-puzzle.js +312 -0
- package/dist/customer/order-monitor.d.ts +75 -0
- package/dist/customer/order-monitor.js +327 -0
- package/dist/customer/order-strategy.d.ts +36 -0
- package/dist/customer/order-strategy.js +373 -0
- package/dist/customer/post-purchase.d.ts +42 -0
- package/dist/customer/post-purchase.js +350 -0
- package/dist/customer/reminder-system.d.ts +42 -0
- package/dist/customer/reminder-system.js +295 -0
- package/dist/customer/risk-assessment.d.ts +8 -0
- package/dist/customer/risk-assessment.js +337 -0
- package/dist/customer/types.d.ts +193 -0
- package/dist/customer/types.js +13 -0
- package/dist/customer/user-preferences.d.ts +67 -0
- package/dist/customer/user-preferences.js +451 -0
- package/dist/experience/experience-reuse.d.ts +10 -0
- package/dist/experience/experience-reuse.js +103 -0
- package/dist/experience/index.d.ts +6 -0
- package/dist/experience/index.js +5 -0
- package/dist/experience/intent-distill.d.ts +3 -0
- package/dist/experience/intent-distill.js +83 -0
- package/dist/experience/realtime-feedback.d.ts +5 -0
- package/dist/experience/realtime-feedback.js +77 -0
- package/dist/experience/types.d.ts +50 -0
- package/dist/experience/types.js +1 -0
- package/dist/experience/user-profile.d.ts +25 -0
- package/dist/experience/user-profile.js +171 -0
- package/dist/harness/checkpoint.d.ts +8 -0
- package/dist/harness/checkpoint.js +129 -0
- package/dist/harness/index.d.ts +33 -0
- package/dist/harness/index.js +75 -0
- package/dist/harness/plan.d.ts +18 -0
- package/dist/harness/plan.js +252 -0
- package/dist/harness/recover.d.ts +17 -0
- package/dist/harness/recover.js +139 -0
- package/dist/harness/types.d.ts +137 -0
- package/dist/harness/types.js +1 -0
- package/dist/harness/verify.d.ts +42 -0
- package/dist/harness/verify.js +237 -0
- package/dist/index.js +667 -201
- package/dist/knowledge/acquisition-flywheel.d.ts +50 -0
- package/dist/knowledge/acquisition-flywheel.js +183 -0
- package/dist/knowledge/arbitration-trust.d.ts +24 -0
- package/dist/knowledge/arbitration-trust.js +117 -0
- package/dist/knowledge/audit-rules.d.ts +28 -0
- package/dist/knowledge/audit-rules.js +141 -0
- package/dist/knowledge/demand-matching.d.ts +29 -0
- package/dist/knowledge/demand-matching.js +132 -0
- package/dist/knowledge/dynamic-pricing.d.ts +31 -0
- package/dist/knowledge/dynamic-pricing.js +87 -0
- package/dist/knowledge/flywheel-loop.d.ts +87 -0
- package/dist/knowledge/flywheel-loop.js +378 -0
- package/dist/knowledge/glossary.d.ts +18 -0
- package/dist/knowledge/glossary.js +209 -0
- package/dist/knowledge/index.d.ts +64 -0
- package/dist/knowledge/index.js +66 -0
- package/dist/knowledge/industry-evolution.d.ts +82 -0
- package/dist/knowledge/industry-evolution.js +323 -0
- package/dist/knowledge/industry-generalizer.d.ts +17 -0
- package/dist/knowledge/industry-generalizer.js +381 -0
- package/dist/knowledge/industry-registry.d.ts +49 -0
- package/dist/knowledge/industry-registry.js +167 -0
- package/dist/knowledge/intent-metrics.d.ts +42 -0
- package/dist/knowledge/intent-metrics.js +566 -0
- package/dist/knowledge/process-model.d.ts +24 -0
- package/dist/knowledge/process-model.js +160 -0
- package/dist/knowledge/reputation-rules.d.ts +42 -0
- package/dist/knowledge/reputation-rules.js +99 -0
- package/dist/knowledge/reward-templates.d.ts +25 -0
- package/dist/knowledge/reward-templates.js +125 -0
- package/dist/knowledge/safety-rules.d.ts +36 -0
- package/dist/knowledge/safety-rules.js +171 -0
- package/dist/knowledge/tool-constraints.d.ts +30 -0
- package/dist/knowledge/tool-constraints.js +185 -0
- package/dist/knowledge/trust-metrics.d.ts +37 -0
- package/dist/knowledge/trust-metrics.js +138 -0
- package/dist/loop-engineering/aggregate.d.ts +50 -0
- package/dist/loop-engineering/aggregate.js +132 -0
- package/dist/loop-engineering/diagnose.d.ts +22 -0
- package/dist/loop-engineering/diagnose.js +273 -0
- package/dist/loop-engineering/improve.d.ts +26 -0
- package/dist/loop-engineering/improve.js +229 -0
- package/dist/loop-engineering/index.d.ts +4 -0
- package/dist/loop-engineering/index.js +4 -0
- package/dist/loop-engineering/pipeline.d.ts +17 -0
- package/dist/loop-engineering/pipeline.js +56 -0
- package/dist/mode-market/index.d.ts +3 -0
- package/dist/mode-market/index.js +3 -0
- package/dist/mode-market/registry.d.ts +53 -0
- package/dist/mode-market/registry.js +124 -0
- package/dist/mode-market/review.d.ts +27 -0
- package/dist/mode-market/review.js +214 -0
- package/dist/mode-market/submission.d.ts +25 -0
- package/dist/mode-market/submission.js +85 -0
- package/dist/project/graph.d.ts +71 -0
- package/dist/project/graph.js +314 -0
- package/dist/project/index.d.ts +62 -0
- package/dist/project/index.js +167 -0
- package/dist/project/namespace.d.ts +62 -0
- package/dist/project/namespace.js +181 -0
- package/dist/project/query.d.ts +40 -0
- package/dist/project/query.js +110 -0
- package/dist/safety/confirm-gate.d.ts +15 -0
- package/dist/safety/confirm-gate.js +44 -0
- package/dist/safety/index.d.ts +3 -0
- package/dist/safety/index.js +3 -0
- package/dist/safety/preview.d.ts +2 -0
- package/dist/safety/preview.js +36 -0
- package/dist/schema/call/allocation.d.ts +55 -40
- package/dist/schema/call/arbitration.d.ts +201 -186
- package/dist/schema/call/base.d.ts +2104 -24
- package/dist/schema/call/base.js +168 -22
- package/dist/schema/call/bridge-handler.js +36 -18
- package/dist/schema/call/bridge.d.ts +777 -120
- package/dist/schema/call/bridge.js +13 -2
- package/dist/schema/call/contact.d.ts +15 -0
- package/dist/schema/call/demand.d.ts +69 -54
- package/dist/schema/call/guard.d.ts +125 -80
- package/dist/schema/call/handler.d.ts +5 -1
- package/dist/schema/call/handler.js +108 -3
- package/dist/schema/call/index.d.ts +1 -0
- package/dist/schema/call/index.js +1 -0
- package/dist/schema/call/machine.d.ts +830 -800
- package/dist/schema/call/order.d.ts +27 -12
- package/dist/schema/call/payment.d.ts +15 -0
- package/dist/schema/call/permission.d.ts +15 -0
- package/dist/schema/call/personal.d.ts +15 -0
- package/dist/schema/call/progress.d.ts +21 -6
- package/dist/schema/call/proof.d.ts +42 -12
- package/dist/schema/call/proof.js +3 -3
- package/dist/schema/call/repository.d.ts +91 -76
- package/dist/schema/call/reward.d.ts +51 -36
- package/dist/schema/call/semantic.d.ts +24 -0
- package/dist/schema/call/semantic.js +981 -0
- package/dist/schema/call/service.d.ts +444 -429
- package/dist/schema/call/treasury.d.ts +219 -204
- package/dist/schema/common/index.js +3 -3
- package/dist/schema/local/index.d.ts +341 -74
- package/dist/schema/local/index.js +44 -7
- package/dist/schema/messenger/index.d.ts +1034 -92
- package/dist/schema/messenger/index.js +18 -0
- package/dist/schema/operations.d.ts +2634 -1817
- package/dist/schema/operations.js +16 -5
- package/dist/schema/query/index.d.ts +2293 -2289
- package/dist/schema/query/index.js +34 -28
- package/dist/schemas/account_operation.output.json +28 -16
- package/dist/schemas/account_operation.schema.json +2 -2
- package/dist/schemas/bridge_operation.output.json +520 -0
- package/dist/schemas/bridge_operation.schema.json +15 -0
- package/dist/schemas/guard2file.schema.json +15 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_info_operation.output.json +26 -0
- package/dist/schemas/local_info_operation.schema.json +1 -1
- package/dist/schemas/local_mark_operation.output.json +27 -1
- package/dist/schemas/local_mark_operation.schema.json +4 -4
- package/dist/schemas/machineNode2file.schema.json +15 -0
- package/dist/schemas/messenger_operation.output.json +549 -0
- package/dist/schemas/messenger_operation.schema.json +21 -0
- package/dist/schemas/onchain_events.output.json +3 -0
- package/dist/schemas/onchain_operations.output.json +814 -37
- package/dist/schemas/onchain_operations.schema.json +117 -40
- package/dist/schemas/onchain_operations_allocation.schema.json +26 -9
- package/dist/schemas/onchain_operations_arbitration.schema.json +26 -9
- package/dist/schemas/onchain_operations_contact.schema.json +26 -9
- package/dist/schemas/onchain_operations_demand.schema.json +26 -9
- package/dist/schemas/onchain_operations_gen_passport.schema.json +51 -17
- package/dist/schemas/onchain_operations_guard.schema.json +26 -9
- package/dist/schemas/onchain_operations_machine.schema.json +92 -32
- package/dist/schemas/onchain_operations_order.schema.json +26 -9
- package/dist/schemas/onchain_operations_payment.schema.json +26 -9
- package/dist/schemas/onchain_operations_permission.schema.json +26 -9
- package/dist/schemas/onchain_operations_personal.schema.json +26 -9
- package/dist/schemas/onchain_operations_progress.schema.json +26 -9
- package/dist/schemas/onchain_operations_repository.schema.json +26 -9
- package/dist/schemas/onchain_operations_reward.schema.json +26 -9
- package/dist/schemas/onchain_operations_service.schema.json +26 -9
- package/dist/schemas/onchain_operations_treasury.schema.json +26 -9
- package/dist/schemas/onchain_table_data.output.json +224 -69
- package/dist/schemas/onchain_table_data.schema.json +2 -2
- package/dist/schemas/query_toolkit.schema.json +5 -1
- package/dist/telemetry/index.d.ts +19 -0
- package/dist/telemetry/index.js +112 -0
- package/dist/telemetry/redact.d.ts +2 -0
- package/dist/telemetry/redact.js +23 -0
- package/dist/telemetry/storage.d.ts +8 -0
- package/dist/telemetry/storage.js +80 -0
- package/package.json +6 -3
package/dist/schema/call/base.js
CHANGED
|
@@ -64,6 +64,9 @@ export const CallEnvSchema = z.object({
|
|
|
64
64
|
no_cache: z.boolean().optional().describe("Whether to disable caching."),
|
|
65
65
|
network: EntrypointSchema.optional(),
|
|
66
66
|
referrer: NameOrAddressSchema.optional().describe("Referrer ID. If the user is using the network for the first time, the referrer ID will be recorded."),
|
|
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
|
+
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
|
+
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."),
|
|
67
70
|
}).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.`);
|
|
68
71
|
export const ObjectsOpSchema = z.union([
|
|
69
72
|
z.object({
|
|
@@ -75,24 +78,138 @@ export const ObjectsOpSchema = z.union([
|
|
|
75
78
|
}).describe("Remove all objects."),
|
|
76
79
|
]).describe("Operate object list. Used to set, add, or remove objects.");
|
|
77
80
|
export const ResponseDataSchema = ObjectBaseSchema.extend({
|
|
78
|
-
change: z.union([z.literal("created"), z.literal("mutated"), z.string()]),
|
|
79
|
-
}).describe("
|
|
81
|
+
change: z.union([z.literal("created"), z.literal("mutated"), z.string()]).describe("What happened to this object in the operation. Constraint: 'created' | 'mutated' | custom string. Example: 'created'"),
|
|
82
|
+
}).describe("One object record in a query result. Contains the object's basic info plus how it changed in this operation.");
|
|
83
|
+
export const ObjectRoleSchema = z.object({
|
|
84
|
+
id: z.string().describe("Object ID (64-hex with 0x prefix). Identifies the on-chain object. Example: '0xa1d4...'"),
|
|
85
|
+
name: z.union([z.string(), z.null()]).optional().describe("Local mark name if assigned, else null. Relation: resolved via local_mark_operation. Example: 'my-shop' or null"),
|
|
86
|
+
role: z.enum([
|
|
87
|
+
"Permission", "Guard", "Machine", "Progress", "Service", "Order", "Allocation",
|
|
88
|
+
"Arbitration", "ArbCase", "Messenger", "Contact", "Demand", "Reward", "Personal",
|
|
89
|
+
"Repository", "Treasury", "Discount", "Other"
|
|
90
|
+
]).describe("Business role of the object in the dependency graph. Constraint: enum of 18 values. Relation: derived from objectType last segment; drives Plan/Verify Loop positioning. Example: 'Service'"),
|
|
91
|
+
relation: z.object({
|
|
92
|
+
parent: z.union([z.string(), z.null()]).optional().describe("Parent object ID, if this object belongs to another (e.g. Machine belongs to Service). Example: '0x123...' or null"),
|
|
93
|
+
relation_type: z.enum(["machine_of", "guard_of", "allocator_of", "permission_of", "progress_of", "allocation_of", "arb_of", "other"]).optional().describe("How this object relates to its parent. Example: 'machine_of'"),
|
|
94
|
+
}).optional().describe("Relationship to another object in the dependency graph"),
|
|
95
|
+
immutable: z.boolean().optional().describe("Whether the object has entered an immutable state (e.g. Service published). Constraint: true after publish. Example: true"),
|
|
96
|
+
}).strict().describe("An object tagged with its business role and relationship within the object dependency graph");
|
|
97
|
+
export const FundRoleSchema = z.object({
|
|
98
|
+
amount: z.string().describe("Amount change as stringified integer (smallest unit). Negative=spend, positive=receive. Example: '-10000000000'"),
|
|
99
|
+
coinType: z.string().describe("Coin type tag (format: {address}::{module}::{struct}). Example: '0x2::wow::WOW'"),
|
|
100
|
+
role: z.enum(["payment", "refund", "change", "compensation", "reward", "gas", "deposit", "release", "other"]).describe("Business role of this fund movement. Constraint: enum of 9 values. Relation: derived from operation context. Example: 'payment'"),
|
|
101
|
+
from: z.string().nullable().optional().describe("Sender address if known. Example: '0xabc...' or null"),
|
|
102
|
+
to: z.string().nullable().optional().describe("Recipient address if known. Example: '0xdef...' or null"),
|
|
103
|
+
}).strict().describe("A fund movement tagged with its business role");
|
|
104
|
+
export const NextActionSchema = z.object({
|
|
105
|
+
action: z.string().describe("Recommended next action. Example: 'add sales products'"),
|
|
106
|
+
reason: z.string().describe("Why this action is recommended. Example: 'Service has no products; customers cannot order'"),
|
|
107
|
+
tool: z.string().optional().describe("MCP tool to use, if applicable. Example: 'onchain_operations'"),
|
|
108
|
+
prerequisite: z.string().optional().describe("Condition that must hold before this action. Example: 'Service must be created first'"),
|
|
109
|
+
priority: z.enum(["required", "recommended", "optional"]).describe("Priority. Constraint: enum. Example: 'required'"),
|
|
110
|
+
}).strict().describe("A recommended next action with priority and rationale");
|
|
111
|
+
export const EventSemanticSchema = z.object({
|
|
112
|
+
event_type: z.string().describe("Raw on-chain event type tag. Example: '0x2::service::ServicePublishedEvent'"),
|
|
113
|
+
business_meaning: z.string().describe("Human-readable business meaning. Example: 'Service has been published and is now immutable'"),
|
|
114
|
+
category: z.enum(["lifecycle", "state_change", "fund_flow", "permission", "guard", "other"]).describe("Business category. Constraint: enum of 6 values. Example: 'lifecycle'"),
|
|
115
|
+
related_object: z.string().optional().describe("Object ID the event relates to, if extractable. Example: '0x123...'"),
|
|
116
|
+
side_effect: z.string().optional().describe("Side effect description for AI. Example: 'Customers can now place orders against this Service'"),
|
|
117
|
+
}).strict().describe("An on-chain event annotated with business semantics");
|
|
118
|
+
export const ExperienceSchema = z.object({
|
|
119
|
+
advice: z.string().optional().describe("Advice from past experience. Example: 'Last time you forgot to set buy_guard; add it before publishing'"),
|
|
120
|
+
avoid: z.array(z.string()).optional().describe("Pitfalls to avoid based on history. Example: ['Guard rejection on delivery_proof']"),
|
|
121
|
+
relevance: z.number().min(0).max(1).optional().describe("Relevance score 0-1 of the matched experience. Example: 0.85"),
|
|
122
|
+
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.");
|
|
124
|
+
export const ServiceStatusSchema = z.object({
|
|
125
|
+
active: z.array(z.string()).describe("Phase 2 services currently active (enabled). Example: ['confirm_gate','project_service','experience_layer']"),
|
|
126
|
+
inactive: z.array(z.string()).optional().describe("Phase 2 services currently inactive (can be toggled via config_operation). Example: ['harness','graph_persist']"),
|
|
127
|
+
}).strict().describe("Phase 2 runtime service status (populated when semantic_rich is enabled). Lets AI see which services are active in each response.");
|
|
128
|
+
export const CustomerReminderSchema = z.object({
|
|
129
|
+
id: z.string().describe("Reminder rule id. Example: 'high_risk_score'"),
|
|
130
|
+
stage: z.enum(["browse", "evaluate", "preorder", "in_progress", "complete", "after_sale"]).describe("Order lifecycle stage when this reminder fires. Example: 'evaluate'"),
|
|
131
|
+
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,强烈建议不购买'"),
|
|
133
|
+
action: z.string().optional().describe("Suggested next action. Example: 'require merchant to bind Arbitration before ordering'"),
|
|
134
|
+
}).strict().describe("A buyer-side reminder triggered at a specific order lifecycle stage (Phase 3 C-3).");
|
|
135
|
+
export const PreferenceMatchSchema = z.object({
|
|
136
|
+
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
|
+
}).strict().describe("Service-to-preference match result (Phase 3 C-2). 7-dimension scoring: price/time/region/brand/bargain/emotion/risk.");
|
|
140
|
+
export const CustomerAdviceSchema = z.object({
|
|
141
|
+
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
|
+
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
|
+
preference_match: PreferenceMatchSchema.optional().describe("Service-to-preference match (populated when user preferences exist). Example: {score:75, matches:[...], mismatches:[...]}"),
|
|
146
|
+
}).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
|
+
export const EvolutionContextSchema = z.object({
|
|
148
|
+
industry_signal: z.string().optional().describe("Industry evolution signal summary. Example: '行业健康度 82/100(healthy);累积 25 个行业信号'"),
|
|
149
|
+
evolution_advice: z.string().optional().describe("Evolution advice for the current operation. Example: '建议强制配置仲裁 + 赔偿金 + 交付 Guard'"),
|
|
150
|
+
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
|
+
health_score: z.number().min(0).max(100).optional().describe("Industry health score 0-100 if available. Example: 82"),
|
|
152
|
+
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
|
+
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: ['强化忠诚度飞轮','优化首单转化']"),
|
|
155
|
+
role: z.enum(["user", "merchant", "arbitrator"]).optional().describe("Phase 4 P4-6.C: Role used for advice routing. Example: 'merchant'"),
|
|
156
|
+
}).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.");
|
|
157
|
+
export const SemanticSummarySchema = z.object({
|
|
158
|
+
intent: z.string().describe("Inferred user intent / operation goal. Constraint: snake_case string. Relation: derived from operation_type + data signals. Example: 'publish_service'"),
|
|
159
|
+
status: z.enum(["success", "partial", "failed", "pending_input"]).describe("Business-level status (not raw tx status). 'pending_input' = needs Guard submission. Example: 'success'"),
|
|
160
|
+
summary: z.string().describe("One-sentence human-readable summary of what happened. AI should read this first. Example: 'Successfully published Service my-shop with Machine bound'"),
|
|
161
|
+
created: z.array(ObjectRoleSchema).optional().describe("Objects newly created in this operation, tagged with roles"),
|
|
162
|
+
modified: z.array(ObjectRoleSchema).optional().describe("Objects mutated in this operation, tagged with roles"),
|
|
163
|
+
released: z.array(FundRoleSchema).optional().describe("Fund movements in this operation, tagged with roles"),
|
|
164
|
+
events: z.array(EventSemanticSchema).optional().describe("On-chain events annotated with business semantics (S-8)"),
|
|
165
|
+
next_actions: z.array(NextActionSchema).optional().describe("Recommended next actions to drive the workflow forward"),
|
|
166
|
+
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)"),
|
|
168
|
+
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
|
+
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
|
+
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."),
|
|
171
|
+
}).strict().describe("Business semantic summary: translates the raw transaction response into AI-directly-understandable business meaning");
|
|
80
172
|
export const CallResponseErrorSchema = z.object({
|
|
81
|
-
type: z.literal("error").describe("
|
|
82
|
-
error: z.string(),
|
|
83
|
-
|
|
173
|
+
type: z.literal("error").describe("Discriminator for this result variant. Constraint: always 'error'. Example: 'error'"),
|
|
174
|
+
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"),
|
|
177
|
+
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
|
+
related_object: z.string().optional().describe("Object ID related to the error, if any. Example: '0x123...'"),
|
|
179
|
+
}).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.");
|
|
180
|
+
export const OperationPreviewSchema = z.object({
|
|
181
|
+
level: z.enum(["none", "standard", "amount", "publish", "irreversible"]).describe("Confirmation level. 'irreversible' = cannot be undone (arb verdict, payment). 'publish' = locks immutable fields. 'amount' = amount-sensitive. 'standard' = default-value warnings."),
|
|
182
|
+
operation: z.string().describe("operation_type that triggered the gate. Example: 'payment'"),
|
|
183
|
+
object: z.union([z.string(), z.record(z.any()), z.null()]).optional().describe("Object name/id involved (string for existing, object for new creation). Example: 'myshop_service' or {name: 'myshop_service'}"),
|
|
184
|
+
network: z.string().optional().describe("Network in use. Example: 'mainnet'"),
|
|
185
|
+
account: z.string().optional().describe("Signing account ('' = default). Example: '' or '0xabc...'"),
|
|
186
|
+
amount: z.object({
|
|
187
|
+
value: z.string().describe("Smallest-unit value as string. Example: '2500000000'"),
|
|
188
|
+
token: z.string().describe("Coin type tag. Example: '0x2::wow::WOW'"),
|
|
189
|
+
human_readable: z.string().describe("Human-readable amount. Example: '2.5 WOW'"),
|
|
190
|
+
recipient: z.string().optional().describe("Recipient address if known. Example: '0xdef...'"),
|
|
191
|
+
}).optional().describe("Amount info for amount-level confirmations."),
|
|
192
|
+
immutable_after: z.array(z.string()).optional().describe("Fields that become immutable after this op (for publish). Example: ['machine','order_allocators']"),
|
|
193
|
+
warnings: z.array(z.string()).optional().describe("Default-value warnings. Example: ['Using default account (env.account=\"\")']"),
|
|
194
|
+
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).");
|
|
196
|
+
export const CallPendingConfirmationSchema = z.object({
|
|
197
|
+
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
|
+
preview: OperationPreviewSchema.describe("Preview of the operation awaiting confirmation."),
|
|
199
|
+
rule_id: z.string().optional().describe("Id of the confirmation rule that matched. Example: 'publish_immutable'"),
|
|
200
|
+
}).describe("Pending confirmation. The ConfirmGate blocked the operation. Read preview first; if user consents, re-invoke the SAME call with env.confirmed=true.");
|
|
84
201
|
export const GuardSubmissionToFillSchema = z.object({
|
|
85
|
-
guard: NameOrAddressSchema.describe("Guard object name or ID."),
|
|
86
|
-
submission: z.array(GuardTableItemSchema).describe("User-submitted data required
|
|
87
|
-
}).strict().describe("
|
|
202
|
+
guard: NameOrAddressSchema.describe("Guard object name or ID that requires submission data. Example: 'my-delivery-guard'"),
|
|
203
|
+
submission: z.array(GuardTableItemSchema).describe("User-submitted data matching the Guard's required fields. Relation: structure must match the Guard table's column definitions. Example: [{field:'delivery_proof', value:'Qm...'}]"),
|
|
204
|
+
}).strict().describe("One Guard's submission data: the Guard to verify plus the user-provided data that satisfies its requirements.");
|
|
88
205
|
export const SubmissionCallSchema = z.object({
|
|
89
|
-
type: z.literal("submission").describe("
|
|
206
|
+
type: z.literal("submission").describe("Discriminator for this result variant. Constraint: always 'submission'. Example: 'submission'"),
|
|
90
207
|
guard: z.array(z.object({
|
|
91
|
-
object: NameOrAddressSchema.describe("Guard object name or ID."),
|
|
92
|
-
impack: z.boolean().describe("Whether
|
|
93
|
-
}).strict()),
|
|
94
|
-
submission: z.array(GuardSubmissionToFillSchema),
|
|
95
|
-
}).strict().describe("Guard verification
|
|
208
|
+
object: NameOrAddressSchema.describe("Guard object name or ID to verify against. Example: 'my-delivery-guard' or '0x123...'"),
|
|
209
|
+
impack: z.boolean().describe("Whether this Guard's verification result participates in the final logic. Constraint: if false, the Guard is checked but does not block the operation. Example: true"),
|
|
210
|
+
}).strict()).describe("Array of Guard objects to verify. Relation: each entry corresponds to a Guard bound to the operation."),
|
|
211
|
+
submission: z.array(GuardSubmissionToFillSchema).describe("User-submitted data for each Guard. Relation: one entry per Guard in the guard array; fill submission fields and resubmit via call_with_submission."),
|
|
212
|
+
}).strict().describe("Guard verification required. The operation was blocked because one or more Guards require user-submitted data. Fill the submission array and resubmit. Semantic status is 'pending_input'.");
|
|
96
213
|
export const TypedPermissionObjectSchema = z.union([
|
|
97
214
|
NameOrAddressSchema.describe("String format: Reference an EXISTING object by its name (local mark) or on-chain object ID. Use this when the object already exists and you want to reference it."),
|
|
98
215
|
TypeNamedObjectWithPermissionSchema.describe("Object format: CREATE a NEW object with COMPLETE configuration including: optional name, tags, description, token type for payments (e.g., '0x2::wow::WOW'), AND Permission-based access control. Use this for creating sophisticated objects with both payment token specification and permission management."),
|
|
@@ -108,17 +225,18 @@ export const TypedDescriptionObjectSchema = z.union([
|
|
|
108
225
|
export const CallResultSchema = z.discriminatedUnion("type", [
|
|
109
226
|
SubmissionCallSchema,
|
|
110
227
|
WowTransactionBlockResponseSchema.extend({
|
|
111
|
-
type: z.literal("transaction"),
|
|
228
|
+
type: z.literal("transaction").describe("Discriminator for this result variant. Constraint: always 'transaction'. Example: 'transaction'"),
|
|
112
229
|
}),
|
|
113
230
|
CallResponseErrorSchema,
|
|
114
231
|
z.object({
|
|
115
|
-
type: z.literal("data"),
|
|
116
|
-
data: z.array(ResponseDataSchema),
|
|
232
|
+
type: z.literal("data").describe("Discriminator for this result variant. Constraint: always 'data'. Example: 'data'"),
|
|
233
|
+
data: z.array(ResponseDataSchema).describe("Array of object records returned by a query operation. Example: [{id:'0x...', change:'created'}]"),
|
|
117
234
|
}),
|
|
118
235
|
z.object({
|
|
119
|
-
type: z.literal("null"),
|
|
236
|
+
type: z.literal("null").describe("Discriminator for this result variant. Constraint: always 'null'. Example: 'null'"),
|
|
120
237
|
}),
|
|
121
|
-
|
|
238
|
+
CallPendingConfirmationSchema,
|
|
239
|
+
]).describe("Discriminated union of 6 result types: 'transaction' (raw Sui response), 'submission' (Guard verification needed), 'error' (failed with error_code), 'data' (query result array), 'null' (no-op completed), 'pending_confirmation' (ConfirmGate blocked — re-call with env.confirmed=true). AI should check result.type first to determine how to process the response.");
|
|
122
240
|
export const ObjectsSchema = z.union([
|
|
123
241
|
z.object({
|
|
124
242
|
op: z.union([z.literal('add'), z.literal('set')]),
|
|
@@ -132,7 +250,35 @@ export const ObjectsSchema = z.union([
|
|
|
132
250
|
op: z.literal('clear'),
|
|
133
251
|
}).strict(),
|
|
134
252
|
]);
|
|
253
|
+
export const VerifyMismatchSchema = z.object({
|
|
254
|
+
dimension: z.enum(["created", "modified", "released", "state", "event"]).describe("Verify dimension that mismatched. Example: 'created'"),
|
|
255
|
+
expected: z.string().describe("What the Expect Loop declared. Example: 'Service object created'"),
|
|
256
|
+
actual: z.string().describe("What actually happened. Example: 'No object created'"),
|
|
257
|
+
severity: z.enum(["pass", "warn", "fail"]).describe("Severity: 'fail' blocks progress, 'warn' is advisory, 'pass' never appears here. Example: 'fail'"),
|
|
258
|
+
detail: z.string().describe("Human-readable explanation of the mismatch. Example: 'Expected Service creation but transaction succeeded without object change'"),
|
|
259
|
+
}).describe("One mismatch between expected and actual result. AI should read severity first to decide whether to halt.");
|
|
260
|
+
export const VerifyReportSchema = z.object({
|
|
261
|
+
status: z.enum(["pass", "warn", "fail"]).describe("Overall verify status. Constraint: 'fail' if any mismatch has severity 'fail'; 'warn' if only warns; 'pass' if no mismatches. Example: 'fail'"),
|
|
262
|
+
mismatches: z.array(VerifyMismatchSchema).describe("List of mismatches found. Empty array when status is 'pass'. Example: [{dimension:'created', expected:'...', actual:'...', severity:'fail', detail:'...'}]"),
|
|
263
|
+
summary: z.string().describe("Human-readable summary of the verify result. Example: '2 mismatches found: created dimension failed, event dimension warned'"),
|
|
264
|
+
timestamp: z.string().describe("ISO 8601 timestamp when verify ran. Example: '2026-07-14T10:30:00.000Z'"),
|
|
265
|
+
}).describe("Verify Loop report. Compares expected vs actual semantic fields across 5 dimensions. When status is 'fail', AI should consult the recovery_action in the parent harness_report.");
|
|
266
|
+
export const RecoveryActionSchema = z.object({
|
|
267
|
+
strategy: z.enum(["retry", "claim_faucet", "fill_submission", "recreate", "switch_account", "query_and_retry", "adjust_params", "escalate_human", "stop"]).describe("Recovery strategy chosen by the Recover Loop. Constraint: 9 strategies matching error_code table. Example: 'claim_faucet'"),
|
|
268
|
+
should_retry: z.boolean().describe("Whether AI should retry the original operation after applying the strategy. Constraint: false for 'stop' and 'escalate_human'. Example: true"),
|
|
269
|
+
adjusted_params: z.record(z.string(), z.unknown()).optional().describe("Suggested parameter adjustments for 'adjust_params' strategy. Example: {amount: '100000000'}"),
|
|
270
|
+
user_prompt: z.string().optional().describe("Prompt to show the user when recovery is semi-automatic or manual. Example: 'Please switch to an account with provider permission'"),
|
|
271
|
+
max_attempts: z.number().int().describe("Maximum attempts for this error_code type. Example: 3"),
|
|
272
|
+
current_attempt: z.number().int().describe("Current attempt count (1-indexed). Example: 1"),
|
|
273
|
+
detail: z.string().describe("Human-readable explanation of the recovery decision. Example: 'Insufficient balance detected; claim faucet tokens then retry'"),
|
|
274
|
+
}).describe("Recover Loop action. Generated when verify fails or an error occurs. AI should follow the strategy and respect max_attempts.");
|
|
275
|
+
export const HarnessReportSchema = z.object({
|
|
276
|
+
verify: VerifyReportSchema.describe("Verify Loop report comparing expected vs actual."),
|
|
277
|
+
recovery: RecoveryActionSchema.optional().describe("Recover Loop action. Present only when verify.status is 'fail' or 'warn', or when an error occurred."),
|
|
278
|
+
}).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.");
|
|
135
279
|
export const CallOutputSchema = z.object({
|
|
136
|
-
result: CallResultSchema,
|
|
137
|
-
message: z.string().optional().describe("
|
|
138
|
-
|
|
280
|
+
result: CallResultSchema.describe("Discriminated result. Check result.type first: 'transaction'|'submission'|'error'|'data'|'null'. Each variant has different fields."),
|
|
281
|
+
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
|
+
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
|
+
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'}}"),
|
|
284
|
+
}).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'.");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BridgeClient, LocalMark, } from "@wowok/wowok";
|
|
2
|
+
import { classifyError, buildSemantic, buildDataSemantic } from "./semantic.js";
|
|
2
3
|
let _bridgeClient = null;
|
|
3
4
|
let _bridgeClientEnv = null;
|
|
4
5
|
function getBridgeClient(env) {
|
|
@@ -56,9 +57,10 @@ function convertBigInts(obj) {
|
|
|
56
57
|
}
|
|
57
58
|
return obj;
|
|
58
59
|
}
|
|
59
|
-
function ok(message, result) {
|
|
60
|
+
function ok(message, result, context) {
|
|
60
61
|
const safeResult = convertBigInts(result);
|
|
61
|
-
const
|
|
62
|
+
const semantic = buildSemantic(safeResult, context);
|
|
63
|
+
const output = { message, result: { type: "data", data: safeResult }, semantic };
|
|
62
64
|
return {
|
|
63
65
|
content: [
|
|
64
66
|
{ type: "text", text: message },
|
|
@@ -67,8 +69,20 @@ function ok(message, result) {
|
|
|
67
69
|
structuredContent: output,
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
|
-
function err(message) {
|
|
71
|
-
const
|
|
72
|
+
function err(message, context) {
|
|
73
|
+
const classified = classifyError(message);
|
|
74
|
+
const semantic = buildDataSemantic(undefined, context, true, message);
|
|
75
|
+
const output = {
|
|
76
|
+
message,
|
|
77
|
+
result: {
|
|
78
|
+
type: "error",
|
|
79
|
+
error: message,
|
|
80
|
+
error_code: classified.error_code,
|
|
81
|
+
retryable: classified.retryable,
|
|
82
|
+
recovery_hint: classified.recovery_hint,
|
|
83
|
+
},
|
|
84
|
+
semantic,
|
|
85
|
+
};
|
|
72
86
|
return {
|
|
73
87
|
content: [{ type: "text", text: message }],
|
|
74
88
|
structuredContent: output,
|
|
@@ -87,6 +101,10 @@ export async function handleBridgeOperations(args) {
|
|
|
87
101
|
return err(`Parameter validation failed: ${e?.message ?? String(e)}`);
|
|
88
102
|
}
|
|
89
103
|
const env = validated.env;
|
|
104
|
+
const ctx = {
|
|
105
|
+
operation_type: "bridge_" + validated.operation_type,
|
|
106
|
+
data: validated.data,
|
|
107
|
+
};
|
|
90
108
|
try {
|
|
91
109
|
switch (validated.operation_type) {
|
|
92
110
|
case "cross_chain_wow_to_evm": {
|
|
@@ -100,7 +118,7 @@ export async function handleBridgeOperations(args) {
|
|
|
100
118
|
waitForFinalization: false,
|
|
101
119
|
});
|
|
102
120
|
return ok(`WOW→EVM cross-chain step 1 (deposit) submitted. transferId=${result.transferId}, activeEvmAccount=${result.activeEvmAccount}. ` +
|
|
103
|
-
`Next: poll query_transfer_status until bridge signs (~1-5 min), then call claim_wow_to_evm to complete.`, result);
|
|
121
|
+
`Next: poll query_transfer_status until bridge signs (~1-5 min), then call claim_wow_to_evm to complete.`, result, ctx);
|
|
104
122
|
}
|
|
105
123
|
case "cross_chain_evm_to_wow": {
|
|
106
124
|
validateMainnet(env);
|
|
@@ -114,14 +132,14 @@ export async function handleBridgeOperations(args) {
|
|
|
114
132
|
waitForFinalization: false,
|
|
115
133
|
});
|
|
116
134
|
return ok(`EVM→WOW cross-chain submitted. transferId=${result.transferId}, activeEvmAccount=${result.activeEvmAccount}. ` +
|
|
117
|
-
`Bridge will auto-claim on WOW (~10-20 min). Poll query_transfer_status to monitor progress.`, result);
|
|
135
|
+
`Bridge will auto-claim on WOW (~10-20 min). Poll query_transfer_status to monitor progress.`, result, ctx);
|
|
118
136
|
}
|
|
119
137
|
case "claim_wow_to_evm": {
|
|
120
138
|
validateMainnet(env);
|
|
121
139
|
const data = validated.data;
|
|
122
140
|
const client = getBridgeClient(env);
|
|
123
141
|
const result = await client.claimWowToEvm(data.transferId);
|
|
124
|
-
return ok(`WOW→EVM claim (step 2) completed. transferId=${result.transferId}, claimTxHash=${result.claimTxHash}`, result);
|
|
142
|
+
return ok(`WOW→EVM claim (step 2) completed. transferId=${result.transferId}, claimTxHash=${result.claimTxHash}`, result, ctx);
|
|
125
143
|
}
|
|
126
144
|
case "withdraw": {
|
|
127
145
|
const data = validated.data;
|
|
@@ -133,7 +151,7 @@ export async function handleBridgeOperations(args) {
|
|
|
133
151
|
const tokenMeta = chain?.tokens?.find((t) => t.symbol === data.token);
|
|
134
152
|
tokenAddress = tokenMeta?.evmAddress;
|
|
135
153
|
if (!tokenAddress) {
|
|
136
|
-
return err(`Cannot resolve ERC20 token address for symbol '${data.token}' on chain '${data.network ?? "mainnet"}'. Please pass tokenAddress explicitly
|
|
154
|
+
return err(`Cannot resolve ERC20 token address for symbol '${data.token}' on chain '${data.network ?? "mainnet"}'. Please pass tokenAddress explicitly.`, ctx);
|
|
137
155
|
}
|
|
138
156
|
}
|
|
139
157
|
const result = await client.withdrawFromActiveEvmAccount({
|
|
@@ -143,7 +161,7 @@ export async function handleBridgeOperations(args) {
|
|
|
143
161
|
token: data.token ? data.token : undefined,
|
|
144
162
|
network: data.network,
|
|
145
163
|
});
|
|
146
|
-
return ok(`Withdrawal submitted. transferId=${result.transferId}, txHash=${result.txHash}`, result);
|
|
164
|
+
return ok(`Withdrawal submitted. transferId=${result.transferId}, txHash=${result.txHash}`, result, ctx);
|
|
147
165
|
}
|
|
148
166
|
case "query_active_evm_account": {
|
|
149
167
|
const data = validated.data ?? {};
|
|
@@ -152,12 +170,12 @@ export async function handleBridgeOperations(args) {
|
|
|
152
170
|
network: data.network,
|
|
153
171
|
tokens: data.tokens,
|
|
154
172
|
});
|
|
155
|
-
return ok(`activeEvmAccount: ${result.address} (${result.chains.length} chain(s))`, result);
|
|
173
|
+
return ok(`activeEvmAccount: ${result.address} (${result.chains.length} chain(s))`, result, ctx);
|
|
156
174
|
}
|
|
157
175
|
case "query_supported_evm_chains": {
|
|
158
176
|
const client = getBridgeClientForQuery();
|
|
159
177
|
const result = await client.querySupportedEvmChains();
|
|
160
|
-
return ok(`${result.length} EVM chain(s) supported: ${result.map(c => `${c.name}(chainId=${c.chainId})`).join(", ")}`, result);
|
|
178
|
+
return ok(`${result.length} EVM chain(s) supported: ${result.map(c => `${c.name}(chainId=${c.chainId})`).join(", ")}`, result, ctx);
|
|
161
179
|
}
|
|
162
180
|
case "query_supported_tokens": {
|
|
163
181
|
const data = validated.data ?? {};
|
|
@@ -166,7 +184,7 @@ export async function handleBridgeOperations(args) {
|
|
|
166
184
|
network: data.network,
|
|
167
185
|
});
|
|
168
186
|
const totalTokens = result.reduce((sum, c) => sum + c.tokens.length, 0);
|
|
169
|
-
return ok(`${result.length} chain(s), ${totalTokens} token entries: ${result.map((c) => `${c.chainName}(${c.tokens.length} tokens)`).join(", ")}`, result);
|
|
187
|
+
return ok(`${result.length} chain(s), ${totalTokens} token entries: ${result.map((c) => `${c.chainName}(${c.tokens.length} tokens)`).join(", ")}`, result, ctx);
|
|
170
188
|
}
|
|
171
189
|
case "query_transfer_list": {
|
|
172
190
|
const data = validated.data ?? {};
|
|
@@ -187,7 +205,7 @@ export async function handleBridgeOperations(args) {
|
|
|
187
205
|
result = result.slice(0, data.limit);
|
|
188
206
|
}
|
|
189
207
|
const active = result.filter(r => r.status !== "success" && r.status !== "failed").length;
|
|
190
|
-
return ok(`${result.length} transfer record(s) (${active} in progress)${data.status || data.direction || data.token ? " (filtered)" : ""}`, result);
|
|
208
|
+
return ok(`${result.length} transfer record(s) (${active} in progress)${data.status || data.direction || data.token ? " (filtered)" : ""}`, result, ctx);
|
|
191
209
|
}
|
|
192
210
|
case "query_transfer_status": {
|
|
193
211
|
const data = validated.data;
|
|
@@ -208,9 +226,9 @@ export async function handleBridgeOperations(args) {
|
|
|
208
226
|
return err(`transferId '${data.transferId}' not found. ` +
|
|
209
227
|
`Use query_transfer_list to see all valid transferIds. ` +
|
|
210
228
|
`Note: transfer history is persisted in cache.db and restored on MCP restart, ` +
|
|
211
|
-
`so this transferId may never have been created in this environment
|
|
229
|
+
`so this transferId may never have been created in this environment.`, ctx);
|
|
212
230
|
}
|
|
213
|
-
return ok(`Transfer ${data.transferId}: ${result.direction} / ${result.step} / ${result.status}`, result);
|
|
231
|
+
return ok(`Transfer ${data.transferId}: ${result.direction} / ${result.step} / ${result.status}`, result, ctx);
|
|
214
232
|
}
|
|
215
233
|
case "manage_evm_rpc": {
|
|
216
234
|
const data = validated.data;
|
|
@@ -220,15 +238,15 @@ export async function handleBridgeOperations(args) {
|
|
|
220
238
|
network: data.network,
|
|
221
239
|
rpcUrls: data.rpcUrls,
|
|
222
240
|
});
|
|
223
|
-
return ok(`RPC '${data.op}' operation ${result.success ? "succeeded" : "failed"}`, result);
|
|
241
|
+
return ok(`RPC '${data.op}' operation ${result.success ? "succeeded" : "failed"}`, result, ctx);
|
|
224
242
|
}
|
|
225
243
|
default: {
|
|
226
|
-
return err(`Unsupported operation_type: ${validated.operation_type}
|
|
244
|
+
return err(`Unsupported operation_type: ${validated.operation_type}`, ctx);
|
|
227
245
|
}
|
|
228
246
|
}
|
|
229
247
|
}
|
|
230
248
|
catch (e) {
|
|
231
249
|
const msg = e?.message ?? String(e);
|
|
232
|
-
return err(`Bridge operation failed: ${msg}
|
|
250
|
+
return err(`Bridge operation failed: ${msg}`, ctx);
|
|
233
251
|
}
|
|
234
252
|
}
|