midnight-mcp 0.1.41 → 0.2.2
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/README.md +32 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +60 -0
- package/dist/chunk-HOWO4K5A.js +2197 -0
- package/dist/chunk-S7G4OHA4.js +8306 -0
- package/dist/db-YDGUWI5K.js +7 -0
- package/dist/index.d.ts +205 -3
- package/dist/index.js +28 -16
- package/package.json +16 -6
- package/dist/config/compact-version.d.ts +0 -183
- package/dist/config/compact-version.js +0 -423
- package/dist/db/index.d.ts +0 -3
- package/dist/db/index.js +0 -2
- package/dist/db/vectorStore.d.ts +0 -69
- package/dist/db/vectorStore.js +0 -196
- package/dist/pipeline/embeddings.d.ts +0 -25
- package/dist/pipeline/embeddings.js +0 -103
- package/dist/pipeline/github.d.ts +0 -84
- package/dist/pipeline/github.js +0 -399
- package/dist/pipeline/index.d.ts +0 -11
- package/dist/pipeline/index.js +0 -6
- package/dist/pipeline/indexer.d.ts +0 -41
- package/dist/pipeline/indexer.js +0 -254
- package/dist/pipeline/parser.d.ts +0 -46
- package/dist/pipeline/parser.js +0 -436
- package/dist/pipeline/releases.d.ts +0 -112
- package/dist/pipeline/releases.js +0 -298
- package/dist/pipeline/repository.d.ts +0 -372
- package/dist/pipeline/repository.js +0 -520
- package/dist/prompts/index.d.ts +0 -3
- package/dist/prompts/index.js +0 -2
- package/dist/prompts/templates.d.ts +0 -26
- package/dist/prompts/templates.js +0 -443
- package/dist/resources/code.d.ts +0 -15
- package/dist/resources/code.js +0 -122
- package/dist/resources/content/code-content.d.ts +0 -6
- package/dist/resources/content/code-content.js +0 -802
- package/dist/resources/content/docs-content.d.ts +0 -14
- package/dist/resources/content/docs-content.js +0 -1202
- package/dist/resources/content/index.d.ts +0 -6
- package/dist/resources/content/index.js +0 -6
- package/dist/resources/docs.d.ts +0 -15
- package/dist/resources/docs.js +0 -98
- package/dist/resources/index.d.ts +0 -6
- package/dist/resources/index.js +0 -13
- package/dist/resources/schemas.d.ts +0 -16
- package/dist/resources/schemas.js +0 -407
- package/dist/scripts/index-repos.d.ts +0 -12
- package/dist/scripts/index-repos.js +0 -53
- package/dist/server.d.ts +0 -43
- package/dist/server.js +0 -696
- package/dist/services/index.d.ts +0 -6
- package/dist/services/index.js +0 -6
- package/dist/services/sampling.d.ts +0 -62
- package/dist/services/sampling.js +0 -277
- package/dist/tools/analyze.d.ts +0 -106
- package/dist/tools/analyze.js +0 -431
- package/dist/tools/generation.d.ts +0 -9
- package/dist/tools/generation.js +0 -285
- package/dist/tools/health.d.ts +0 -120
- package/dist/tools/health.js +0 -365
- package/dist/tools/index.d.ts +0 -14
- package/dist/tools/index.js +0 -22
- package/dist/tools/meta.d.ts +0 -61
- package/dist/tools/meta.js +0 -282
- package/dist/tools/repository/constants.d.ts +0 -19
- package/dist/tools/repository/constants.js +0 -324
- package/dist/tools/repository/handlers.d.ts +0 -373
- package/dist/tools/repository/handlers.js +0 -724
- package/dist/tools/repository/index.d.ts +0 -9
- package/dist/tools/repository/index.js +0 -13
- package/dist/tools/repository/schemas.d.ts +0 -153
- package/dist/tools/repository/schemas.js +0 -106
- package/dist/tools/repository/tools.d.ts +0 -7
- package/dist/tools/repository/tools.js +0 -484
- package/dist/tools/repository/validation.d.ts +0 -106
- package/dist/tools/repository/validation.js +0 -820
- package/dist/tools/repository.d.ts +0 -6
- package/dist/tools/repository.js +0 -7
- package/dist/tools/search.d.ts +0 -76
- package/dist/tools/search.js +0 -423
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/mcp.d.ts +0 -187
- package/dist/types/mcp.js +0 -6
- package/dist/utils/cache.d.ts +0 -77
- package/dist/utils/cache.js +0 -172
- package/dist/utils/config.d.ts +0 -70
- package/dist/utils/config.js +0 -294
- package/dist/utils/errors.d.ts +0 -111
- package/dist/utils/errors.js +0 -165
- package/dist/utils/health.d.ts +0 -29
- package/dist/utils/health.js +0 -132
- package/dist/utils/hosted-api.d.ts +0 -67
- package/dist/utils/hosted-api.js +0 -119
- package/dist/utils/index.d.ts +0 -16
- package/dist/utils/index.js +0 -15
- package/dist/utils/logger.d.ts +0 -48
- package/dist/utils/logger.js +0 -124
- package/dist/utils/rate-limit.d.ts +0 -61
- package/dist/utils/rate-limit.js +0 -148
- package/dist/utils/validation.d.ts +0 -52
- package/dist/utils/validation.js +0 -255
package/dist/utils/config.js
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import dotenv from "dotenv";
|
|
3
|
-
dotenv.config();
|
|
4
|
-
const ConfigSchema = z.object({
|
|
5
|
-
// Mode: 'hosted' (default) or 'local'
|
|
6
|
-
mode: z.enum(["hosted", "local"]).default("hosted"),
|
|
7
|
-
// Hosted API URL (used when mode is 'hosted')
|
|
8
|
-
hostedApiUrl: z
|
|
9
|
-
.string()
|
|
10
|
-
.default("https://midnight-mcp-api.midnightmcp.workers.dev"),
|
|
11
|
-
// GitHub
|
|
12
|
-
githubToken: z.string().optional(),
|
|
13
|
-
// Vector Database (only needed for local mode)
|
|
14
|
-
chromaUrl: z.string().default("http://localhost:8000"),
|
|
15
|
-
// Embeddings (only needed for local mode)
|
|
16
|
-
openaiApiKey: z.string().optional(),
|
|
17
|
-
embeddingModel: z.string().default("text-embedding-3-small"),
|
|
18
|
-
// Server
|
|
19
|
-
logLevel: z.enum(["debug", "info", "warn", "error"]).default("info"),
|
|
20
|
-
syncInterval: z.number().default(900000), // 15 minutes
|
|
21
|
-
port: z.number().default(3000),
|
|
22
|
-
// Data directories
|
|
23
|
-
dataDir: z.string().default("./data"),
|
|
24
|
-
cacheDir: z.string().default("./cache"),
|
|
25
|
-
});
|
|
26
|
-
function loadConfig() {
|
|
27
|
-
// Determine mode: local if MIDNIGHT_LOCAL=true or if OPENAI_API_KEY is set
|
|
28
|
-
const isLocalMode = process.env.MIDNIGHT_LOCAL === "true" ||
|
|
29
|
-
(process.env.OPENAI_API_KEY && process.env.CHROMA_URL);
|
|
30
|
-
const rawConfig = {
|
|
31
|
-
mode: isLocalMode ? "local" : "hosted",
|
|
32
|
-
hostedApiUrl: process.env.MIDNIGHT_API_URL,
|
|
33
|
-
githubToken: process.env.GITHUB_TOKEN,
|
|
34
|
-
chromaUrl: process.env.CHROMA_URL,
|
|
35
|
-
openaiApiKey: process.env.OPENAI_API_KEY,
|
|
36
|
-
embeddingModel: process.env.EMBEDDING_MODEL,
|
|
37
|
-
logLevel: process.env.LOG_LEVEL,
|
|
38
|
-
syncInterval: process.env.SYNC_INTERVAL
|
|
39
|
-
? parseInt(process.env.SYNC_INTERVAL)
|
|
40
|
-
: undefined,
|
|
41
|
-
port: process.env.PORT ? parseInt(process.env.PORT) : undefined,
|
|
42
|
-
dataDir: process.env.DATA_DIR,
|
|
43
|
-
cacheDir: process.env.CACHE_DIR,
|
|
44
|
-
};
|
|
45
|
-
// Remove undefined values
|
|
46
|
-
const cleanConfig = Object.fromEntries(Object.entries(rawConfig).filter(([_, v]) => v !== undefined));
|
|
47
|
-
return ConfigSchema.parse(cleanConfig);
|
|
48
|
-
}
|
|
49
|
-
export const config = loadConfig();
|
|
50
|
-
/**
|
|
51
|
-
* Check if running in hosted mode (default)
|
|
52
|
-
*/
|
|
53
|
-
export function isHostedMode() {
|
|
54
|
-
return config.mode === "hosted";
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Check if running in local mode
|
|
58
|
-
*/
|
|
59
|
-
export function isLocalMode() {
|
|
60
|
-
return config.mode === "local";
|
|
61
|
-
}
|
|
62
|
-
export const DEFAULT_REPOSITORIES = [
|
|
63
|
-
// Core Language & SDK
|
|
64
|
-
{
|
|
65
|
-
owner: "midnightntwrk",
|
|
66
|
-
repo: "compact",
|
|
67
|
-
branch: "main",
|
|
68
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
69
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
owner: "midnightntwrk",
|
|
73
|
-
repo: "midnight-js",
|
|
74
|
-
branch: "main",
|
|
75
|
-
patterns: ["**/*.ts", "**/*.md"],
|
|
76
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
77
|
-
},
|
|
78
|
-
// Documentation
|
|
79
|
-
{
|
|
80
|
-
owner: "midnightntwrk",
|
|
81
|
-
repo: "midnight-docs",
|
|
82
|
-
branch: "main",
|
|
83
|
-
patterns: ["**/*.md", "**/*.mdx"],
|
|
84
|
-
exclude: ["node_modules/**"],
|
|
85
|
-
},
|
|
86
|
-
// Example DApps
|
|
87
|
-
{
|
|
88
|
-
owner: "midnightntwrk",
|
|
89
|
-
repo: "example-counter",
|
|
90
|
-
branch: "main",
|
|
91
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
92
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
owner: "midnightntwrk",
|
|
96
|
-
repo: "example-bboard",
|
|
97
|
-
branch: "main",
|
|
98
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.tsx", "**/*.md"],
|
|
99
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
owner: "midnightntwrk",
|
|
103
|
-
repo: "example-dex",
|
|
104
|
-
branch: "main",
|
|
105
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.tsx", "**/*.md"],
|
|
106
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
107
|
-
},
|
|
108
|
-
// Developer Tools
|
|
109
|
-
{
|
|
110
|
-
owner: "midnightntwrk",
|
|
111
|
-
repo: "create-mn-app",
|
|
112
|
-
branch: "main",
|
|
113
|
-
patterns: ["**/*.ts", "**/*.md", "**/*.json"],
|
|
114
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
owner: "midnightntwrk",
|
|
118
|
-
repo: "midnight-wallet",
|
|
119
|
-
branch: "main",
|
|
120
|
-
patterns: ["**/*.ts", "**/*.tsx", "**/*.md"],
|
|
121
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
122
|
-
},
|
|
123
|
-
// Infrastructure
|
|
124
|
-
{
|
|
125
|
-
owner: "midnightntwrk",
|
|
126
|
-
repo: "midnight-indexer",
|
|
127
|
-
branch: "main",
|
|
128
|
-
patterns: ["**/*.ts", "**/*.md", "**/*.rs"],
|
|
129
|
-
exclude: ["node_modules/**", "dist/**", "target/**"],
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
owner: "midnightntwrk",
|
|
133
|
-
repo: "midnight-node-docker",
|
|
134
|
-
branch: "main",
|
|
135
|
-
patterns: ["**/*.md", "**/Dockerfile", "**/*.yml", "**/*.yaml"],
|
|
136
|
-
exclude: [],
|
|
137
|
-
},
|
|
138
|
-
// APIs & Connectors
|
|
139
|
-
{
|
|
140
|
-
owner: "midnightntwrk",
|
|
141
|
-
repo: "midnight-dapp-connector-api",
|
|
142
|
-
branch: "main",
|
|
143
|
-
patterns: ["**/*.ts", "**/*.md"],
|
|
144
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
145
|
-
},
|
|
146
|
-
// Tooling
|
|
147
|
-
{
|
|
148
|
-
owner: "midnightntwrk",
|
|
149
|
-
repo: "compact-tree-sitter",
|
|
150
|
-
branch: "main",
|
|
151
|
-
patterns: ["**/*.js", "**/*.md", "**/*.scm"],
|
|
152
|
-
exclude: ["node_modules/**"],
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
owner: "midnightntwrk",
|
|
156
|
-
repo: "setup-compact-action",
|
|
157
|
-
branch: "main",
|
|
158
|
-
patterns: ["**/*.ts", "**/*.js", "**/*.md", "**/*.yml", "**/*.yaml"],
|
|
159
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
160
|
-
},
|
|
161
|
-
// Community
|
|
162
|
-
{
|
|
163
|
-
owner: "midnightntwrk",
|
|
164
|
-
repo: "midnight-awesome-dapps",
|
|
165
|
-
branch: "main",
|
|
166
|
-
patterns: ["**/*.md"],
|
|
167
|
-
exclude: [],
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
owner: "midnightntwrk",
|
|
171
|
-
repo: "contributor-hub",
|
|
172
|
-
branch: "main",
|
|
173
|
-
patterns: ["**/*.md"],
|
|
174
|
-
exclude: [],
|
|
175
|
-
},
|
|
176
|
-
// Partner Libraries (OpenZeppelin)
|
|
177
|
-
{
|
|
178
|
-
owner: "OpenZeppelin",
|
|
179
|
-
repo: "compact-contracts",
|
|
180
|
-
branch: "main",
|
|
181
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
182
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
owner: "OpenZeppelin",
|
|
186
|
-
repo: "midnight-apps",
|
|
187
|
-
branch: "main",
|
|
188
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
189
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
190
|
-
},
|
|
191
|
-
// Official Partners (from awesome-dapps)
|
|
192
|
-
{
|
|
193
|
-
owner: "bricktowers",
|
|
194
|
-
repo: "midnight-seabattle",
|
|
195
|
-
branch: "main",
|
|
196
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
197
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
owner: "bricktowers",
|
|
201
|
-
repo: "midnight-identity",
|
|
202
|
-
branch: "main",
|
|
203
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
204
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
owner: "bricktowers",
|
|
208
|
-
repo: "midnight-rwa",
|
|
209
|
-
branch: "main",
|
|
210
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
211
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
owner: "MeshJS",
|
|
215
|
-
repo: "midnight-starter-template",
|
|
216
|
-
branch: "main",
|
|
217
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
218
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
owner: "midnames",
|
|
222
|
-
repo: "core",
|
|
223
|
-
branch: "main",
|
|
224
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
225
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
226
|
-
},
|
|
227
|
-
// Sea Battle Hackathon Winners (Feb 2025)
|
|
228
|
-
{
|
|
229
|
-
owner: "ErickRomeroDev",
|
|
230
|
-
repo: "naval-battle-game_v2",
|
|
231
|
-
branch: "main",
|
|
232
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.tsx", "**/*.md"],
|
|
233
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
owner: "eddex",
|
|
237
|
-
repo: "midnight-sea-battle-hackathon",
|
|
238
|
-
branch: "main",
|
|
239
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
240
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
241
|
-
},
|
|
242
|
-
// Mini DApp Hackathon Winners (Sep 2025)
|
|
243
|
-
{
|
|
244
|
-
owner: "statera-protocol",
|
|
245
|
-
repo: "statera-protocol-midnight",
|
|
246
|
-
branch: "main",
|
|
247
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
248
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
owner: "nel349",
|
|
252
|
-
repo: "midnight-bank",
|
|
253
|
-
branch: "main",
|
|
254
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
255
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
owner: "Imdavyking",
|
|
259
|
-
repo: "zkbadge",
|
|
260
|
-
branch: "main",
|
|
261
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.md"],
|
|
262
|
-
exclude: ["node_modules/**", "dist/**"],
|
|
263
|
-
},
|
|
264
|
-
// Core Partner - PaimaStudios (Gaming Infrastructure)
|
|
265
|
-
{
|
|
266
|
-
owner: "PaimaStudios",
|
|
267
|
-
repo: "midnight-game-2",
|
|
268
|
-
branch: "main",
|
|
269
|
-
patterns: ["**/*.compact", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.md"],
|
|
270
|
-
exclude: ["node_modules/**", "dist/**", "phaser/node_modules/**"],
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
owner: "PaimaStudios",
|
|
274
|
-
repo: "midnight-wasm-prover",
|
|
275
|
-
branch: "main",
|
|
276
|
-
patterns: ["**/*.rs", "**/*.ts", "**/*.md"],
|
|
277
|
-
exclude: ["target/**", "node_modules/**", "pkg/**"],
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
owner: "PaimaStudios",
|
|
281
|
-
repo: "midnight-batcher",
|
|
282
|
-
branch: "main",
|
|
283
|
-
patterns: ["**/*.rs", "**/*.ts", "**/*.md"],
|
|
284
|
-
exclude: ["target/**", "node_modules/**"],
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
owner: "PaimaStudios",
|
|
288
|
-
repo: "midnight-impact-rps-example",
|
|
289
|
-
branch: "main",
|
|
290
|
-
patterns: ["**/*.rs", "**/*.ts", "**/*.md"],
|
|
291
|
-
exclude: ["target/**", "node_modules/**", "www/pkg/**"],
|
|
292
|
-
},
|
|
293
|
-
];
|
|
294
|
-
//# sourceMappingURL=config.js.map
|
package/dist/utils/errors.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User-friendly error messages and error handling utilities
|
|
3
|
-
*/
|
|
4
|
-
export declare class MCPError extends Error {
|
|
5
|
-
readonly code: string;
|
|
6
|
-
readonly suggestion?: string;
|
|
7
|
-
readonly details?: Record<string, unknown>;
|
|
8
|
-
constructor(message: string, code: string, suggestion?: string, details?: Record<string, unknown>);
|
|
9
|
-
toJSON(): {
|
|
10
|
-
details?: Record<string, unknown> | undefined;
|
|
11
|
-
error: string;
|
|
12
|
-
code: string;
|
|
13
|
-
suggestion: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Common error codes
|
|
18
|
-
*/
|
|
19
|
-
export declare const ErrorCodes: {
|
|
20
|
-
readonly RATE_LIMIT: "RATE_LIMIT_EXCEEDED";
|
|
21
|
-
readonly NOT_FOUND: "RESOURCE_NOT_FOUND";
|
|
22
|
-
readonly NETWORK: "NETWORK_ERROR";
|
|
23
|
-
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
24
|
-
readonly UNKNOWN_REPO: "UNKNOWN_REPOSITORY";
|
|
25
|
-
readonly PARSE_ERROR: "PARSE_ERROR";
|
|
26
|
-
readonly CHROMADB_UNAVAILABLE: "CHROMADB_UNAVAILABLE";
|
|
27
|
-
readonly OPENAI_UNAVAILABLE: "OPENAI_UNAVAILABLE";
|
|
28
|
-
readonly MISSING_PARAM: "MISSING_PARAMETER";
|
|
29
|
-
readonly INVALID_VERSION: "INVALID_VERSION";
|
|
30
|
-
readonly SAMPLING_UNAVAILABLE: "SAMPLING_UNAVAILABLE";
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* LLM-friendly error hints that help the model self-correct
|
|
34
|
-
* These are designed to give the AI enough context to retry with corrected input
|
|
35
|
-
*/
|
|
36
|
-
export declare const SelfCorrectionHints: {
|
|
37
|
-
UNKNOWN_REPO: (repo: string, validRepos: string[]) => {
|
|
38
|
-
error: string;
|
|
39
|
-
code: "UNKNOWN_REPOSITORY";
|
|
40
|
-
suggestion: string;
|
|
41
|
-
correction: {
|
|
42
|
-
invalidValue: string;
|
|
43
|
-
validValues: string[];
|
|
44
|
-
parameterName: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
INVALID_VERSION: (version: string, example: string) => {
|
|
48
|
-
error: string;
|
|
49
|
-
code: "INVALID_VERSION";
|
|
50
|
-
suggestion: string;
|
|
51
|
-
correction: {
|
|
52
|
-
invalidValue: string;
|
|
53
|
-
expectedFormat: string;
|
|
54
|
-
example: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
MISSING_REQUIRED_PARAM: (paramName: string, toolName: string) => {
|
|
58
|
-
error: string;
|
|
59
|
-
code: "MISSING_PARAMETER";
|
|
60
|
-
suggestion: string;
|
|
61
|
-
correction: {
|
|
62
|
-
missingParameter: string;
|
|
63
|
-
tool: string;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
FILE_NOT_FOUND: (path: string, repo: string, similarPaths?: string[]) => {
|
|
67
|
-
error: string;
|
|
68
|
-
code: "RESOURCE_NOT_FOUND";
|
|
69
|
-
suggestion: string;
|
|
70
|
-
correction: {
|
|
71
|
-
suggestions?: string[] | undefined;
|
|
72
|
-
invalidPath: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
SAMPLING_NOT_AVAILABLE: (toolName: string) => {
|
|
76
|
-
error: string;
|
|
77
|
-
code: "SAMPLING_UNAVAILABLE";
|
|
78
|
-
suggestion: string;
|
|
79
|
-
alternatives: {
|
|
80
|
-
"midnight-generate-contract": string;
|
|
81
|
-
"midnight-review-contract": string;
|
|
82
|
-
"midnight-document-contract": string;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
RATE_LIMIT: (retryAfter?: number) => {
|
|
86
|
-
error: string;
|
|
87
|
-
code: "RATE_LIMIT_EXCEEDED";
|
|
88
|
-
suggestion: string;
|
|
89
|
-
correction: {
|
|
90
|
-
retryAfterSeconds?: number | undefined;
|
|
91
|
-
action: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Create user-friendly error from various error types
|
|
97
|
-
*/
|
|
98
|
-
export declare function createUserError(error: unknown, context?: string): MCPError;
|
|
99
|
-
/**
|
|
100
|
-
* Format error for MCP response
|
|
101
|
-
*/
|
|
102
|
-
export declare function formatErrorResponse(error: unknown, context?: string): {
|
|
103
|
-
error: string;
|
|
104
|
-
code: string;
|
|
105
|
-
suggestion?: string;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Wrap a function with error handling
|
|
109
|
-
*/
|
|
110
|
-
export declare function withErrorHandling<T extends (...args: unknown[]) => Promise<unknown>>(fn: T, context: string): T;
|
|
111
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/utils/errors.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User-friendly error messages and error handling utilities
|
|
3
|
-
*/
|
|
4
|
-
export class MCPError extends Error {
|
|
5
|
-
code;
|
|
6
|
-
suggestion;
|
|
7
|
-
details;
|
|
8
|
-
constructor(message, code, suggestion, details) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.name = "MCPError";
|
|
11
|
-
this.code = code;
|
|
12
|
-
this.suggestion = suggestion;
|
|
13
|
-
this.details = details;
|
|
14
|
-
}
|
|
15
|
-
toJSON() {
|
|
16
|
-
return {
|
|
17
|
-
error: this.message,
|
|
18
|
-
code: this.code,
|
|
19
|
-
suggestion: this.suggestion,
|
|
20
|
-
...(this.details && { details: this.details }),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Common error codes
|
|
26
|
-
*/
|
|
27
|
-
export const ErrorCodes = {
|
|
28
|
-
RATE_LIMIT: "RATE_LIMIT_EXCEEDED",
|
|
29
|
-
NOT_FOUND: "RESOURCE_NOT_FOUND",
|
|
30
|
-
NETWORK: "NETWORK_ERROR",
|
|
31
|
-
INVALID_INPUT: "INVALID_INPUT",
|
|
32
|
-
UNKNOWN_REPO: "UNKNOWN_REPOSITORY",
|
|
33
|
-
PARSE_ERROR: "PARSE_ERROR",
|
|
34
|
-
CHROMADB_UNAVAILABLE: "CHROMADB_UNAVAILABLE",
|
|
35
|
-
OPENAI_UNAVAILABLE: "OPENAI_UNAVAILABLE",
|
|
36
|
-
MISSING_PARAM: "MISSING_PARAMETER",
|
|
37
|
-
INVALID_VERSION: "INVALID_VERSION",
|
|
38
|
-
SAMPLING_UNAVAILABLE: "SAMPLING_UNAVAILABLE",
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* LLM-friendly error hints that help the model self-correct
|
|
42
|
-
* These are designed to give the AI enough context to retry with corrected input
|
|
43
|
-
*/
|
|
44
|
-
export const SelfCorrectionHints = {
|
|
45
|
-
UNKNOWN_REPO: (repo, validRepos) => ({
|
|
46
|
-
error: `Unknown repository: '${repo}'`,
|
|
47
|
-
code: ErrorCodes.UNKNOWN_REPO,
|
|
48
|
-
suggestion: `Try one of these instead: ${validRepos.slice(0, 8).join(", ")}`,
|
|
49
|
-
correction: {
|
|
50
|
-
invalidValue: repo,
|
|
51
|
-
validValues: validRepos,
|
|
52
|
-
parameterName: "repo",
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
55
|
-
INVALID_VERSION: (version, example) => ({
|
|
56
|
-
error: `Invalid version format: '${version}'`,
|
|
57
|
-
code: ErrorCodes.INVALID_VERSION,
|
|
58
|
-
suggestion: `Version should be like '${example}'. Check available versions with midnight-get-version-info first.`,
|
|
59
|
-
correction: {
|
|
60
|
-
invalidValue: version,
|
|
61
|
-
expectedFormat: "v1.0.0 or 0.14.0",
|
|
62
|
-
example,
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
MISSING_REQUIRED_PARAM: (paramName, toolName) => ({
|
|
66
|
-
error: `Missing required parameter: '${paramName}'`,
|
|
67
|
-
code: ErrorCodes.MISSING_PARAM,
|
|
68
|
-
suggestion: `The '${paramName}' parameter is required for ${toolName}. Please provide it.`,
|
|
69
|
-
correction: {
|
|
70
|
-
missingParameter: paramName,
|
|
71
|
-
tool: toolName,
|
|
72
|
-
},
|
|
73
|
-
}),
|
|
74
|
-
FILE_NOT_FOUND: (path, repo, similarPaths) => ({
|
|
75
|
-
error: `File not found: '${path}' in ${repo}`,
|
|
76
|
-
code: ErrorCodes.NOT_FOUND,
|
|
77
|
-
suggestion: similarPaths?.length
|
|
78
|
-
? `Did you mean: ${similarPaths.join(", ")}?`
|
|
79
|
-
: `Check the file path. Use midnight-get-file with a different path or list directory contents first.`,
|
|
80
|
-
correction: {
|
|
81
|
-
invalidPath: path,
|
|
82
|
-
...(similarPaths && { suggestions: similarPaths }),
|
|
83
|
-
},
|
|
84
|
-
}),
|
|
85
|
-
SAMPLING_NOT_AVAILABLE: (toolName) => ({
|
|
86
|
-
error: `Sampling capability not available`,
|
|
87
|
-
code: ErrorCodes.SAMPLING_UNAVAILABLE,
|
|
88
|
-
suggestion: `${toolName} requires a client that supports sampling (e.g., Claude Desktop). Use a non-AI alternative or switch clients.`,
|
|
89
|
-
alternatives: {
|
|
90
|
-
"midnight-generate-contract": "Use midnight-search-compact to find similar contracts as templates",
|
|
91
|
-
"midnight-review-contract": "Use midnight-analyze-contract for static analysis",
|
|
92
|
-
"midnight-document-contract": "Manual documentation or inline comments",
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
95
|
-
RATE_LIMIT: (retryAfter) => ({
|
|
96
|
-
error: "GitHub API rate limit exceeded",
|
|
97
|
-
code: ErrorCodes.RATE_LIMIT,
|
|
98
|
-
suggestion: retryAfter
|
|
99
|
-
? `Wait ${retryAfter} seconds before retrying. Or add GITHUB_TOKEN for higher limits.`
|
|
100
|
-
: "Add GITHUB_TOKEN to increase from 60 to 5000 requests/hour.",
|
|
101
|
-
correction: {
|
|
102
|
-
action: "wait_and_retry",
|
|
103
|
-
...(retryAfter && { retryAfterSeconds: retryAfter }),
|
|
104
|
-
},
|
|
105
|
-
}),
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Create user-friendly error from various error types
|
|
109
|
-
*/
|
|
110
|
-
export function createUserError(error, context) {
|
|
111
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
112
|
-
const ctx = context ? ` while ${context}` : "";
|
|
113
|
-
// Rate limit errors
|
|
114
|
-
if (message.includes("rate limit") ||
|
|
115
|
-
message.includes("403") ||
|
|
116
|
-
message.includes("API rate limit")) {
|
|
117
|
-
return new MCPError(`GitHub API rate limit exceeded${ctx}`, ErrorCodes.RATE_LIMIT, "Add GITHUB_TOKEN to your config to increase limits from 60 to 5000 requests/hour. " +
|
|
118
|
-
"Get a token at https://github.com/settings/tokens");
|
|
119
|
-
}
|
|
120
|
-
// Not found errors
|
|
121
|
-
if (message.includes("404") || message.includes("Not Found")) {
|
|
122
|
-
return new MCPError(`Resource not found${ctx}`, ErrorCodes.NOT_FOUND, "Check that the repository, file, or version exists and is publicly accessible.");
|
|
123
|
-
}
|
|
124
|
-
// Network errors
|
|
125
|
-
if (message.includes("network") ||
|
|
126
|
-
message.includes("ECONNREFUSED") ||
|
|
127
|
-
message.includes("ETIMEDOUT") ||
|
|
128
|
-
message.includes("timeout")) {
|
|
129
|
-
return new MCPError(`Network error${ctx}`, ErrorCodes.NETWORK, "Check your internet connection and try again. If the problem persists, " +
|
|
130
|
-
"the service may be temporarily unavailable.");
|
|
131
|
-
}
|
|
132
|
-
// ChromaDB errors
|
|
133
|
-
if (message.includes("chroma") || message.includes("8000")) {
|
|
134
|
-
return new MCPError(`ChromaDB is not available${ctx}`, ErrorCodes.CHROMADB_UNAVAILABLE, "ChromaDB is optional. Without it, search uses keyword matching instead of semantic search. " +
|
|
135
|
-
"To enable semantic search, run: docker run -d -p 8000:8000 chromadb/chroma");
|
|
136
|
-
}
|
|
137
|
-
// OpenAI errors
|
|
138
|
-
if (message.includes("openai") || message.includes("embedding")) {
|
|
139
|
-
return new MCPError(`OpenAI API error${ctx}`, ErrorCodes.OPENAI_UNAVAILABLE, "OpenAI is optional. Without it, search uses keyword matching. " +
|
|
140
|
-
"To enable semantic search, add OPENAI_API_KEY to your config.");
|
|
141
|
-
}
|
|
142
|
-
// Default error - don't leak internal details
|
|
143
|
-
return new MCPError(`An error occurred${ctx}`, "UNKNOWN_ERROR", "If this problem persists, please report it at https://github.com/Olanetsoft/midnight-mcp/issues");
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Format error for MCP response
|
|
147
|
-
*/
|
|
148
|
-
export function formatErrorResponse(error, context) {
|
|
149
|
-
const mcpError = error instanceof MCPError ? error : createUserError(error, context);
|
|
150
|
-
return mcpError.toJSON();
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Wrap a function with error handling
|
|
154
|
-
*/
|
|
155
|
-
export function withErrorHandling(fn, context) {
|
|
156
|
-
return (async (...args) => {
|
|
157
|
-
try {
|
|
158
|
-
return await fn(...args);
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
throw createUserError(error, context);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/utils/health.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Health check utilities for MCP server monitoring
|
|
3
|
-
*/
|
|
4
|
-
export interface HealthStatus {
|
|
5
|
-
status: "healthy" | "degraded" | "unhealthy";
|
|
6
|
-
timestamp: string;
|
|
7
|
-
version: string;
|
|
8
|
-
uptime: number;
|
|
9
|
-
checks: {
|
|
10
|
-
name: string;
|
|
11
|
-
status: "pass" | "warn" | "fail";
|
|
12
|
-
message?: string;
|
|
13
|
-
latency?: number;
|
|
14
|
-
}[];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Perform a full health check
|
|
18
|
-
*/
|
|
19
|
-
export declare function getHealthStatus(): Promise<HealthStatus>;
|
|
20
|
-
/**
|
|
21
|
-
* Get a quick health check (no external calls)
|
|
22
|
-
*/
|
|
23
|
-
export declare function getQuickHealthStatus(): Omit<HealthStatus, "checks"> & {
|
|
24
|
-
checks: {
|
|
25
|
-
name: string;
|
|
26
|
-
status: "pass";
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=health.d.ts.map
|