@wowok/agent-mcp 2.3.18 → 2.4.3

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 (121) hide show
  1. package/dist/customer/industry-risks.js +31 -31
  2. package/dist/customer/order-monitor.js +57 -57
  3. package/dist/customer/order-strategy.js +89 -89
  4. package/dist/customer/post-purchase.js +97 -97
  5. package/dist/customer/reminder-system.js +26 -26
  6. package/dist/customer/risk-assessment.js +46 -46
  7. package/dist/customer/types.d.ts +4 -4
  8. package/dist/customer/types.js +4 -4
  9. package/dist/customer/user-preferences.js +50 -50
  10. package/dist/experience/intent-distill.js +6 -6
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +11 -1624
  13. package/dist/knowledge/acquisition-flywheel.js +64 -64
  14. package/dist/knowledge/arbitration-trust.js +10 -10
  15. package/dist/knowledge/demand-matching.js +8 -8
  16. package/dist/knowledge/dynamic-pricing.js +18 -18
  17. package/dist/knowledge/flywheel-loop.js +11 -11
  18. package/dist/knowledge/glossary.js +22 -22
  19. package/dist/knowledge/guard-ledger.d.ts +1 -1
  20. package/dist/knowledge/guard-ledger.js +145 -104
  21. package/dist/knowledge/guard-lint.d.ts +77 -0
  22. package/dist/knowledge/guard-lint.js +670 -0
  23. package/dist/knowledge/guard-migration.d.ts +48 -0
  24. package/dist/knowledge/guard-migration.js +228 -0
  25. package/dist/knowledge/guard-puzzle.d.ts +109 -14
  26. package/dist/knowledge/guard-puzzle.js +627 -101
  27. package/dist/knowledge/guard-risk.d.ts +10 -1
  28. package/dist/knowledge/guard-risk.js +1634 -292
  29. package/dist/knowledge/guard-templates.d.ts +38 -0
  30. package/dist/knowledge/guard-templates.js +605 -0
  31. package/dist/knowledge/guard-translation.d.ts +14 -2
  32. package/dist/knowledge/guard-translation.js +825 -194
  33. package/dist/knowledge/index.d.ts +8 -4
  34. package/dist/knowledge/index.js +9 -5
  35. package/dist/knowledge/industry-evolution.js +29 -29
  36. package/dist/knowledge/industry-generalizer.js +52 -52
  37. package/dist/knowledge/industry-registry.js +20 -33
  38. package/dist/knowledge/intent-metrics.js +67 -67
  39. package/dist/knowledge/process-model.js +80 -80
  40. package/dist/knowledge/reputation-rules.js +9 -9
  41. package/dist/knowledge/reward-templates.js +51 -51
  42. package/dist/knowledge/safety-rules.js +3 -3
  43. package/dist/knowledge/tool-constraints.js +20 -4
  44. package/dist/knowledge/trust-metrics.js +26 -26
  45. package/dist/project/graph.d.ts +1 -0
  46. package/dist/project/graph.js +27 -1
  47. package/dist/project/index.d.ts +1 -0
  48. package/dist/project/index.js +39 -2
  49. package/dist/project/namespace.d.ts +11 -1
  50. package/dist/project/namespace.js +27 -2
  51. package/dist/project/query.d.ts +2 -0
  52. package/dist/project/query.js +56 -15
  53. package/dist/rules.d.ts +12 -0
  54. package/dist/rules.js +9 -0
  55. package/dist/schema/call/allocation.d.ts +10 -10
  56. package/dist/schema/call/base.js +19 -19
  57. package/dist/schema/call/bridge.d.ts +32 -32
  58. package/dist/schema/call/demand.d.ts +84 -84
  59. package/dist/schema/call/guard.d.ts +153 -0
  60. package/dist/schema/call/guard.js +50 -0
  61. package/dist/schema/call/machine.d.ts +38 -38
  62. package/dist/schema/call/permission.d.ts +78 -78
  63. package/dist/schema/call/repository.d.ts +22 -22
  64. package/dist/schema/call/semantic.js +229 -25
  65. package/dist/schema/call/service.d.ts +7 -7
  66. package/dist/schema/local/wip.d.ts +39 -19
  67. package/dist/schema/local/wip.js +5 -5
  68. package/dist/schema/messenger/index.d.ts +26 -26
  69. package/dist/schema/messenger/index.js +2 -2
  70. package/dist/schema/operations.d.ts +270 -192
  71. package/dist/schema/query/index.d.ts +184 -184
  72. package/dist/schema/query/index.js +15 -9
  73. package/dist/schema/trust/index.d.ts +4 -4
  74. package/dist/schema/utils/guard-parser.js +4 -4
  75. package/dist/schema/utils/guard-query-utils.d.ts +7 -0
  76. package/dist/schema/utils/guard-query-utils.js +14 -1
  77. package/dist/schema/utils/node-parser.js +14 -14
  78. package/dist/schemas/bridge_operation.output.json +15 -15
  79. package/dist/schemas/index.json +1 -1
  80. package/dist/schemas/messenger_operation.output.json +18 -16
  81. package/dist/schemas/onchain_events.output.json +15 -15
  82. package/dist/schemas/onchain_operations.output.json +16 -16
  83. package/dist/schemas/onchain_operations.schema.json +11 -20
  84. package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
  85. package/dist/schemas/onchain_operations_machine.schema.json +2 -5
  86. package/dist/schemas/onchain_operations_service.schema.json +2 -5
  87. package/dist/schemas/onchain_table_data.output.json +20 -26
  88. package/dist/schemas/wip_file.output.json +24 -1
  89. package/dist/tools/handlers/bridge.d.ts +1 -0
  90. package/dist/tools/handlers/bridge.js +1 -0
  91. package/dist/tools/handlers/config.d.ts +2 -0
  92. package/dist/tools/handlers/config.js +71 -0
  93. package/dist/tools/handlers/file-export.d.ts +3 -0
  94. package/dist/tools/handlers/file-export.js +90 -0
  95. package/dist/tools/handlers/local.d.ts +30 -0
  96. package/dist/tools/handlers/local.js +27 -0
  97. package/dist/tools/handlers/messenger.d.ts +16 -0
  98. package/dist/tools/handlers/messenger.js +187 -0
  99. package/dist/tools/handlers/onchain.d.ts +2 -0
  100. package/dist/tools/handlers/onchain.js +246 -0
  101. package/dist/tools/handlers/project.d.ts +2 -0
  102. package/dist/tools/handlers/project.js +53 -0
  103. package/dist/tools/handlers/query.d.ts +5 -0
  104. package/dist/tools/handlers/query.js +256 -0
  105. package/dist/tools/handlers/schema-query.d.ts +2 -0
  106. package/dist/tools/handlers/schema-query.js +92 -0
  107. package/dist/tools/handlers/trust.d.ts +2 -0
  108. package/dist/tools/handlers/trust.js +194 -0
  109. package/dist/tools/handlers/wip.d.ts +2 -0
  110. package/dist/tools/handlers/wip.js +44 -0
  111. package/dist/tools/index.d.ts +13 -0
  112. package/dist/tools/index.js +479 -0
  113. package/dist/tools/rules-hook.d.ts +2 -0
  114. package/dist/tools/rules-hook.js +22 -0
  115. package/dist/tools/shared.d.ts +29 -0
  116. package/dist/tools/shared.js +130 -0
  117. package/dist/tools/types.d.ts +35 -0
  118. package/dist/tools/types.js +1 -0
  119. package/dist/tools/wrap.d.ts +6 -0
  120. package/dist/tools/wrap.js +55 -0
  121. package/package.json +19 -5
