midnight-mcp 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
startHttpServer,
|
|
4
4
|
startServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-E5HAMXS3.js";
|
|
6
6
|
import {
|
|
7
7
|
setOutputFormat
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6BPO5SRQ.js";
|
|
9
9
|
|
|
10
10
|
// src/bin.ts
|
|
11
11
|
import { config } from "dotenv";
|
|
@@ -13,7 +13,7 @@ import { resolve } from "path";
|
|
|
13
13
|
import yargs from "yargs";
|
|
14
14
|
import { hideBin } from "yargs/helpers";
|
|
15
15
|
config({ path: resolve(process.cwd(), ".env") });
|
|
16
|
-
var CURRENT_VERSION = "0.2.
|
|
16
|
+
var CURRENT_VERSION = "0.2.5";
|
|
17
17
|
process.on("uncaughtException", (error) => {
|
|
18
18
|
console.error("Uncaught exception:", error);
|
|
19
19
|
process.exit(1);
|
|
@@ -1594,7 +1594,7 @@ async function checkGitHubAPI() {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
async function checkVectorStore() {
|
|
1596
1596
|
try {
|
|
1597
|
-
const { vectorStore: vectorStore2 } = await import("./db-
|
|
1597
|
+
const { vectorStore: vectorStore2 } = await import("./db-F27LE73N.js");
|
|
1598
1598
|
if (vectorStore2) {
|
|
1599
1599
|
return {
|
|
1600
1600
|
status: "pass",
|
|
@@ -1898,7 +1898,9 @@ function pruneAllCaches() {
|
|
|
1898
1898
|
setInterval(pruneAllCaches, 5 * 60 * 1e3);
|
|
1899
1899
|
|
|
1900
1900
|
// src/utils/hosted-api.ts
|
|
1901
|
-
var API_TIMEOUT =
|
|
1901
|
+
var API_TIMEOUT = 15e3;
|
|
1902
|
+
var MAX_RETRIES = 2;
|
|
1903
|
+
var RETRY_DELAY_MS = 1e3;
|
|
1902
1904
|
function getActionableErrorMessage(status, endpoint, serverMessage) {
|
|
1903
1905
|
const baseMessages = {
|
|
1904
1906
|
400: `Bad request to ${endpoint}. Check your query parameters are valid.`,
|
|
@@ -1932,8 +1934,17 @@ async function parseApiError(response, endpoint) {
|
|
|
1932
1934
|
);
|
|
1933
1935
|
return new Error(actionableMessage);
|
|
1934
1936
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
+
function isRetryableError2(error) {
|
|
1938
|
+
if (error instanceof Error) {
|
|
1939
|
+
const message = error.message.toLowerCase();
|
|
1940
|
+
return error.name === "AbortError" || message.includes("timeout") || message.includes("network") || message.includes("econnreset") || message.includes("502") || message.includes("503") || message.includes("504") || message.includes("bad gateway") || message.includes("service unavailable") || message.includes("gateway timeout");
|
|
1941
|
+
}
|
|
1942
|
+
return false;
|
|
1943
|
+
}
|
|
1944
|
+
function sleep2(ms) {
|
|
1945
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1946
|
+
}
|
|
1947
|
+
async function makeRequest(url, endpoint, options) {
|
|
1937
1948
|
const controller = new AbortController();
|
|
1938
1949
|
const timeout = setTimeout(() => controller.abort(), API_TIMEOUT);
|
|
1939
1950
|
try {
|
|
@@ -1953,21 +1964,54 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
1953
1964
|
} catch (error) {
|
|
1954
1965
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1955
1966
|
throw new Error(
|
|
1956
|
-
`Request to ${endpoint} timed out after ${API_TIMEOUT / 1e3}s
|
|
1967
|
+
`Request to ${endpoint} timed out after ${API_TIMEOUT / 1e3}s.`
|
|
1957
1968
|
);
|
|
1958
1969
|
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1970
|
+
throw error;
|
|
1971
|
+
} finally {
|
|
1972
|
+
clearTimeout(timeout);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
async function apiRequest(endpoint, options = {}) {
|
|
1976
|
+
const url = `${config.hostedApiUrl}${endpoint}`;
|
|
1977
|
+
let lastError = null;
|
|
1978
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
1979
|
+
try {
|
|
1980
|
+
return await makeRequest(url, endpoint, options);
|
|
1981
|
+
} catch (error) {
|
|
1982
|
+
lastError = error;
|
|
1983
|
+
if (!isRetryableError2(error)) {
|
|
1984
|
+
break;
|
|
1985
|
+
}
|
|
1986
|
+
if (attempt === MAX_RETRIES) {
|
|
1987
|
+
logger.warn(`Hosted API request failed after ${attempt + 1} attempts`, {
|
|
1988
|
+
endpoint,
|
|
1989
|
+
error: String(error)
|
|
1990
|
+
});
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
1993
|
+
const delay = RETRY_DELAY_MS * Math.pow(2, attempt);
|
|
1994
|
+
logger.debug(
|
|
1995
|
+
`Retrying hosted API request in ${delay}ms (attempt ${attempt + 1}/${MAX_RETRIES + 1})`,
|
|
1996
|
+
{ endpoint }
|
|
1997
|
+
);
|
|
1998
|
+
await sleep2(delay);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
if (lastError) {
|
|
2002
|
+
if (lastError.message.includes("github.com/Olanetsoft")) {
|
|
2003
|
+
throw lastError;
|
|
1961
2004
|
}
|
|
1962
|
-
if (
|
|
2005
|
+
if (lastError.message.includes("timed out")) {
|
|
1963
2006
|
throw new Error(
|
|
1964
|
-
`
|
|
2007
|
+
`Request to ${endpoint} timed out after ${MAX_RETRIES + 1} attempts. The hosted service may be slow or unavailable. Try a simpler query or set MIDNIGHT_LOCAL=true for local search.`
|
|
1965
2008
|
);
|
|
1966
2009
|
}
|
|
1967
|
-
throw
|
|
1968
|
-
|
|
1969
|
-
|
|
2010
|
+
throw new Error(
|
|
2011
|
+
`Failed to connect to hosted API after ${MAX_RETRIES + 1} attempts: ${lastError.message}. Check your internet connection or set MIDNIGHT_LOCAL=true for local search.`
|
|
2012
|
+
);
|
|
1970
2013
|
}
|
|
2014
|
+
throw new Error("Unknown error in API request");
|
|
1971
2015
|
}
|
|
1972
2016
|
async function searchCompactHosted(query, limit = 10) {
|
|
1973
2017
|
logger.debug("Searching Compact code via hosted API", { query });
|
|
@@ -2025,7 +2069,7 @@ function serialize(data) {
|
|
|
2025
2069
|
}
|
|
2026
2070
|
|
|
2027
2071
|
// src/utils/version.ts
|
|
2028
|
-
var CURRENT_VERSION = "0.2.
|
|
2072
|
+
var CURRENT_VERSION = "0.2.5";
|
|
2029
2073
|
|
|
2030
2074
|
// src/db/vectorStore.ts
|
|
2031
2075
|
var VectorStore = class {
|
|
@@ -2234,4 +2278,4 @@ export {
|
|
|
2234
2278
|
serialize,
|
|
2235
2279
|
CURRENT_VERSION
|
|
2236
2280
|
};
|
|
2237
|
-
//# sourceMappingURL=chunk-
|
|
2281
|
+
//# sourceMappingURL=chunk-6BPO5SRQ.js.map
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
validateNumber,
|
|
26
26
|
validateQuery,
|
|
27
27
|
vectorStore
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-6BPO5SRQ.js";
|
|
29
29
|
|
|
30
30
|
// src/tools/search/schemas.ts
|
|
31
31
|
import { z } from "zod";
|
|
@@ -9292,4 +9292,4 @@ export {
|
|
|
9292
9292
|
startServer,
|
|
9293
9293
|
startHttpServer
|
|
9294
9294
|
};
|
|
9295
|
-
//# sourceMappingURL=chunk-
|
|
9295
|
+
//# sourceMappingURL=chunk-E5HAMXS3.js.map
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
promptDefinitions,
|
|
10
10
|
startHttpServer,
|
|
11
11
|
startServer
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-E5HAMXS3.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6BPO5SRQ.js";
|
|
16
16
|
export {
|
|
17
17
|
allResources,
|
|
18
18
|
allTools,
|
package/package.json
CHANGED