@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
@@ -0,0 +1,130 @@
1
+ import { confirmGate } from "../safety/confirm-gate.js";
2
+ import { renderPreview } from "../safety/preview.js";
3
+ import { validateOperation, hasBlockingViolations, getWarningViolations, } from "../knowledge/index.js";
4
+ import { getHarness } from "../harness/index.js";
5
+ import { isEnabled as isRuntimeEnabled } from "../config/index.js";
6
+ import { classifyError, buildDataSemantic, } from "../schema/call/semantic.js";
7
+ import { strictParse } from "../schema/index.js";
8
+ export function withHarness(base, operation, intent) {
9
+ if (!isRuntimeEnabled("harness"))
10
+ return base;
11
+ try {
12
+ const harness = getHarness();
13
+ const expected = harness.expect(operation, intent, base.operation_type, base.data);
14
+ return {
15
+ ...base,
16
+ harness,
17
+ expected,
18
+ operation_id: `${base.operation_type}_${Date.now()}`,
19
+ };
20
+ }
21
+ catch {
22
+ return base;
23
+ }
24
+ }
25
+ export function wrapLocalHandler(config) {
26
+ const { schema, operationFn, parseLabel, buildContext } = config;
27
+ return async (args) => {
28
+ let validated;
29
+ try {
30
+ validated = strictParse(schema, args, parseLabel);
31
+ const result = await operationFn(validated);
32
+ const ctx = buildContext(validated);
33
+ return {
34
+ content: [{ type: "text", text: JSON.stringify(result) }],
35
+ structuredContent: {
36
+ result: {
37
+ status: "success",
38
+ data: result,
39
+ },
40
+ semantic: buildDataSemantic(result, ctx),
41
+ },
42
+ };
43
+ }
44
+ catch (error) {
45
+ const errorMessage = error instanceof Error ? error.message : String(error);
46
+ const ctx = validated ? buildContext(validated) : undefined;
47
+ const classified = classifyError(errorMessage);
48
+ const errorResult = {
49
+ status: "error",
50
+ error: errorMessage,
51
+ };
52
+ if (classified.error_code !== undefined)
53
+ errorResult.error_code = classified.error_code;
54
+ if (classified.retryable !== undefined)
55
+ errorResult.retryable = classified.retryable;
56
+ if (classified.recovery_hint !== undefined)
57
+ errorResult.recovery_hint = classified.recovery_hint;
58
+ return {
59
+ content: [{ type: "text", text: `Error: ${errorMessage}` }],
60
+ structuredContent: {
61
+ result: errorResult,
62
+ semantic: buildDataSemantic(undefined, ctx, true, errorMessage),
63
+ },
64
+ };
65
+ }
66
+ };
67
+ }
68
+ export function buildPendingConfirmation(operation_type, data, env) {
69
+ const gate = confirmGate(operation_type, data, env, env?.user_intent_phrases);
70
+ if (gate.pass)
71
+ return { content: [], structuredContent: null };
72
+ const preview = gate.preview;
73
+ const rendered = renderPreview(preview);
74
+ const output = {
75
+ message: rendered,
76
+ result: {
77
+ type: "pending_confirmation",
78
+ preview,
79
+ rule_id: gate.rule_id,
80
+ },
81
+ semantic: {
82
+ intent: `${operation_type}_awaiting_confirmation`,
83
+ status: "pending_input",
84
+ summary: `Operation blocked by ConfirmGate (${gate.level}). Review the preview and re-call with env.confirmed=true to proceed.`,
85
+ next_actions: [
86
+ {
87
+ action: "confirm: re-call the SAME operation with env.confirmed=true",
88
+ reason: `ConfirmGate rule '${gate.rule_id}' matched. The operation was NOT executed.`,
89
+ tool: "onchain_operations",
90
+ priority: "required",
91
+ },
92
+ ],
93
+ warnings: preview.warnings ?? [],
94
+ },
95
+ };
96
+ return {
97
+ content: [{ type: "text", text: rendered }],
98
+ structuredContent: output,
99
+ };
100
+ }
101
+ export function buildConstraintError(operation_type, violations) {
102
+ const errors = violations.filter((v) => v.severity === "error");
103
+ const errorList = errors.map((v) => ` • [${v.field}] ${v.message}`).join("\n");
104
+ const message = `Pre-call constraint violations for '${operation_type}':\n${errorList}\n\nFix the listed field(s) and retry.`;
105
+ const output = {
106
+ message,
107
+ result: {
108
+ type: "error",
109
+ error: message,
110
+ error_code: "invalid_parameter",
111
+ retryable: false,
112
+ recovery_hint: "Review the constraint violations above and correct the corresponding fields.",
113
+ },
114
+ };
115
+ return {
116
+ content: [{ type: "text", text: message }],
117
+ structuredContent: output,
118
+ };
119
+ }
120
+ export function buildClassifiedErrorResult(base, error, classified) {
121
+ const result = { ...base, error };
122
+ if (classified.error_code !== undefined)
123
+ result.error_code = classified.error_code;
124
+ if (classified.retryable !== undefined)
125
+ result.retryable = classified.retryable;
126
+ if (classified.recovery_hint !== undefined)
127
+ result.recovery_hint = classified.recovery_hint;
128
+ return result;
129
+ }
130
+ export { validateOperation, hasBlockingViolations, getWarningViolations, };
@@ -0,0 +1,35 @@
1
+ import type { z } from "zod";
2
+ import type { classifyError } from "../schema/call/semantic.js";
3
+ import type { SemanticContext } from "../schema/call/semantic.js";
4
+ export interface ToolConfig {
5
+ title: string;
6
+ description: string;
7
+ inputSchema: z.ZodTypeAny;
8
+ outputSchema?: z.ZodTypeAny;
9
+ annotations?: {
10
+ readOnlyHint?: boolean;
11
+ destructiveHint?: boolean;
12
+ idempotentHint?: boolean;
13
+ openWorldHint?: boolean;
14
+ };
15
+ _meta?: any;
16
+ }
17
+ export type ErrorShapeBuilder = (error: string, classified: ReturnType<typeof classifyError>, ctx: SemanticContext) => Record<string, any>;
18
+ export interface ToolDispatchResult {
19
+ content: {
20
+ type: "text";
21
+ text: string;
22
+ }[];
23
+ structuredContent: any;
24
+ }
25
+ export interface ToolEntry {
26
+ name: string;
27
+ handler: (args: any) => Promise<ToolDispatchResult>;
28
+ config: ToolConfig;
29
+ errorShapeBuilder?: ErrorShapeBuilder;
30
+ timeoutMs?: number;
31
+ applyRules?: (args: any) => ToolDispatchResult | null;
32
+ }
33
+ export interface DispatchOptions {
34
+ skipRules?: boolean;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { ErrorShapeBuilder } from "./types.js";
2
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number, operationName?: string): Promise<T>;
3
+ export declare function wrapHandlerWithErrorShape(handler: (args: any) => Promise<any>, timeoutMs: number, toolName: string, errorShapeBuilder?: ErrorShapeBuilder): (args: any) => Promise<any>;
4
+ export declare const statusErrorShape: ErrorShapeBuilder;
5
+ export declare const operationErrorShape: ErrorShapeBuilder;
6
+ export declare const strictStatusErrorShape: ErrorShapeBuilder;
@@ -0,0 +1,55 @@
1
+ import { classifyError, buildDataSemantic, } from "../schema/call/semantic.js";
2
+ import { buildClassifiedErrorResult } from "./shared.js";
3
+ export function withTimeout(promise, timeoutMs = 30000, operationName = "operation") {
4
+ let timer;
5
+ return Promise.race([
6
+ promise.finally(() => {
7
+ if (timer)
8
+ clearTimeout(timer);
9
+ }),
10
+ new Promise((_, reject) => {
11
+ timer = setTimeout(() => {
12
+ let hint = "";
13
+ if (operationName.includes("messenger")) {
14
+ hint = " This is a messenger network operation. Possible causes: " +
15
+ "(1) messenger server (https://messenger.wowok.net) unreachable, " +
16
+ "(2) no messenger-enabled account configured (use account_operation to set messenger name), " +
17
+ "(3) network connectivity issue. " +
18
+ "Ensure you have a messenger-enabled account and the server is reachable.";
19
+ }
20
+ reject(new Error(`Operation '${operationName}' timed out after ${timeoutMs}ms.${hint}`));
21
+ }, timeoutMs);
22
+ }),
23
+ ]);
24
+ }
25
+ export function wrapHandlerWithErrorShape(handler, timeoutMs, toolName, errorShapeBuilder) {
26
+ return async (args) => {
27
+ try {
28
+ return await withTimeout(handler(args), timeoutMs, toolName);
29
+ }
30
+ catch (error) {
31
+ if (errorShapeBuilder) {
32
+ const errorMessage = error instanceof Error ? error.message : String(error);
33
+ const classified = classifyError(errorMessage);
34
+ const ctx = { operation_type: toolName, data: args };
35
+ const structuredContent = errorShapeBuilder(errorMessage, classified, ctx);
36
+ return {
37
+ content: [{ type: "text", text: `Error: ${errorMessage}` }],
38
+ structuredContent,
39
+ };
40
+ }
41
+ throw error;
42
+ }
43
+ };
44
+ }
45
+ export const statusErrorShape = (error, classified, ctx) => ({
46
+ result: buildClassifiedErrorResult({ status: "error" }, error, classified),
47
+ semantic: buildDataSemantic(undefined, ctx, true, error),
48
+ });
49
+ export const operationErrorShape = (error, classified, ctx) => ({
50
+ result: buildClassifiedErrorResult({ operation: "error" }, error, classified),
51
+ semantic: buildDataSemantic(undefined, ctx, true, error),
52
+ });
53
+ export const strictStatusErrorShape = (error, _classified, _ctx) => ({
54
+ result: { status: "error", error },
55
+ });
package/package.json CHANGED
@@ -1,11 +1,25 @@
1
1
  {
2
2
  "name": "@wowok/agent-mcp",
3
- "version": "2.3.18",
3
+ "version": "2.4.3",
4
4
  "description": "Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "module": "node",
8
8
  "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./rules": {
15
+ "types": "./dist/rules.d.ts",
16
+ "import": "./dist/rules.js"
17
+ },
18
+ "./tools": {
19
+ "types": "./dist/tools/index.d.ts",
20
+ "import": "./dist/tools/index.js"
21
+ }
22
+ },
9
23
  "repository": {
10
24
  "type": "git",
11
25
  "url": "https://github.com/wowok-ai/agent.git"
@@ -36,16 +50,16 @@
36
50
  "license": "Apache-2.0",
37
51
  "dependencies": {
38
52
  "@modelcontextprotocol/sdk": "^1.29.0",
39
- "@wowok/wowok": "2.3.18",
53
+ "@wowok/wowok": "2.4.3",
40
54
  "lodash": "^4.18.1",
41
- "zod": "^3.25.76"
55
+ "zod": "^3.25.76",
56
+ "zod-to-json-schema": "^3.25.2"
42
57
  },
43
58
  "devDependencies": {
44
59
  "@types/node": "^22.19.19",
45
60
  "tsx": "^4.21.0",
46
61
  "typescript": "^5.8.2",
47
- "vitest": "^2.1.0",
48
- "zod-to-json-schema": "^3.25.2"
62
+ "vitest": "^2.1.0"
49
63
  },
50
64
  "scripts": {
51
65
  "clean": "rm -rf dist",