@@ -1589,6 +1589,7 @@
1589
1589
  "number",
1590
1590
  "string"
1591
1591
  ],
1592
+ "default": 0,
1592
1593
  "description": "Threshold to trigger node advancement. If total Forward weight is greater than or equal to threshold, node advancement is triggered."
1593
1594
  },
1594
1595
  "forwards": {
@@ -1652,10 +1653,7 @@
1652
1653
  {
1653
1654
  "type": "array",
1654
1655
  "items": {
1655
- "type": [
1656
- "number",
1657
- "string"
1658
- ]
1656
+ "$ref": "#/definitions/onchain_table_data/properties/result/anyOf/8/properties/result/anyOf/0/properties/value/items/properties/threshold"
1659
1657
  }
1660
1658
  },
1661
1659
  {
@@ -1690,7 +1688,6 @@
1690
1688
  },
1691
1689
  "required": [
1692
1690
  "prev_node",
1693
- "threshold",
1694
1691
  "forwards"
1695
1692
  ],
1696
1693
  "additionalProperties": false,
@@ -1881,18 +1878,15 @@
1881
1878
  "description": "Total operation weight"
1882
1879
  },
1883
1880
  "threshold": {
1884
- "type": [
1885
- "number",
1886
- "string"
1887
- ],
1881
+ "$ref": "#/definitions/onchain_table_data/properties/result/anyOf/8/properties/result/anyOf/0/properties/value/items/properties/threshold",
1882
+ "default": 0,
1888
1883
  "description": "Operation threshold. When total operation weight exceeds threshold, session is considered completed and Progress moves from current node to next node."
1889
1884
  }
