@gala-chain/launchpad-mcp-server 1.4.0 ā 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +9 -1
- package/dist/constants/mcpToolNames.d.ts +159 -0
- package/dist/constants/mcpToolNames.d.ts.map +1 -0
- package/dist/constants/mcpToolNames.js +131 -0
- package/dist/constants/mcpToolNames.js.map +1 -0
- package/dist/prompts/__tests__/promptStructure.test.d.ts +7 -0
- package/dist/prompts/__tests__/promptStructure.test.d.ts.map +1 -0
- package/dist/prompts/__tests__/promptStructure.test.js +106 -0
- package/dist/prompts/__tests__/promptStructure.test.js.map +1 -0
- package/dist/prompts/__tests__/registry.test.d.ts +7 -0
- package/dist/prompts/__tests__/registry.test.d.ts.map +1 -0
- package/dist/prompts/__tests__/registry.test.js +119 -0
- package/dist/prompts/__tests__/registry.test.js.map +1 -0
- package/dist/prompts/analysis.d.ts.map +1 -1
- package/dist/prompts/analysis.js +97 -65
- package/dist/prompts/analysis.js.map +1 -1
- package/dist/prompts/index.d.ts +58 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +83 -3
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/portfolio.d.ts.map +1 -1
- package/dist/prompts/portfolio.js +80 -76
- package/dist/prompts/portfolio.js.map +1 -1
- package/dist/prompts/trading.d.ts.map +1 -1
- package/dist/prompts/trading.js +76 -139
- package/dist/prompts/trading.js.map +1 -1
- package/dist/prompts/utils/workflowTemplates.d.ts +103 -0
- package/dist/prompts/utils/workflowTemplates.d.ts.map +1 -0
- package/dist/prompts/utils/workflowTemplates.js +315 -0
- package/dist/prompts/utils/workflowTemplates.js.map +1 -0
- package/dist/schemas/common-schemas.d.ts +121 -16
- package/dist/schemas/common-schemas.d.ts.map +1 -1
- package/dist/schemas/common-schemas.js +122 -17
- package/dist/schemas/common-schemas.js.map +1 -1
- package/dist/scripts/test-all-prompts.d.ts +6 -0
- package/dist/scripts/test-all-prompts.d.ts.map +1 -0
- package/dist/scripts/test-all-prompts.js +158 -0
- package/dist/scripts/test-all-prompts.js.map +1 -0
- package/dist/server.js +1 -1
- package/dist/tools/balance/index.d.ts.map +1 -1
- package/dist/tools/balance/index.js +5 -4
- package/dist/tools/balance/index.js.map +1 -1
- package/dist/tools/creation/index.d.ts.map +1 -1
- package/dist/tools/creation/index.js +6 -11
- package/dist/tools/creation/index.js.map +1 -1
- package/dist/tools/index.d.ts +9 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +58 -14
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pools/fetchPoolDetailsForCalculation.d.ts +2 -3
- package/dist/tools/pools/fetchPoolDetailsForCalculation.d.ts.map +1 -1
- package/dist/tools/pools/fetchPoolDetailsForCalculation.js +5 -17
- package/dist/tools/pools/fetchPoolDetailsForCalculation.js.map +1 -1
- package/dist/tools/pools/index.d.ts.map +1 -1
- package/dist/tools/pools/index.js +51 -137
- package/dist/tools/pools/index.js.map +1 -1
- package/dist/tools/social/index.d.ts.map +1 -1
- package/dist/tools/social/index.js +4 -3
- package/dist/tools/social/index.js.map +1 -1
- package/dist/tools/trading/index.d.ts.map +1 -1
- package/dist/tools/trading/index.js +7 -21
- package/dist/tools/trading/index.js.map +1 -1
- package/dist/tools/utils/createWallet.d.ts +2 -3
- package/dist/tools/utils/createWallet.d.ts.map +1 -1
- package/dist/tools/utils/createWallet.js +8 -13
- package/dist/tools/utils/createWallet.js.map +1 -1
- package/dist/tools/utils/getAddress.d.ts +2 -3
- package/dist/tools/utils/getAddress.d.ts.map +1 -1
- package/dist/tools/utils/getAddress.js +6 -13
- package/dist/tools/utils/getAddress.js.map +1 -1
- package/dist/tools/utils/getConfig.d.ts +2 -3
- package/dist/tools/utils/getConfig.d.ts.map +1 -1
- package/dist/tools/utils/getConfig.js +5 -13
- package/dist/tools/utils/getConfig.js.map +1 -1
- package/dist/tools/utils/getEthereumAddress.d.ts +2 -3
- package/dist/tools/utils/getEthereumAddress.d.ts.map +1 -1
- package/dist/tools/utils/getEthereumAddress.js +6 -13
- package/dist/tools/utils/getEthereumAddress.js.map +1 -1
- package/dist/tools/utils/getUrlByTokenName.d.ts +2 -3
- package/dist/tools/utils/getUrlByTokenName.d.ts.map +1 -1
- package/dist/tools/utils/getUrlByTokenName.js +6 -20
- package/dist/tools/utils/getUrlByTokenName.js.map +1 -1
- package/dist/tools/utils/isTokenGraduated.d.ts +2 -3
- package/dist/tools/utils/isTokenGraduated.d.ts.map +1 -1
- package/dist/tools/utils/isTokenGraduated.js +6 -17
- package/dist/tools/utils/isTokenGraduated.js.map +1 -1
- package/dist/utils/__tests__/validation.test.d.ts +7 -0
- package/dist/utils/__tests__/validation.test.d.ts.map +1 -0
- package/dist/utils/__tests__/validation.test.js +122 -0
- package/dist/utils/__tests__/validation.test.js.map +1 -0
- package/dist/utils/default-values.d.ts +147 -0
- package/dist/utils/default-values.d.ts.map +1 -0
- package/dist/utils/default-values.js +177 -0
- package/dist/utils/default-values.js.map +1 -0
- package/dist/utils/error-handler.d.ts +9 -2
- package/dist/utils/error-handler.d.ts.map +1 -1
- package/dist/utils/error-handler.js +14 -59
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/error-templates.d.ts +96 -0
- package/dist/utils/error-templates.d.ts.map +1 -0
- package/dist/utils/error-templates.js +244 -0
- package/dist/utils/error-templates.js.map +1 -0
- package/dist/utils/tool-factory.d.ts +154 -0
- package/dist/utils/tool-factory.d.ts.map +1 -0
- package/dist/utils/tool-factory.js +194 -0
- package/dist/utils/tool-factory.js.map +1 -0
- package/dist/utils/tool-registry.d.ts +92 -0
- package/dist/utils/tool-registry.d.ts.map +1 -0
- package/dist/utils/tool-registry.js +227 -0
- package/dist/utils/tool-registry.js.map +1 -0
- package/dist/utils/validation.d.ts +162 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +276 -0
- package/dist/utils/validation.js.map +1 -0
- package/jest.integration.config.js +70 -0
- package/package.json +10 -6
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Default Value Utilities
|
|
4
|
+
*
|
|
5
|
+
* Centralized default values for tool parameters to eliminate magic numbers
|
|
6
|
+
* and ensure consistency across 47 MCP tools.
|
|
7
|
+
*
|
|
8
|
+
* @see Phase 2.2 of refactoring plan
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.defaultValues = exports.RESOLUTION_MAP = exports.DEFAULT_VOLUME_RESOLUTION = exports.DEFAULT_SORT_ORDER = exports.DEFAULT_POOL_TYPE = exports.DEFAULT_RBC_FEE_SLIPPAGE = exports.DEFAULT_SLIPPAGE_TOLERANCE = exports.MAX_LIMITS = exports.DEFAULT_LIMITS = exports.DEFAULT_PAGINATION = void 0;
|
|
12
|
+
exports.applyPaginationDefaults = applyPaginationDefaults;
|
|
13
|
+
exports.applyOperationPaginationDefaults = applyOperationPaginationDefaults;
|
|
14
|
+
exports.applySlippageDefaults = applySlippageDefaults;
|
|
15
|
+
exports.resolutionToSeconds = resolutionToSeconds;
|
|
16
|
+
exports.dateToUnixTimestamp = dateToUnixTimestamp;
|
|
17
|
+
const constraints_js_1 = require("./constraints.js");
|
|
18
|
+
// =============================================================================
|
|
19
|
+
// Pagination Defaults
|
|
20
|
+
// =============================================================================
|
|
21
|
+
/**
|
|
22
|
+
* Default pagination configuration
|
|
23
|
+
*/
|
|
24
|
+
exports.DEFAULT_PAGINATION = {
|
|
25
|
+
page: 1,
|
|
26
|
+
limit: 20,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Operation-specific default limits
|
|
30
|
+
*/
|
|
31
|
+
exports.DEFAULT_LIMITS = {
|
|
32
|
+
trade: 20,
|
|
33
|
+
user: 20,
|
|
34
|
+
pool: 20,
|
|
35
|
+
comment: 20,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Maximum limits per operation type (from MCP_CONSTRAINTS)
|
|
39
|
+
*/
|
|
40
|
+
exports.MAX_LIMITS = {
|
|
41
|
+
trade: constraints_js_1.MCP_CONSTRAINTS.TRADE_LIMIT, // 20
|
|
42
|
+
user: constraints_js_1.MCP_CONSTRAINTS.USER_LIMIT, // 20
|
|
43
|
+
pool: constraints_js_1.MCP_CONSTRAINTS.POOL_LIMIT, // 100
|
|
44
|
+
comment: constraints_js_1.MCP_CONSTRAINTS.COMMENT_LIMIT, // 50
|
|
45
|
+
};
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// Trading Defaults
|
|
48
|
+
// =============================================================================
|
|
49
|
+
/**
|
|
50
|
+
* Default slippage tolerance (1%)
|
|
51
|
+
*/
|
|
52
|
+
exports.DEFAULT_SLIPPAGE_TOLERANCE = 0.01;
|
|
53
|
+
/**
|
|
54
|
+
* Default reverse bonding curve fee slippage tolerance (1%)
|
|
55
|
+
*/
|
|
56
|
+
exports.DEFAULT_RBC_FEE_SLIPPAGE = 0.01;
|
|
57
|
+
/**
|
|
58
|
+
* Default pool type for fetchPools
|
|
59
|
+
*/
|
|
60
|
+
exports.DEFAULT_POOL_TYPE = 'recent';
|
|
61
|
+
/**
|
|
62
|
+
* Default sort order
|
|
63
|
+
*/
|
|
64
|
+
exports.DEFAULT_SORT_ORDER = 'DESC';
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// Volume Data Defaults
|
|
67
|
+
// =============================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Default resolution for volume data (1 hour)
|
|
70
|
+
*/
|
|
71
|
+
exports.DEFAULT_VOLUME_RESOLUTION = '1h';
|
|
72
|
+
/**
|
|
73
|
+
* Resolution mapping (string to seconds)
|
|
74
|
+
*/
|
|
75
|
+
exports.RESOLUTION_MAP = {
|
|
76
|
+
'1m': 60,
|
|
77
|
+
'5m': 300,
|
|
78
|
+
'15m': 900,
|
|
79
|
+
'1h': 3600,
|
|
80
|
+
'4h': 14400,
|
|
81
|
+
'1d': 86400,
|
|
82
|
+
};
|
|
83
|
+
// =============================================================================
|
|
84
|
+
// Utility Functions
|
|
85
|
+
// =============================================================================
|
|
86
|
+
/**
|
|
87
|
+
* Applies default pagination values to args object
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const params = applyPaginationDefaults(args);
|
|
92
|
+
* // { page: 1, limit: 20, ...otherArgs }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
function applyPaginationDefaults(args, defaults = exports.DEFAULT_PAGINATION) {
|
|
96
|
+
return {
|
|
97
|
+
...args,
|
|
98
|
+
page: args.page ?? defaults.page ?? exports.DEFAULT_PAGINATION.page,
|
|
99
|
+
limit: args.limit ?? defaults.limit ?? exports.DEFAULT_PAGINATION.limit,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Applies operation-specific pagination defaults
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const params = applyOperationPaginationDefaults(args, 'pool');
|
|
108
|
+
* // Uses default limit of 20 for pool operations
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
function applyOperationPaginationDefaults(args, operationType) {
|
|
112
|
+
return applyPaginationDefaults(args, {
|
|
113
|
+
page: exports.DEFAULT_PAGINATION.page,
|
|
114
|
+
limit: exports.DEFAULT_LIMITS[operationType],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Applies default slippage values to trading args
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const params = applySlippageDefaults(args);
|
|
123
|
+
* // { slippageToleranceFactor: 0.01, maxAcceptableReverseBondingCurveFeeSlippageFactor: 0.01, ...args }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
function applySlippageDefaults(args, defaults = {}) {
|
|
127
|
+
return {
|
|
128
|
+
...args,
|
|
129
|
+
slippageToleranceFactor: args.slippageToleranceFactor ??
|
|
130
|
+
defaults.slippageToleranceFactor ??
|
|
131
|
+
exports.DEFAULT_SLIPPAGE_TOLERANCE,
|
|
132
|
+
maxAcceptableReverseBondingCurveFeeSlippageFactor: args.maxAcceptableReverseBondingCurveFeeSlippageFactor ??
|
|
133
|
+
defaults.maxAcceptableReverseBondingCurveFeeSlippageFactor ??
|
|
134
|
+
exports.DEFAULT_RBC_FEE_SLIPPAGE,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Converts volume resolution string to seconds
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const seconds = resolutionToSeconds('1h', '1h');
|
|
143
|
+
* // 3600
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
function resolutionToSeconds(resolution, defaultResolution = exports.DEFAULT_VOLUME_RESOLUTION) {
|
|
147
|
+
return exports.RESOLUTION_MAP[resolution ?? defaultResolution] ?? exports.RESOLUTION_MAP[defaultResolution];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Converts ISO 8601 date string to Unix timestamp (seconds)
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const timestamp = dateToUnixTimestamp('2024-01-15T14:30:25Z');
|
|
155
|
+
* // 1705329025
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
function dateToUnixTimestamp(isoDate) {
|
|
159
|
+
if (!isoDate)
|
|
160
|
+
return undefined;
|
|
161
|
+
return Math.floor(new Date(isoDate).getTime() / 1000);
|
|
162
|
+
}
|
|
163
|
+
// =============================================================================
|
|
164
|
+
// Export All
|
|
165
|
+
// =============================================================================
|
|
166
|
+
exports.defaultValues = {
|
|
167
|
+
pagination: exports.DEFAULT_PAGINATION,
|
|
168
|
+
limits: exports.DEFAULT_LIMITS,
|
|
169
|
+
maxLimits: exports.MAX_LIMITS,
|
|
170
|
+
slippageTolerance: exports.DEFAULT_SLIPPAGE_TOLERANCE,
|
|
171
|
+
rbcFeeSlippage: exports.DEFAULT_RBC_FEE_SLIPPAGE,
|
|
172
|
+
poolType: exports.DEFAULT_POOL_TYPE,
|
|
173
|
+
sortOrder: exports.DEFAULT_SORT_ORDER,
|
|
174
|
+
volumeResolution: exports.DEFAULT_VOLUME_RESOLUTION,
|
|
175
|
+
resolutionMap: exports.RESOLUTION_MAP,
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=default-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-values.js","sourceRoot":"","sources":["../../src/utils/default-values.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA8FH,0DASC;AAWD,4EAQC;AAWD,sDAqBC;AAWD,kDAKC;AAWD,kDAGC;AAtLD,qDAAmD;AAEnD,gFAAgF;AAChF,sBAAsB;AACtB,gFAAgF;AAEhF;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,EAAE;CACD,CAAC;AAEX;;GAEG;AACU,QAAA,cAAc,GAAG;IAC5B,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;CACH,CAAC;AAEX;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,gCAAe,CAAC,WAAW,EAAE,KAAK;IACzC,IAAI,EAAE,gCAAe,CAAC,UAAU,EAAE,KAAK;IACvC,IAAI,EAAE,gCAAe,CAAC,UAAU,EAAE,MAAM;IACxC,OAAO,EAAE,gCAAe,CAAC,aAAa,EAAE,KAAK;CACrC,CAAC;AAEX,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAE7C;;GAEG;AACU,QAAA,iBA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QG;AACH,SAAgB,mBAAmB,CACjC,UAA8B,EAC9B,oBAA4B,iCAAyB;IAErD,OAAO,sBAAc,CAAC,UAAU,IAAI,iBAAiB,CAAC,IAAI,sBAAc,CAAC,iBAAiB,CAAC,CAAC;AAC9F,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CAAC,OAA2B;IAC7D,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEnE,QAAA,aAAa,GAAG;IAC3B,UAAU,EAAE,0BAAkB;IAC9B,MAAM,EAAE,sBAAc;IACtB,SAAS,EAAE,kBAAU;IACrB,iBAAiB,EAAE,kCAA0B;IAC7C,cAAc,EAAE,gCAAwB;IACxC,QAAQ,EAAE,yBAAiB;IAC3B,SAAS,EAAE,0BAAkB;IAC7B,gBAAgB,EAAE,iCAAyB;IAC3C,aAAa,EAAE,sBAAc;CAC9B,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error Handler Utility
|
|
3
3
|
*
|
|
4
|
-
* Formats errors for MCP protocol responses
|
|
4
|
+
* Formats errors for MCP protocol responses with AI-friendly tips.
|
|
5
|
+
* Uses centralized error templates from error-templates.ts.
|
|
6
|
+
*
|
|
7
|
+
* @see src/utils/error-templates.ts
|
|
5
8
|
*/
|
|
6
9
|
import type { MCPToolResponse } from '../types/mcp.js';
|
|
7
10
|
/**
|
|
@@ -10,6 +13,10 @@ import type { MCPToolResponse } from '../types/mcp.js';
|
|
|
10
13
|
export declare function formatError(error: unknown): MCPToolResponse;
|
|
11
14
|
/**
|
|
12
15
|
* Wrap handler with error handling
|
|
16
|
+
*
|
|
17
|
+
* @template TArgs - Array of argument types
|
|
18
|
+
* @param handler - Handler function to wrap with error handling
|
|
19
|
+
* @returns Wrapped handler with automatic error formatting
|
|
13
20
|
*/
|
|
14
|
-
export declare function withErrorHandling<
|
|
21
|
+
export declare function withErrorHandling<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<MCPToolResponse>): (...args: TArgs) => Promise<MCPToolResponse>;
|
|
15
22
|
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAkB3D;AAkBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,OAAO,EAAE,EACvD,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,GACpD,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,eAAe,CAAC,CAQ9C"}
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Error Handler Utility
|
|
4
4
|
*
|
|
5
|
-
* Formats errors for MCP protocol responses
|
|
5
|
+
* Formats errors for MCP protocol responses with AI-friendly tips.
|
|
6
|
+
* Uses centralized error templates from error-templates.ts.
|
|
7
|
+
*
|
|
8
|
+
* @see src/utils/error-templates.ts
|
|
6
9
|
*/
|
|
7
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
11
|
exports.formatError = formatError;
|
|
9
12
|
exports.withErrorHandling = withErrorHandling;
|
|
13
|
+
const error_templates_js_1 = require("./error-templates.js");
|
|
10
14
|
/**
|
|
11
15
|
* Format error for MCP response with AI-friendly tips
|
|
12
16
|
*/
|
|
13
17
|
function formatError(error) {
|
|
14
|
-
const errorMessage = error instanceof Error
|
|
15
|
-
? error.message
|
|
16
|
-
: String(error);
|
|
18
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
17
19
|
// Sanitize sensitive information from error messages
|
|
18
20
|
const sanitized = sanitizeError(errorMessage);
|
|
19
|
-
// Add AI-friendly tips
|
|
20
|
-
const withTips =
|
|
21
|
+
// Add AI-friendly tips using centralized templates
|
|
22
|
+
const withTips = (0, error_templates_js_1.enhanceErrorMessage)(sanitized);
|
|
21
23
|
return {
|
|
22
24
|
content: [
|
|
23
25
|
{
|
|
@@ -28,57 +30,6 @@ function formatError(error) {
|
|
|
28
30
|
isError: true,
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Add AI-friendly tips for common error patterns
|
|
33
|
-
*/
|
|
34
|
-
function addAIFriendlyTips(message) {
|
|
35
|
-
// Limit validation errors
|
|
36
|
-
if (message.includes('Limit must be') || message.includes('between 1 and')) {
|
|
37
|
-
if (message.includes('20')) {
|
|
38
|
-
return `${message}\n\nš” AI TIP: Trade and user operations have a maximum limit of 20. Use:\n- gala_launchpad_fetch_trades: limit ⤠20\n- gala_launchpad_fetch_tokens_held: limit ⤠20\n- gala_launchpad_fetch_tokens_created: limit ⤠20\n\nSee docs/CONSTRAINTS-REFERENCE.md for details.`;
|
|
39
|
-
}
|
|
40
|
-
if (message.includes('50')) {
|
|
41
|
-
return `${message}\n\nš” AI TIP: Comment operations have a maximum limit of 50. Use:\n- gala_launchpad_fetch_comments: limit ⤠50\n\nSee docs/CONSTRAINTS-REFERENCE.md for details.`;
|
|
42
|
-
}
|
|
43
|
-
if (message.includes('100')) {
|
|
44
|
-
return `${message}\n\nš” AI TIP: Pool operations have a maximum limit of 100. Use:\n- gala_launchpad_fetch_pools: limit ⤠100\n\nSee docs/CONSTRAINTS-REFERENCE.md for details.`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Token name validation errors
|
|
48
|
-
if (message.includes('token name') && (message.includes('invalid') || message.includes('validation'))) {
|
|
49
|
-
return `${message}\n\nš” AI TIP: Token names must match pattern ^[a-z0-9_-]{2,20}$:\n- Lowercase letters and numbers only\n- Dashes and underscores allowed\n- Length: 2-20 characters\n- Valid examples: 'mytoken', 'test-token', 'token_123'\n- Invalid: 'MyToken' (uppercase), 'a' (too short), 'my token' (space)`;
|
|
50
|
-
}
|
|
51
|
-
// Token symbol validation errors
|
|
52
|
-
if (message.includes('token symbol') && (message.includes('invalid') || message.includes('validation'))) {
|
|
53
|
-
return `${message}\n\nš” AI TIP: Token symbols must match pattern ^[A-Z0-9]{2,10}$:\n- Uppercase letters and numbers only\n- No special characters\n- Length: 2-10 characters\n- Valid examples: 'MTK', 'TEST123', 'ABC'\n- Invalid: 'mtk' (lowercase), 'A' (too short), 'MY-TOKEN' (dash)`;
|
|
54
|
-
}
|
|
55
|
-
// Wallet address format errors
|
|
56
|
-
if (message.includes('address') && (message.includes('format') || message.includes('validation'))) {
|
|
57
|
-
return `${message}\n\nš” AI TIP: Wallet addresses must use format:\n- Backend API: 'eth|{40-hex-chars}' (e.g., 'eth|abc123...')\n- Convert from standard: address.startsWith('0x') ? \`eth|\${address.slice(2)}\` : address\n- Most MCP tools expect 'eth|...' format`;
|
|
58
|
-
}
|
|
59
|
-
// WebSocket/trade timeout errors
|
|
60
|
-
if (message.includes('timeout') || message.includes('WebSocket')) {
|
|
61
|
-
return `${message}\n\nš” AI TIP: Trade execution timeouts often indicate incorrect expectedAmount parameter.\n\nā
CORRECT WORKFLOW:\n1. Call calculate_buy_amount() or calculate_sell_amount()\n2. Extract result.amount from response (e.g., "16843.7579794843252")\n3. Use result.amount as expectedAmount in buy() or sell()\n\nā WRONG: Using your input amount as expectedAmount\nā
RIGHT: Using calculated result.amount as expectedAmount\n\nSee docs/AI-AGENT-PATTERNS.md section "Gotcha #1" for examples.`;
|
|
62
|
-
}
|
|
63
|
-
// Slippage/amount errors
|
|
64
|
-
if (message.includes('slippage') || message.includes('amount') && message.includes('expected')) {
|
|
65
|
-
return `${message}\n\nš” AI TIP: expectedAmount must be the calculated output from calculate functions, NOT your input amount.\n\nExample:\nconst calc = await calculateBuyAmount({ amount: '10', type: 'native', ... });\n// calc.amount = "16843.7579794843252" <- Use THIS as expectedAmount\nawait buy({ amount: '10', expectedAmount: calc.amount, ... });\n\nSee docs/AI-AGENT-PATTERNS.md for complete trading workflow.`;
|
|
66
|
-
}
|
|
67
|
-
// Social URL requirement errors
|
|
68
|
-
if (message.includes('social') || (message.includes('URL') && message.includes('required'))) {
|
|
69
|
-
return `${message}\n\nš” AI TIP: Token launch requires at least ONE social URL:\n- websiteUrl (e.g., 'https://mytoken.com')\n- twitterUrl (e.g., 'https://twitter.com/mytoken')\n- telegramUrl (e.g., 'https://t.me/mytoken')\n\nProvide at least one in launchToken() call.`;
|
|
70
|
-
}
|
|
71
|
-
// Type parameter confusion
|
|
72
|
-
if (message.includes('type') && (message.includes('native') || message.includes('token'))) {
|
|
73
|
-
return `${message}\n\nš” AI TIP: Trading type parameter:\n- 'native': You specify GALA amount (most common)\n Example: "I want to spend 10 GALA" ā type: 'native', amount: '10'\n- 'token': You specify exact token amount\n Example: "I want to buy exactly 1000 tokens" ā type: 'token', amount: '1000'\n\nSee docs/AI-AGENT-PATTERNS.md section "Gotcha #3" for details.`;
|
|
74
|
-
}
|
|
75
|
-
// Generic validation error
|
|
76
|
-
if (message.includes('validation') || message.includes('invalid')) {
|
|
77
|
-
return `${message}\n\nš” AI TIP: Check parameter formats in docs/AI-AGENT-PATTERNS.md\nCommon validation rules:\n- tokenName: ^[a-z0-9_-]{2,20}$ (lowercase, 2-20 chars)\n- tokenSymbol: ^[A-Z0-9]{2,10}$ (uppercase, 2-10 chars)\n- address: 'eth|...' or '0x...' format (auto-normalized)\n- amount: ^[0-9.]+$ (decimal string)\n- limits: See CONSTRAINTS-REFERENCE.md`;
|
|
78
|
-
}
|
|
79
|
-
// No specific tip found, return original message
|
|
80
|
-
return message;
|
|
81
|
-
}
|
|
82
33
|
/**
|
|
83
34
|
* Sanitize error messages to remove sensitive information
|
|
84
35
|
*/
|
|
@@ -93,15 +44,19 @@ function sanitizeError(message) {
|
|
|
93
44
|
}
|
|
94
45
|
/**
|
|
95
46
|
* Wrap handler with error handling
|
|
47
|
+
*
|
|
48
|
+
* @template TArgs - Array of argument types
|
|
49
|
+
* @param handler - Handler function to wrap with error handling
|
|
50
|
+
* @returns Wrapped handler with automatic error formatting
|
|
96
51
|
*/
|
|
97
52
|
function withErrorHandling(handler) {
|
|
98
|
-
return
|
|
53
|
+
return async (...args) => {
|
|
99
54
|
try {
|
|
100
55
|
return await handler(...args);
|
|
101
56
|
}
|
|
102
57
|
catch (error) {
|
|
103
58
|
return formatError(error);
|
|
104
59
|
}
|
|
105
|
-
}
|
|
60
|
+
};
|
|
106
61
|
}
|
|
107
62
|
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAQH,kCAkBC;AAyBD,8CAUC;AA1DD,6DAA2D;AAE3D;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE5E,qDAAqD;IACrD,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAE9C,mDAAmD;IACnD,MAAM,QAAQ,GAAG,IAAA,wCAAmB,EAAC,SAAS,CAAC,CAAC;IAEhD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,UAAU,QAAQ,EAAE;aAC3B;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,sBAAsB;IACtB,IAAI,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IAE/D,gDAAgD;IAChD,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;IAElE,8CAA8C;IAC9C,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;IAE/D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,OAAqD;IAErD,OAAO,KAAK,EAAE,GAAG,IAAW,EAA4B,EAAE;QACxD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Message Templates
|
|
3
|
+
*
|
|
4
|
+
* Centralized error messages with AI-friendly tips for common error patterns.
|
|
5
|
+
* Eliminates duplication and ensures consistent error messaging.
|
|
6
|
+
*
|
|
7
|
+
* @see Phase 3.3 of refactoring plan
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Error template with AI-friendly tip
|
|
11
|
+
*/
|
|
12
|
+
export interface ErrorTemplate {
|
|
13
|
+
pattern: RegExp | string;
|
|
14
|
+
tip: string;
|
|
15
|
+
category: 'validation' | 'timeout' | 'format' | 'business-logic' | 'network';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Limit validation errors
|
|
19
|
+
*/
|
|
20
|
+
export declare const LIMIT_ERRORS: {
|
|
21
|
+
readonly trade: {
|
|
22
|
+
readonly pattern: RegExp;
|
|
23
|
+
readonly tip: "š” AI TIP: Trade and user operations have a maximum limit of 20. Use:\n- gala_launchpad_fetch_trades: limit ⤠20\n- gala_launchpad_fetch_tokens_held: limit ⤠20\n- gala_launchpad_fetch_tokens_created: limit ⤠20\n\nSee docs/CONSTRAINTS-REFERENCE.md for details.";
|
|
24
|
+
readonly category: "validation";
|
|
25
|
+
};
|
|
26
|
+
readonly comment: {
|
|
27
|
+
readonly pattern: RegExp;
|
|
28
|
+
readonly tip: "š” AI TIP: Comment operations have a maximum limit of 50. Use:\n- gala_launchpad_fetch_comments: limit ⤠50\n\nSee docs/CONSTRAINTS-REFERENCE.md for details.";
|
|
29
|
+
readonly category: "validation";
|
|
30
|
+
};
|
|
31
|
+
readonly pool: {
|
|
32
|
+
readonly pattern: RegExp;
|
|
33
|
+
readonly tip: "š” AI TIP: Pool operations have a maximum limit of 100. Use:\n- gala_launchpad_fetch_pools: limit ⤠100\n\nSee docs/CONSTRAINTS-REFERENCE.md for details.";
|
|
34
|
+
readonly category: "validation";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Token name validation errors
|
|
39
|
+
*/
|
|
40
|
+
export declare const TOKEN_NAME_ERROR: ErrorTemplate;
|
|
41
|
+
/**
|
|
42
|
+
* Token symbol validation errors
|
|
43
|
+
*/
|
|
44
|
+
export declare const TOKEN_SYMBOL_ERROR: ErrorTemplate;
|
|
45
|
+
/**
|
|
46
|
+
* Wallet address format errors
|
|
47
|
+
*/
|
|
48
|
+
export declare const ADDRESS_FORMAT_ERROR: ErrorTemplate;
|
|
49
|
+
/**
|
|
50
|
+
* WebSocket/trade timeout errors
|
|
51
|
+
*/
|
|
52
|
+
export declare const TRADE_TIMEOUT_ERROR: ErrorTemplate;
|
|
53
|
+
/**
|
|
54
|
+
* Slippage/amount errors
|
|
55
|
+
*/
|
|
56
|
+
export declare const SLIPPAGE_ERROR: ErrorTemplate;
|
|
57
|
+
/**
|
|
58
|
+
* Type parameter confusion
|
|
59
|
+
*/
|
|
60
|
+
export declare const TRADE_TYPE_ERROR: ErrorTemplate;
|
|
61
|
+
/**
|
|
62
|
+
* Social URL requirement errors
|
|
63
|
+
*/
|
|
64
|
+
export declare const SOCIAL_URL_ERROR: ErrorTemplate;
|
|
65
|
+
/**
|
|
66
|
+
* Generic validation error
|
|
67
|
+
*/
|
|
68
|
+
export declare const GENERIC_VALIDATION_ERROR: ErrorTemplate;
|
|
69
|
+
/**
|
|
70
|
+
* All error templates in priority order (checked sequentially)
|
|
71
|
+
*/
|
|
72
|
+
export declare const ERROR_TEMPLATES: ErrorTemplate[];
|
|
73
|
+
/**
|
|
74
|
+
* Finds the best matching error template for a message
|
|
75
|
+
*/
|
|
76
|
+
export declare function findErrorTemplate(message: string): ErrorTemplate | null;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the AI-friendly tip for an error message
|
|
79
|
+
*/
|
|
80
|
+
export declare function getErrorTip(message: string): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Applies AI-friendly tip to error message
|
|
83
|
+
*/
|
|
84
|
+
export declare function enhanceErrorMessage(message: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Gets error category for an error message
|
|
87
|
+
*/
|
|
88
|
+
export declare function getErrorCategory(message: string): string;
|
|
89
|
+
export declare const errorTemplates: {
|
|
90
|
+
templates: ErrorTemplate[];
|
|
91
|
+
findTemplate: typeof findErrorTemplate;
|
|
92
|
+
getTip: typeof getErrorTip;
|
|
93
|
+
enhance: typeof enhanceErrorMessage;
|
|
94
|
+
getCategory: typeof getErrorCategory;
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=error-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-templates.d.ts","sourceRoot":"","sources":["../../src/utils/error-templates.ts"],"names":[],"mappings":"A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