1890
1885
  },
1891
1886
  "required": [
1892
1887
  "next_node",
1893
1888
  "forwards",
1894
- "weights",
1895
- "threshold"
1889
+ "weights"
1896
1890
  ],
1897
1891
  "additionalProperties": false,
1898
1892
  "description": "Progress session"
@@ -2359,7 +2353,7 @@
2359
2353
  }
2360
2354
  },
2361
2355
  "additionalProperties": false,
2362
- "description": "Experience layer feedback from past operations (Phase 2 议题 2)"
2356
+ "description": "Experience layer feedback from past operations (Phase 2 Topic 2)"
2363
2357
  },
2364
2358
  "service_status": {
2365
2359
  "type": "object",
@@ -2409,7 +2403,7 @@
2409
2403
  "items": {
2410
2404
  "type": "string"
2411
2405
  },
2412
- "description": "Actionable recommendations for the buyer. Example: ['要求商家配置仲裁','通过 Messenger 协商退款条款']"
2406
+ "description": "Actionable recommendations for the buyer. Example: ['Require merchant to configure arbitration','Negotiate refund terms via Messenger']"
2413
2407
  },
2414
2408
  "reminders": {
2415
2409
  "type": "array",
@@ -2444,7 +2438,7 @@
2444
2438
  },
2445
2439
  "message": {
2446
2440
  "type": "string",
2447
- "description": "Human-readable reminder message. Example: '🔴 综合风险分 25/100,强烈建议不购买'"
2441
+ "description": "Human-readable reminder message. Example: 'Composite risk score 25/100, strongly discourage purchase'"
2448
2442
  },
2449
2443
  "action": {
2450
2444
  "type": "string",
@@ -2460,7 +2454,7 @@
2460
2454
  "additionalProperties": false,
2461
2455
  "description": "A buyer-side reminder triggered at a specific order lifecycle stage (Phase 3 C-3)."
2462
2456
  },
2463
- "description": "Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'🔴 模糊 Guard 必须人工审查'}]"
2457
+ "description": "Stage-specific reminders (deduped, sorted by priority, capped to 3 high-risk). Example: [{priority:'required', message:'Ambiguous Guard must be human-reviewed'}]"
2464
2458
  },
2465
2459
  "preference_match": {
2466
2460
  "type": "object",
@@ -2476,14 +2470,14 @@
2476
2470
  "items": {
2477
2471
  "type": "string"
2478
2472
  },
2479
- "description": "Aspects that match user preferences. Example: ['价格低于均价 10%','有仲裁']"
2473
+ "description": "Aspects that match user preferences. Example: ['Price 10% below average','Has arbitration']"
2480
2474
  },
2481
2475
  "mismatches": {
2482
2476
  "type": "array",
2483
2477
  "items": {
2484
2478
  "type": "string"
2485
2479
  },
2486
- "description": "Aspects that mismatch user preferences. Example: ['交付周期超出期望']"
2480
+ "description": "Aspects that mismatch user preferences. Example: ['Delivery cycle exceeds expectation']"
2487
2481
  }
2488
2482
  },
2489
2483
  "required": [
@@ -2507,11 +2501,11 @@
2507
2501
  "properties": {
2508
2502
  "industry_signal": {
2509
2503
  "type": "string",
2510
- "description": "Industry evolution signal summary. Example: '行业健康度 82/100healthy);累积 25 个行业信号'"
2504
+ "description": "Industry evolution signal summary. Example: 'Industry health 82/100 (healthy); 25 cumulative industry signals'"
2511
2505
  },
2512
2506
  "evolution_advice": {
2513
2507
  "type": "string",
2514
- "description": "Evolution advice for the current operation. Example: '建议强制配置仲裁 + 赔偿金 + 交付 Guard'"
2508
+ "description": "Evolution advice for the current operation. Example: 'Recommend mandatory arbitration + compensation fund + delivery Guard'"
2515
2509
  },
2516
2510
  "confidence": {
2517
2511
  "type": "number",
@@ -2548,7 +2542,7 @@
2548
2542
  "items": {
2549
2543
  "type": "string"
2550
2544
  },
2551
- "description": "Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['强化忠诚度飞轮','优化首单转化']"
2545
+ "description": "Phase 4 P4-6.C: Role-targeted advice strings (user/merchant/arbitrator). Example: ['Strengthen loyalty flywheel','Optimize first-order conversion']"
2552
2546
  },
2553
2547
  "role": {
2554
2548
  "type": "string",
@@ -2630,21 +2624,21 @@
2630
2624
  },
2631
2625
  "scene_description": {
2632
2626
  "type": "string",
2633
- "description": "Human-readable scene description. Example: '工作流节点推进验证(Forward.guard'"
2627
+ "description": "Human-readable scene description. Example: 'Workflow node forward validation (Forward.guard)'"
2634
2628
  },
2635
2629
  "scene_constraints": {
2636
2630
  "type": "array",
2637
2631
  "items": {
2638
2632
  "type": "string"
2639
2633
  },
2640
- "description": "Special constraints for the matched scene. Example: ['Machine 发布后 Forward.guard 不可修改']"
2634
+ "description": "Special constraints for the matched scene. Example: ['Forward.guard cannot be modified after Machine is published']"
2641
2635
  },
2642
2636
  "suggested_patterns": {
2643
2637
  "type": "array",
2644
2638
  "items": {
2645
2639
  "type": "string"
2646
2640
  },
2647
- "description": "Suggested Guard patterns based on user intent. Example: ['时间锁','进度状态检查']"
2641
+ "description": "Suggested Guard patterns based on user intent. Example: ['time lock','progress status check']"
2648
2642
  },
2649
2643
  "available_queries": {
2650
2644
  "type": "array",
@@ -2657,7 +2651,7 @@
2657
2651
  },
2658
2652
  "name": {
2659
2653
  "type": "string",
2660
- "description": "Query instruction name. Example: 'progress.current_node_name'"
2654
+ "description": "Query instruction name. Example: 'progress.current'"
2661
2655
  },
2662
2656
  "objectType": {
2663
2657
  "type": "string",
@@ -2688,14 +2682,14 @@
2688
2682
  "items": {
2689
2683
  "type": "string"
2690
2684
  },
2691
- "description": "Risk warnings for the current Guard design. Example: ['Guard 创建后不可修改','时间锁测试用 1000ms']"
2685
+ "description": "Risk warnings for the current Guard design. Example: ['Guard cannot be modified after creation','Time lock test uses 1000ms']"
2692
2686
  },
2693
2687
  "pending_questions": {
2694
2688
  "type": "array",
2695
2689
  "items": {
2696
2690
  "type": "string"
2697
2691
  },
2698
- "description": "Questions for the user to complete the puzzle. Example: ['Guard 将绑定到哪个 Host Object']"
2692
+ "description": "Questions for the user to complete the puzzle. Example: ['Which Host Object will the Guard bind to?']"
2699
2693
  },
2700
2694
  "confirmation_text": {
2701
2695
  "type": "string",
@@ -50,7 +50,30 @@
50
50
  "type": "boolean"
51
51
  },
52
52
  "signatures": {
53
- "type": "array"
53
+ "type": "array",
54
+ "items": {
55
+ "type": "object",
56
+ "properties": {
57
+ "publicKey": {
58
+ "type": "string",
59
+ "description": "Signature public key"
60
+ },
61
+ "address": {
62
+ "type": "string",
63
+ "description": "Address derived from public key"
64
+ },
65
+ "valid": {
66
+ "type": "boolean",
67
+ "description": "Whether signature is valid"
68
+ }
69
+ },
70
+ "required": [
71
+ "publicKey",
72
+ "valid"
73
+ ],
74
+ "additionalProperties": false,
75
+ "description": "Single signature verification result"
76
+ }
54
77
  }
55
78
  },
56
79
  "required": [
@@ -0,0 +1 @@
1
+ export { handleBridgeOperations } from "../../schema/call/bridge-handler.js";
@@ -0,0 +1 @@
1
+ export { handleBridgeOperations } from "../../schema/call/bridge-handler.js";
@@ -0,0 +1,2 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function handleConfigOperation(args: any): Promise<ToolDispatchResult>;
@@ -0,0 +1,71 @@
1
+ import { listServices, getServiceInfo, toggle as toggleService, setEnabled as setServiceEnabled, reset as resetService, } from "../../config/index.js";
2
+ export async function handleConfigOperation(args) {
3
+ const action = args.action;
4
+ let result;
5
+ switch (action) {
6
+ case "list":
7
+ result = { services: listServices() };
8
+ break;
9
+ case "toggle": {
10
+ const service = args.service;
11
+ if (!service)
12
+ throw new Error("'service' param is required for toggle");
13
+ const existing = getServiceInfo(service);
14
+ if (!existing) {
15
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
16
+ }
17
+ const newState = toggleService(service);
18
+ result = { service, enabled: newState, reminder: existing.reminder };
19
+ break;
20
+ }
21
+ case "enable": {
22
+ const service = args.service;
23
+ if (!service)
24
+ throw new Error("'service' param is required for enable");
25
+ const existing = getServiceInfo(service);
26
+ if (!existing)
27
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
28
+ setServiceEnabled(service, true);
29
+ result = { service, enabled: true, reminder: existing.reminder };
30
+ break;
31
+ }
32
+ case "disable": {
33
+ const service = args.service;
34
+ if (!service)
35
+ throw new Error("'service' param is required for disable");
36
+ const existing = getServiceInfo(service);
37
+ if (!existing)
38
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
39
+ setServiceEnabled(service, false);
40
+ result = { service, enabled: false, reminder: existing.reminder };
41
+ break;
42
+ }
43
+ case "reset": {
44
+ const service = args.service;
45
+ if (!service)
46
+ throw new Error("'service' param is required for reset");
47
+ const existing = getServiceInfo(service);
48
+ if (!existing)
49
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
50
+ resetService(service);
51
+ result = { service, enabled: getServiceInfo(service)?.enabled, reminder: existing.reminder, reset: true };
52
+ break;
53
+ }
54
+ case "info": {
55
+ const service = args.service;
56
+ if (!service)
57
+ throw new Error("'service' param is required for info");
58
+ const info = getServiceInfo(service);
59
+ if (!info)
60
+ throw new Error(`Unknown service: ${service}. Use action='list' to see all valid services.`);
61
+ result = info;
62
+ break;
63
+ }
64
+ default:
65
+ throw new Error(`Unknown config_operation action: ${action}`);
66
+ }
67
+ return {
68
+ content: [{ type: "text", text: JSON.stringify({ result }) }],
69
+ structuredContent: { result },
70
+ };
71
+ }
@@ -0,0 +1,3 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function handleGuard2File(args: any): Promise<ToolDispatchResult>;
3
+ export declare function handleMachineNode2File(args: any): Promise<ToolDispatchResult>;
@@ -0,0 +1,90 @@
1
+ import { resolve } from "path";
2
+ import { strictParse, getEnvConfig, Guard2File_InputSchema, MachineNode2File_InputSchema, } from "../../schema/index.js";
3
+ import { guard2file, machineNode2file, } from "@wowok/wowok";
4
+ export async function handleGuard2File(args) {
5
+ const validated = strictParse(Guard2File_InputSchema, args, "guard2file input");
6
+ const env = getEnvConfig(validated.env);
7
+ try {
8
+ await guard2file(validated.guard, validated.file_path, validated.format || "json", env.network);
9
+ const result = {
10
+ result: {
11
+ status: "success",
12
+ data: {
13
+ file_path: resolve(validated.file_path),
14
+ format: validated.format || "json",
15
+ guard_object: validated.guard,
16
+ },
17
+ },
18
+ };
19
+ return {
20
+ content: [{ type: "text", text: JSON.stringify(result) }],
21
+ structuredContent: result,
22
+ };
23
+ }
24
+ catch (error) {
25
+ const result = {
26
+ result: {
27
+ status: "error",
28
+ error: error.message,
29
+ },
30
+ };
31
+ return {
32
+ content: [{ type: "text", text: JSON.stringify(result) }],
33
+ structuredContent: result,
34
+ };
35
+ }
36
+ }
37
+ export async function handleMachineNode2File(args) {
38
+ const validated = strictParse(MachineNode2File_InputSchema, args, "machineNode2file input");
39
+ const env = getEnvConfig(validated.env);
40
+ try {
41
+ await machineNode2file(validated.machine, validated.file_path, validated.format || "json", env.network);
42
+ let node_count = undefined;
43
+ try {
44
+ const filePath = resolve(validated.file_path);
45
+ const fileContent = await import('fs/promises').then(fs => fs.readFile(filePath, 'utf-8'));
46
+ if ((validated.format || "json") === "json") {
47
+ const parsed = JSON.parse(fileContent);
48
+ if (Array.isArray(parsed)) {
49
+ node_count = parsed.length;
50
+ }
51
+ }
52
+ else {
53
+ const nodeMatches = fileContent.match(/^##\s+Node:/gm);
54
+ node_count = nodeMatches ? nodeMatches.length : 0;
55
+ }
56
+ }
57
+ catch {
58
+ node_count = undefined;
59
+ }
60
+ const result = {
61
+ result: {
62
+ status: "success",
63
+ data: {
64
+ file_path: resolve(validated.file_path),
65
+ format: validated.format || "json",
66
+ machine_object: validated.machine,
67
+ },
68
+ },
69
+ };
70
+ if (node_count !== undefined) {
71
+ result.result.data.node_count = node_count;
72
+ }
73
+ return {
74
+ content: [{ type: "text", text: JSON.stringify(result) }],
75
+ structuredContent: result,
76
+ };
77
+ }
78
+ catch (error) {
79
+ const result = {
80
+ result: {
81
+ status: "error",
82
+ error: error.message,
83
+ },
84
+ };
85
+ return {
86
+ content: [{ type: "text", text: JSON.stringify(result) }],
87
+ structuredContent: result,
88
+ };
89
+ }
90
+ }
@@ -0,0 +1,30 @@
1
+ export declare const handleAccountOperation: (args: any) => Promise<{
2
+ content: {
3
+ type: "text";
4
+ text: string;
5
+ }[];
6
+ structuredContent: {
7
+ result: any;
8
+ semantic: any;
9
+ };
10
+ }>;
11
+ export declare const handleMarkOperation: (args: any) => Promise<{
12
+ content: {
13
+ type: "text";
14
+ text: string;
15
+ }[];
16
+ structuredContent: {
17
+ result: any;
18
+ semantic: any;
19
+ };
20
+ }>;
21
+ export declare const handleInfoOperation: (args: any) => Promise<{
22
+ content: {
23
+ type: "text";
24
+ text: string;
25
+ }[];
26
+ structuredContent: {
27
+ result: any;
28
+ semantic: any;
29
+ };
30
+ }>;
@@ -0,0 +1,27 @@
1
+ import { wrapLocalHandler } from "../shared.js";
2
+ import { AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, } from "../../schema/index.js";
3
+ import { account_operation, local_mark_operation, local_info_operation, } from "@wowok/wowok";
4
+ export const handleAccountOperation = wrapLocalHandler({
5
+ schema: AccountOperationSchema,
6
+ operationFn: account_operation,
7
+ parseLabel: "account_operation input",
8
+ buildContext: (validated) => ({
9
+ operation_type: "account_" + validated.operation_type,
10
+ data: validated,
11
+ }),
12
+ });
13
+ export const handleMarkOperation = wrapLocalHandler({
14
+ schema: LocalMarkOperationSchema,
15
+ operationFn: local_mark_operation,
16
+ parseLabel: "local_mark_operation input",
17
+ buildContext: (validated) => ({
18
+ operation_type: "mark_" + validated.operation_type,
19
+ data: validated,
20
+ }),
21
+ });
22
+ export const handleInfoOperation = wrapLocalHandler({
23
+ schema: LocalInfoOperationSchema,
24
+ operationFn: local_info_operation,
25
+ parseLabel: "local_info_operation input",
26
+ buildContext: (validated) => ({ operation_type: "local_info", data: validated }),
27
+ });
@@ -0,0 +1,16 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function normalizeAccountOrMark(input: string | {
3
+ name_or_address?: string;
4
+ local_mark_first?: boolean;
5
+ }): {
6
+ name_or_address?: string;
7
+ local_mark_first?: boolean;
8
+ };
9
+ export declare function normalizeManyAccountOrMark(input: string[] | {
10
+ entities: any[];
11
+ check_all_founded?: boolean;
12
+ }): {
13
+ entities: any[];
14
+ check_all_founded?: boolean;
15
+ };
16
+ export declare function handleMessengerOperation(args: any): Promise<ToolDispatchResult>;
@@ -0,0 +1,187 @@
1
+ import { strictParse, MessengerOperationInputSchema, } from "../../schema/index.js";
2
+ import { watch_conversations, send_message, send_file, watch_messages, extract_zip_messages, pull_messages, generate_wts, verify_wts, sign_wts, wts2html, proof_message, mark_messages_as_viewed, mark_conversation_as_viewed, blacklist, friendslist, guardlist, settings, } from "@wowok/wowok";
3
+ import { classifyError, buildDataSemantic, } from "../../schema/call/semantic.js";
4
+ export function normalizeAccountOrMark(input) {
5
+ if (typeof input === 'string') {
6
+ return { name_or_address: input, local_mark_first: true };
7
+ }
8
+ return input;
9
+ }
10
+ export function normalizeManyAccountOrMark(input) {
11
+ if (Array.isArray(input)) {
12
+ return {
13
+ entities: input.map(item => typeof item === 'string' ? { name_or_address: item, local_mark_first: true } : item),
14
+ check_all_founded: true,
15
+ };
16
+ }
17
+ return input;
18
+ }
19
+ export async function handleMessengerOperation(args) {
20
+ let validated;
21
+ try {
22
+ validated = strictParse(MessengerOperationInputSchema, args, "messenger_operation input");
23
+ let result;
24
+ switch (validated.operation) {
25
+ case "watch_conversations": {
26
+ const conversations = await watch_conversations(validated.filter);
27
+ result = { operation: "watch_conversations", result: conversations };
28
+ break;
29
+ }
30
+ case "send_message": {
31
+ const sendResult = await send_message(validated.from, normalizeAccountOrMark(validated.to), validated.content, validated.options);
32
+ const filteredResult = {
33
+ ...sendResult,
34
+ merkleData: sendResult.merkleData ? {
35
+ leafIndex: sendResult.merkleData.leafIndex,
36
+ prevRoot: sendResult.merkleData.prevRoot,
37
+ newRoot: sendResult.merkleData.newRoot,
38
+ serverSignature: sendResult.merkleData.serverSignature,
39
+ serverTimestamp: sendResult.merkleData.serverTimestamp,
40
+ serverPublicKey: sendResult.merkleData.serverPublicKey,
41
+ } : undefined,
42
+ };
43
+ result = { operation: "send_message", result: filteredResult };
44
+ break;
45
+ }
46
+ case "send_file": {
47
+ const sendResult = await send_file(validated.from, normalizeAccountOrMark(validated.to), validated.filePath, validated.options);
48
+ const filteredResult = {
49
+ ...sendResult,
50
+ merkleData: sendResult.merkleData ? {
51
+ leafIndex: sendResult.merkleData.leafIndex,
52
+ prevRoot: sendResult.merkleData.prevRoot,
53
+ newRoot: sendResult.merkleData.newRoot,
54
+ serverSignature: sendResult.merkleData.serverSignature,
55
+ serverTimestamp: sendResult.merkleData.serverTimestamp,
56
+ serverPublicKey: sendResult.merkleData.serverPublicKey,
57
+ } : undefined,
58
+ };
59
+ result = { operation: "send_file", result: filteredResult };
60
+ break;
61
+ }
62
+ case "watch_messages": {
63
+ const filter = validated.filter ? {
64
+ ...validated.filter,
65
+ peerAddress: validated.filter.peerAddress ? normalizeAccountOrMark(validated.filter.peerAddress) : undefined,
66
+ } : undefined;
67
+ const messages = await watch_messages(filter);
68
+ result = { operation: "watch_messages", result: messages };
69
+ break;
70
+ }
71
+ case "extract_zip_messages": {
72
+ const extractedPaths = await extract_zip_messages(validated.account, validated.messages, validated.outputDir);
73
+ result = { operation: "extract_zip_messages", result: extractedPaths };
74
+ break;
75
+ }
76
+ case "generate_wts": {
77
+ const params = validated.params ? {
78
+ ...validated.params,
79
+ peerAccount: normalizeAccountOrMark(validated.params.peerAccount),
80
+ } : undefined;
81
+ const wtsResult = await generate_wts(params);
82
+ result = { operation: "generate_wts", result: wtsResult };
83
+ break;
84
+ }
85
+ case "verify_wts": {
86
+ const verifyResult = await verify_wts(validated.wtsFilePath);
87
+ result = { operation: "verify_wts", result: verifyResult };
88
+ break;
89
+ }
90
+ case "sign_wts": {
91
+ const signedPath = await sign_wts(validated.wtsFilePath, validated.account, validated.outputPath);
92
+ result = { operation: "sign_wts", result: signedPath };
93
+ break;
94
+ }
95
+ case "wts2html": {
96
+ const htmlResult = await wts2html(validated.wtsPath, validated.options);
97
+ result = { operation: "wts2html", result: htmlResult };
98
+ break;
99
+ }
100
+ case "proof_message": {
101
+ const proofResult = await proof_message(validated.account, validated.messageId, validated.network);
102
+ result = { operation: "proof_message", result: proofResult };
103
+ break;
104
+ }
105
+ case "blacklist": {
106
+ const blacklistParams = {
107
+ account: validated.account,
108
+ op: validated.blacklist.op,
109
+ };
110
+ if ('users' in validated.blacklist) {
111
+ blacklistParams.users = normalizeManyAccountOrMark(validated.blacklist.users);
112
+ }
113
+ const blacklistResult = await blacklist(blacklistParams);
114
+ result = { operation: "blacklist", op: validated.blacklist.op, result: blacklistResult.result };
115
+ break;
116
+ }
117
+ case "friendslist": {
118
+ const friendslistParams = {
119
+ account: validated.account,
120
+ op: validated.friendslist.op,
121
+ };
122
+ if ('users' in validated.friendslist) {
123
+ friendslistParams.users = normalizeManyAccountOrMark(validated.friendslist.users);
124
+ }
125
+ const friendslistResult = await friendslist(friendslistParams);
126
+ result = { operation: "friendslist", op: validated.friendslist.op, result: friendslistResult.result };
127
+ break;
128
+ }
129
+ case "guardlist": {
130
+ const guardlistResult = await guardlist({
131
+ account: validated.account,
132
+ ...validated.guardlist,
133
+ });
134
+ result = { operation: "guardlist", op: validated.guardlist.op, result: guardlistResult.result };
135
+ break;
136
+ }
137
+ case "settings": {
138
+ const settingsResult = await settings({
139
+ account: validated.account,
140
+ ...validated.settings,
141
+ });
142
+ result = { operation: "settings", op: validated.settings.op, result: settingsResult.result };
143
+ break;
144
+ }
145
+ case "mark_messages_as_viewed": {
146
+ const markedCount = await mark_messages_as_viewed(validated.messageIds, validated.account);
147
+ result = { operation: "mark_messages_as_viewed", result: markedCount };
148
+ break;
149
+ }
150
+ case "mark_conversation_as_viewed": {
151
+ const markedCount = await mark_conversation_as_viewed(normalizeAccountOrMark(validated.peerAddress), validated.account);
152
+ result = { operation: "mark_conversation_as_viewed", result: markedCount };
153
+ break;
154
+ }
155
+ case "pull_messages": {
156
+ const messages = await pull_messages(validated.account, validated.limit);
157
+ result = { operation: "pull_messages", result: messages };
158
+ break;
159
+ }
160
+ default:
161
+ throw new Error(`Unknown messenger operation: ${validated.operation}`);
162
+ }
163
+ return {
164
+ content: [{ type: "text", text: JSON.stringify(result) }],
165
+ structuredContent: { result },
166
+ };
167
+ }
168
+ catch (error) {
169
+ const errorMessage = error instanceof Error ? error.message : String(error);
170
+ const ctx = validated ? { operation_type: "messenger_" + validated.operation, data: validated } : undefined;
171
+ const classified = classifyError(errorMessage);
172
+ const errorResult = { operation: "error", error: errorMessage };
173
+ if (classified.error_code !== undefined)
174
+ errorResult.error_code = classified.error_code;
175
+ if (classified.retryable !== undefined)
176
+ errorResult.retryable = classified.retryable;
177
+ if (classified.recovery_hint !== undefined)
178
+ errorResult.recovery_hint = classified.recovery_hint;
179
+ return {
180
+ content: [{ type: "text", text: `Error: ${errorMessage}` }],
181
+ structuredContent: {
182
+ result: errorResult,
183
+ semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
184
+ },
185
+ };
186
+ }
187
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolDispatchResult } from "../types.js";
2
+ export declare function handleOnchainOperations(args: any): Promise<ToolDispatchResult>;