@arabold/docs-mcp-server 2.2.0 → 2.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 +14 -0
- package/dist/index.js +1 -1
- package/dist/{main-B6iwx1JH.js → main-DPijzQ1K.js} +428 -121
- package/dist/main-DPijzQ1K.js.map +1 -0
- package/package.json +1 -1
- package/dist/main-B6iwx1JH.js.map +0 -1
|
@@ -368,10 +368,12 @@ const DEFAULT_CONFIG = {
|
|
|
368
368
|
maxPages: 1e3,
|
|
369
369
|
maxDepth: 3,
|
|
370
370
|
maxConcurrency: 3,
|
|
371
|
+
abortOnFailureRate: 0.5,
|
|
372
|
+
preserveHashes: false,
|
|
371
373
|
pageTimeoutMs: 5e3,
|
|
372
374
|
browserTimeoutMs: 3e4,
|
|
373
375
|
fetcher: {
|
|
374
|
-
maxRetries:
|
|
376
|
+
maxRetries: 3,
|
|
375
377
|
baseDelayMs: 1e3,
|
|
376
378
|
maxCacheItems: 200,
|
|
377
379
|
maxCacheItemSizeBytes: 500 * 1024
|
|
@@ -446,6 +448,8 @@ const AppConfigSchema = z.object({
|
|
|
446
448
|
maxPages: z.coerce.number().int().default(DEFAULT_CONFIG.scraper.maxPages),
|
|
447
449
|
maxDepth: z.coerce.number().int().default(DEFAULT_CONFIG.scraper.maxDepth),
|
|
448
450
|
maxConcurrency: z.coerce.number().int().default(DEFAULT_CONFIG.scraper.maxConcurrency),
|
|
451
|
+
abortOnFailureRate: z.coerce.number().min(0).max(1).default(DEFAULT_CONFIG.scraper.abortOnFailureRate),
|
|
452
|
+
preserveHashes: envBoolean.default(DEFAULT_CONFIG.scraper.preserveHashes),
|
|
449
453
|
pageTimeoutMs: z.coerce.number().int().default(DEFAULT_CONFIG.scraper.pageTimeoutMs),
|
|
450
454
|
browserTimeoutMs: z.coerce.number().int().default(DEFAULT_CONFIG.scraper.browserTimeoutMs),
|
|
451
455
|
fetcher: z.object({
|
|
@@ -935,6 +939,28 @@ function createAuthMiddleware(authManager) {
|
|
|
935
939
|
}
|
|
936
940
|
};
|
|
937
941
|
}
|
|
942
|
+
const ALLOWED_GRANT_TYPES = /* @__PURE__ */ new Set(["authorization_code", "refresh_token"]);
|
|
943
|
+
const ALLOWED_RESPONSE_TYPES = /* @__PURE__ */ new Set(["code"]);
|
|
944
|
+
async function sendUpstreamJsonResponse(reply, response, upstream) {
|
|
945
|
+
const text = await response.text();
|
|
946
|
+
if (text.length > 0) {
|
|
947
|
+
try {
|
|
948
|
+
const data = JSON.parse(text);
|
|
949
|
+
if (data !== null && typeof data === "object") {
|
|
950
|
+
reply.status(response.status).type("application/json").send(data);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
} catch {
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
logger.warn(
|
|
957
|
+
`Upstream ${upstream} endpoint returned a non-JSON-object body (status=${response.status}, bytes=${text.length})`
|
|
958
|
+
);
|
|
959
|
+
reply.status(502).type("application/json").send({
|
|
960
|
+
error: "server_error",
|
|
961
|
+
error_description: `Upstream ${upstream} endpoint returned an invalid response.`
|
|
962
|
+
});
|
|
963
|
+
}
|
|
938
964
|
class ProxyAuthManager {
|
|
939
965
|
constructor(config) {
|
|
940
966
|
this.config = config;
|
|
@@ -1009,8 +1035,8 @@ class ProxyAuthManager {
|
|
|
1009
1035
|
revocation_endpoint: `${baseUrl.origin}/oauth/revoke`,
|
|
1010
1036
|
registration_endpoint: `${baseUrl.origin}/oauth/register`,
|
|
1011
1037
|
scopes_supported: ["profile", "email"],
|
|
1012
|
-
response_types_supported: [
|
|
1013
|
-
grant_types_supported: [
|
|
1038
|
+
response_types_supported: [...ALLOWED_RESPONSE_TYPES],
|
|
1039
|
+
grant_types_supported: [...ALLOWED_GRANT_TYPES],
|
|
1014
1040
|
token_endpoint_auth_methods_supported: [
|
|
1015
1041
|
"client_secret_basic",
|
|
1016
1042
|
"client_secret_post",
|
|
@@ -1020,52 +1046,77 @@ class ProxyAuthManager {
|
|
|
1020
1046
|
};
|
|
1021
1047
|
reply.type("application/json").send(metadata);
|
|
1022
1048
|
});
|
|
1023
|
-
server.get("/.well-known/oauth-protected-resource", async (
|
|
1024
|
-
const
|
|
1049
|
+
server.get("/.well-known/oauth-protected-resource", async (_request, reply) => {
|
|
1050
|
+
const origin = baseUrl.origin;
|
|
1025
1051
|
const metadata = {
|
|
1026
|
-
resource: `${
|
|
1052
|
+
resource: `${origin}/sse`,
|
|
1027
1053
|
authorization_servers: [this.config.issuerUrl],
|
|
1028
1054
|
scopes_supported: ["profile", "email"],
|
|
1029
1055
|
bearer_methods_supported: ["header"],
|
|
1030
1056
|
resource_name: "Documentation MCP Server",
|
|
1031
1057
|
resource_documentation: "https://github.com/arabold/docs-mcp-server#readme",
|
|
1032
1058
|
// Enhanced metadata for better discoverability
|
|
1033
|
-
resource_server_metadata_url: `${
|
|
1059
|
+
resource_server_metadata_url: `${origin}/.well-known/oauth-protected-resource`,
|
|
1034
1060
|
authorization_server_metadata_url: `${this.config.issuerUrl}/.well-known/openid-configuration`,
|
|
1035
1061
|
jwks_uri: `${this.config.issuerUrl}/.well-known/jwks.json`,
|
|
1036
1062
|
// Supported MCP transports
|
|
1037
1063
|
mcp_transports: [
|
|
1038
1064
|
{
|
|
1039
1065
|
transport: "sse",
|
|
1040
|
-
endpoint: `${
|
|
1066
|
+
endpoint: `${origin}/sse`,
|
|
1041
1067
|
description: "Server-Sent Events transport"
|
|
1042
1068
|
},
|
|
1043
1069
|
{
|
|
1044
1070
|
transport: "http",
|
|
1045
|
-
endpoint: `${
|
|
1071
|
+
endpoint: `${origin}/mcp`,
|
|
1046
1072
|
description: "Streaming HTTP transport"
|
|
1047
1073
|
}
|
|
1048
1074
|
]
|
|
1049
1075
|
};
|
|
1050
1076
|
reply.type("application/json").send(metadata);
|
|
1051
1077
|
});
|
|
1078
|
+
const pinnedResourceUrl = `${baseUrl.origin}/sse`;
|
|
1052
1079
|
server.get("/oauth/authorize", async (request, reply) => {
|
|
1053
|
-
const endpoints = await this.discoverEndpoints();
|
|
1054
1080
|
const params = new URLSearchParams(request.query);
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1081
|
+
const responseType = params.get("response_type");
|
|
1082
|
+
if (!responseType) {
|
|
1083
|
+
reply.status(400).type("application/json").send({
|
|
1084
|
+
error: "invalid_request",
|
|
1085
|
+
error_description: "Missing required parameter 'response_type'."
|
|
1086
|
+
});
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
if (!ALLOWED_RESPONSE_TYPES.has(responseType)) {
|
|
1090
|
+
reply.status(400).type("application/json").send({
|
|
1091
|
+
error: "unsupported_response_type",
|
|
1092
|
+
error_description: "Only the 'code' response_type is supported by this proxy."
|
|
1093
|
+
});
|
|
1094
|
+
return;
|
|
1058
1095
|
}
|
|
1096
|
+
params.set("resource", pinnedResourceUrl);
|
|
1097
|
+
const endpoints = await this.discoverEndpoints();
|
|
1059
1098
|
const redirectUrl = `${endpoints.authorizationUrl}?${params.toString()}`;
|
|
1060
1099
|
reply.redirect(redirectUrl);
|
|
1061
1100
|
});
|
|
1062
1101
|
server.post("/oauth/token", async (request, reply) => {
|
|
1063
|
-
const endpoints = await this.discoverEndpoints();
|
|
1064
1102
|
const tokenBody = new URLSearchParams(request.body);
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1103
|
+
const grantType = tokenBody.get("grant_type");
|
|
1104
|
+
if (!grantType) {
|
|
1105
|
+
reply.status(400).type("application/json").send({
|
|
1106
|
+
error: "invalid_request",
|
|
1107
|
+
error_description: "Missing required parameter 'grant_type'."
|
|
1108
|
+
});
|
|
1109
|
+
return;
|
|
1068
1110
|
}
|
|
1111
|
+
if (!ALLOWED_GRANT_TYPES.has(grantType)) {
|
|
1112
|
+
reply.status(400).type("application/json").send({
|
|
1113
|
+
error: "unsupported_grant_type",
|
|
1114
|
+
error_description: `Grant type '${grantType}' is not supported by this proxy.`
|
|
1115
|
+
});
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
tokenBody.set("resource", pinnedResourceUrl);
|
|
1119
|
+
const endpoints = await this.discoverEndpoints();
|
|
1069
1120
|
const response = await fetch(endpoints.tokenUrl, {
|
|
1070
1121
|
method: "POST",
|
|
1071
1122
|
headers: {
|
|
@@ -1073,8 +1124,7 @@ class ProxyAuthManager {
|
|
|
1073
1124
|
},
|
|
1074
1125
|
body: tokenBody.toString()
|
|
1075
1126
|
});
|
|
1076
|
-
|
|
1077
|
-
reply.status(response.status).type("application/json").send(data);
|
|
1127
|
+
await sendUpstreamJsonResponse(reply, response, "token");
|
|
1078
1128
|
});
|
|
1079
1129
|
server.post("/oauth/revoke", async (request, reply) => {
|
|
1080
1130
|
const endpoints = await this.discoverEndpoints();
|
|
@@ -1101,8 +1151,7 @@ class ProxyAuthManager {
|
|
|
1101
1151
|
},
|
|
1102
1152
|
body: JSON.stringify(request.body)
|
|
1103
1153
|
});
|
|
1104
|
-
|
|
1105
|
-
reply.status(response.status).type("application/json").send(data);
|
|
1154
|
+
await sendUpstreamJsonResponse(reply, response, "register");
|
|
1106
1155
|
} else {
|
|
1107
1156
|
reply.status(404).send({ error: "Dynamic client registration not supported" });
|
|
1108
1157
|
}
|
|
@@ -1465,7 +1514,8 @@ function createMcpServerInstance(tools, config) {
|
|
|
1465
1514
|
),
|
|
1466
1515
|
maxDepth: z$1.number().optional().default(config.scraper.maxDepth).describe(`Maximum navigation depth (default: ${config.scraper.maxDepth}).`),
|
|
1467
1516
|
scope: z$1.enum(["subpages", "hostname", "domain"]).optional().default("subpages").describe("Crawling boundary: 'subpages', 'hostname', or 'domain'."),
|
|
1468
|
-
followRedirects: z$1.boolean().optional().default(true).describe("Follow HTTP redirects (3xx responses).")
|
|
1517
|
+
followRedirects: z$1.boolean().optional().default(true).describe("Follow HTTP redirects (3xx responses)."),
|
|
1518
|
+
preserveHashes: z$1.boolean().optional().describe("Preserve hash fragments for hash-routed SPA documentation sites.")
|
|
1469
1519
|
},
|
|
1470
1520
|
{
|
|
1471
1521
|
title: "Scrape New Library Documentation",
|
|
@@ -1474,7 +1524,16 @@ function createMcpServerInstance(tools, config) {
|
|
|
1474
1524
|
openWorldHint: true
|
|
1475
1525
|
// requires internet access
|
|
1476
1526
|
},
|
|
1477
|
-
async ({
|
|
1527
|
+
async ({
|
|
1528
|
+
url,
|
|
1529
|
+
library,
|
|
1530
|
+
version,
|
|
1531
|
+
maxPages,
|
|
1532
|
+
maxDepth,
|
|
1533
|
+
scope,
|
|
1534
|
+
followRedirects,
|
|
1535
|
+
preserveHashes
|
|
1536
|
+
}) => {
|
|
1478
1537
|
telemetry.track(TelemetryEvent.TOOL_USED, {
|
|
1479
1538
|
tool: "scrape_docs",
|
|
1480
1539
|
context: "mcp_server",
|
|
@@ -1498,7 +1557,8 @@ function createMcpServerInstance(tools, config) {
|
|
|
1498
1557
|
maxPages,
|
|
1499
1558
|
maxDepth,
|
|
1500
1559
|
scope,
|
|
1501
|
-
followRedirects
|
|
1560
|
+
followRedirects,
|
|
1561
|
+
preserveHashes
|
|
1502
1562
|
}
|
|
1503
1563
|
});
|
|
1504
1564
|
if ("jobId" in result) {
|
|
@@ -4031,8 +4091,10 @@ class DocumentPipeline extends BasePipeline {
|
|
|
4031
4091
|
};
|
|
4032
4092
|
} catch (error) {
|
|
4033
4093
|
const errorName = error instanceof Error ? error.name : "UnknownError";
|
|
4094
|
+
const reasons = collectErrorReasons(error);
|
|
4034
4095
|
const safeMessage = `Failed to convert document: ${errorName}`;
|
|
4035
|
-
|
|
4096
|
+
const detail = reasons.length > 0 ? ` — ${reasons.join(" | ")}` : "";
|
|
4097
|
+
logger.error(`❌ ${safeMessage} (${mimeType}) for ${rawContent.source}${detail}`);
|
|
4036
4098
|
return {
|
|
4037
4099
|
title: null,
|
|
4038
4100
|
contentType: rawContent.mimeType,
|
|
@@ -4098,6 +4160,25 @@ class DocumentPipeline extends BasePipeline {
|
|
|
4098
4160
|
}
|
|
4099
4161
|
}
|
|
4100
4162
|
}
|
|
4163
|
+
const MAX_ERROR_DETAIL_LENGTH = 500;
|
|
4164
|
+
function collectErrorReasons(error) {
|
|
4165
|
+
const messages = [];
|
|
4166
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4167
|
+
let current = error;
|
|
4168
|
+
let depth = 0;
|
|
4169
|
+
while (current && !seen.has(current) && depth < 10) {
|
|
4170
|
+
seen.add(current);
|
|
4171
|
+
if (current instanceof Error && current.message) {
|
|
4172
|
+
const trimmed = current.message.replace(/\s+/g, " ").trim().slice(0, MAX_ERROR_DETAIL_LENGTH);
|
|
4173
|
+
if (trimmed && !messages.includes(trimmed)) {
|
|
4174
|
+
messages.push(trimmed);
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
current = current.cause;
|
|
4178
|
+
depth++;
|
|
4179
|
+
}
|
|
4180
|
+
return messages;
|
|
4181
|
+
}
|
|
4101
4182
|
class HtmlCheerioParserMiddleware {
|
|
4102
4183
|
async process(context, next) {
|
|
4103
4184
|
try {
|
|
@@ -5156,9 +5237,18 @@ ${frame.content}
|
|
|
5156
5237
|
page = await browserContext.newPage();
|
|
5157
5238
|
logger.debug(`Playwright: Processing ${context.source}`);
|
|
5158
5239
|
await this.injectShadowDOMExtractor(page);
|
|
5240
|
+
const initialRequestUrl = (() => {
|
|
5241
|
+
try {
|
|
5242
|
+
const initialUrl = new URL(context.source);
|
|
5243
|
+
initialUrl.hash = "";
|
|
5244
|
+
return initialUrl.toString();
|
|
5245
|
+
} catch {
|
|
5246
|
+
return context.source;
|
|
5247
|
+
}
|
|
5248
|
+
})();
|
|
5159
5249
|
await page.route("**/*", async (route) => {
|
|
5160
5250
|
const reqUrl = route.request().url();
|
|
5161
|
-
if (reqUrl ===
|
|
5251
|
+
if (reqUrl === initialRequestUrl) {
|
|
5162
5252
|
try {
|
|
5163
5253
|
return await route.fulfill({
|
|
5164
5254
|
status: 200,
|
|
@@ -7821,13 +7911,15 @@ class ListLibrariesTool {
|
|
|
7821
7911
|
const libraries = rawLibraries.map(({ library, versions }) => ({
|
|
7822
7912
|
name: library,
|
|
7823
7913
|
versions: versions.map((v) => ({
|
|
7914
|
+
id: v.id,
|
|
7824
7915
|
version: v.ref.version,
|
|
7825
7916
|
documentCount: v.counts.documents,
|
|
7826
7917
|
uniqueUrlCount: v.counts.uniqueUrls,
|
|
7827
7918
|
indexedAt: v.indexedAt,
|
|
7828
7919
|
status: v.status,
|
|
7829
7920
|
...v.progress ? { progress: v.progress } : void 0,
|
|
7830
|
-
sourceUrl: v.sourceUrl
|
|
7921
|
+
sourceUrl: v.sourceUrl,
|
|
7922
|
+
preserveHashes: v.preserveHashes
|
|
7831
7923
|
}))
|
|
7832
7924
|
}));
|
|
7833
7925
|
return { libraries };
|
|
@@ -7839,7 +7931,7 @@ class RefreshVersionTool {
|
|
|
7839
7931
|
this.pipeline = pipeline;
|
|
7840
7932
|
}
|
|
7841
7933
|
async execute(options) {
|
|
7842
|
-
const { library, version, waitForCompletion = true } = options;
|
|
7934
|
+
const { library, version, preserveHashes, waitForCompletion = true } = options;
|
|
7843
7935
|
let internalVersion;
|
|
7844
7936
|
const partialVersionRegex = /^\d+(\.\d+)?$/;
|
|
7845
7937
|
if (version === null || version === void 0) {
|
|
@@ -7868,7 +7960,9 @@ class RefreshVersionTool {
|
|
|
7868
7960
|
internalVersion = internalVersion.toLowerCase();
|
|
7869
7961
|
const pipeline = this.pipeline;
|
|
7870
7962
|
const refreshVersion = internalVersion === "" ? null : internalVersion;
|
|
7871
|
-
const jobId = await pipeline.enqueueRefreshJob(library, refreshVersion
|
|
7963
|
+
const jobId = await pipeline.enqueueRefreshJob(library, refreshVersion, {
|
|
7964
|
+
preserveHashes
|
|
7965
|
+
});
|
|
7872
7966
|
if (waitForCompletion) {
|
|
7873
7967
|
try {
|
|
7874
7968
|
await pipeline.waitForJobCompletion(jobId);
|
|
@@ -7991,6 +8085,7 @@ class ScrapeTool {
|
|
|
7991
8085
|
// Pass scrapeMode enum
|
|
7992
8086
|
includePatterns: scraperOptions?.includePatterns,
|
|
7993
8087
|
excludePatterns: scraperOptions?.excludePatterns,
|
|
8088
|
+
preserveHashes: scraperOptions?.preserveHashes,
|
|
7994
8089
|
headers: scraperOptions?.headers,
|
|
7995
8090
|
// <-- propagate headers
|
|
7996
8091
|
clean: scraperOptions?.clean
|
|
@@ -9816,6 +9911,35 @@ class DocumentStore {
|
|
|
9816
9911
|
const message = error.message.toLowerCase();
|
|
9817
9912
|
return message.includes("maximum context length") || message.includes("too long") || message.includes("token limit") || message.includes("input is too large") || message.includes("exceeds") || message.includes("max") && message.includes("token");
|
|
9818
9913
|
}
|
|
9914
|
+
getEmbeddingErrorHint(error) {
|
|
9915
|
+
if (this.isInputSizeError(error)) {
|
|
9916
|
+
return "The embedding input appears to exceed provider or model limits. Check model context size and reduce embedding batch size if needed.";
|
|
9917
|
+
}
|
|
9918
|
+
if (error instanceof Error) {
|
|
9919
|
+
const message = error.message.toLowerCase();
|
|
9920
|
+
if (message.includes("rate limit") || message.includes("429")) {
|
|
9921
|
+
return "The embedding provider appears to be rate limiting requests. Reduce concurrency or retry after the provider quota resets.";
|
|
9922
|
+
}
|
|
9923
|
+
if (message.includes("timed out") || message.includes("econnrefused") || message.includes("enotfound") || message.includes("etimedout") || message.includes("econnreset") || message.includes("network") || message.includes("fetch failed")) {
|
|
9924
|
+
return "The embedding service appears unreachable. Check that the provider endpoint is running and accessible.";
|
|
9925
|
+
}
|
|
9926
|
+
}
|
|
9927
|
+
return null;
|
|
9928
|
+
}
|
|
9929
|
+
createEmbeddingConnectionError(error, context) {
|
|
9930
|
+
const modelSpec = this.embeddingConfig?.modelSpec ?? "unknown";
|
|
9931
|
+
const errorHint = this.getEmbeddingErrorHint(error);
|
|
9932
|
+
const providerHint = this.embeddingConfig ? "Verify embedding provider configuration, model availability, credentials, quota, request size, and backend logs." : null;
|
|
9933
|
+
const hints = [errorHint, providerHint].filter((hint) => hint !== null);
|
|
9934
|
+
const hintText = hints.length > 0 ? `
|
|
9935
|
+
${hints.join("\n ")}` : "";
|
|
9936
|
+
return new ConnectionError(
|
|
9937
|
+
`Failed to generate embeddings for ${context.url} using ${modelSpec}.
|
|
9938
|
+
Batch ${context.batchIndex}: ${context.batchTextCount} text(s), ${context.batchChars} chars, ${context.totalChunks} page chunk(s).
|
|
9939
|
+
Config: batchSize=${this.embeddingBatchSize}, batchChars=${this.embeddingBatchChars}, vectorDimension=${this.dbDimension}.` + hintText,
|
|
9940
|
+
error
|
|
9941
|
+
);
|
|
9942
|
+
}
|
|
9819
9943
|
/**
|
|
9820
9944
|
* Creates embeddings for an array of texts with automatic retry logic for size-related errors.
|
|
9821
9945
|
* If a batch fails due to size limits:
|
|
@@ -9904,38 +10028,41 @@ class DocumentStore {
|
|
|
9904
10028
|
let currentBatch = [];
|
|
9905
10029
|
let currentBatchSize = 0;
|
|
9906
10030
|
let batchCount = 0;
|
|
10031
|
+
const processEmbeddingBatch = async (isFinalBatch = false) => {
|
|
10032
|
+
batchCount++;
|
|
10033
|
+
const batchTexts = currentBatch;
|
|
10034
|
+
const batchChars = currentBatchSize;
|
|
10035
|
+
logger.debug(
|
|
10036
|
+
`Processing ${isFinalBatch ? "final " : ""}embedding batch ${batchCount}: ${batchTexts.length} texts, ${batchChars} chars`
|
|
10037
|
+
);
|
|
10038
|
+
try {
|
|
10039
|
+
const batchEmbeddings = await this.embedDocumentsWithRetry(batchTexts);
|
|
10040
|
+
rawEmbeddings.push(...batchEmbeddings);
|
|
10041
|
+
} catch (error) {
|
|
10042
|
+
throw this.createEmbeddingConnectionError(error, {
|
|
10043
|
+
url,
|
|
10044
|
+
batchIndex: batchCount,
|
|
10045
|
+
batchTextCount: batchTexts.length,
|
|
10046
|
+
batchChars,
|
|
10047
|
+
totalChunks: chunks.length
|
|
10048
|
+
});
|
|
10049
|
+
}
|
|
10050
|
+
currentBatch = [];
|
|
10051
|
+
currentBatchSize = 0;
|
|
10052
|
+
};
|
|
9907
10053
|
for (const text of texts) {
|
|
9908
10054
|
const textSize = text.length;
|
|
9909
10055
|
if (currentBatchSize + textSize > maxBatchChars && currentBatch.length > 0) {
|
|
9910
|
-
|
|
9911
|
-
logger.debug(
|
|
9912
|
-
`Processing embedding batch ${batchCount}: ${currentBatch.length} texts, ${currentBatchSize} chars`
|
|
9913
|
-
);
|
|
9914
|
-
const batchEmbeddings = await this.embedDocumentsWithRetry(currentBatch);
|
|
9915
|
-
rawEmbeddings.push(...batchEmbeddings);
|
|
9916
|
-
currentBatch = [];
|
|
9917
|
-
currentBatchSize = 0;
|
|
10056
|
+
await processEmbeddingBatch();
|
|
9918
10057
|
}
|
|
9919
10058
|
currentBatch.push(text);
|
|
9920
10059
|
currentBatchSize += textSize;
|
|
9921
10060
|
if (currentBatch.length >= this.embeddingBatchSize) {
|
|
9922
|
-
|
|
9923
|
-
logger.debug(
|
|
9924
|
-
`Processing embedding batch ${batchCount}: ${currentBatch.length} texts, ${currentBatchSize} chars`
|
|
9925
|
-
);
|
|
9926
|
-
const batchEmbeddings = await this.embedDocumentsWithRetry(currentBatch);
|
|
9927
|
-
rawEmbeddings.push(...batchEmbeddings);
|
|
9928
|
-
currentBatch = [];
|
|
9929
|
-
currentBatchSize = 0;
|
|
10061
|
+
await processEmbeddingBatch();
|
|
9930
10062
|
}
|
|
9931
10063
|
}
|
|
9932
10064
|
if (currentBatch.length > 0) {
|
|
9933
|
-
|
|
9934
|
-
logger.debug(
|
|
9935
|
-
`Processing final embedding batch ${batchCount}: ${currentBatch.length} texts, ${currentBatchSize} chars`
|
|
9936
|
-
);
|
|
9937
|
-
const batchEmbeddings = await this.embedDocumentsWithRetry(currentBatch);
|
|
9938
|
-
rawEmbeddings.push(...batchEmbeddings);
|
|
10065
|
+
await processEmbeddingBatch(true);
|
|
9939
10066
|
}
|
|
9940
10067
|
paddedEmbeddings = rawEmbeddings.map((vector) => this.padVector(vector));
|
|
9941
10068
|
}
|
|
@@ -9993,6 +10120,9 @@ class DocumentStore {
|
|
|
9993
10120
|
});
|
|
9994
10121
|
transaction();
|
|
9995
10122
|
} catch (error) {
|
|
10123
|
+
if (error instanceof StoreError) {
|
|
10124
|
+
throw error;
|
|
10125
|
+
}
|
|
9996
10126
|
throw new ConnectionError("Failed to add documents to store", error);
|
|
9997
10127
|
}
|
|
9998
10128
|
}
|
|
@@ -10134,6 +10264,14 @@ class DocumentStore {
|
|
|
10134
10264
|
}
|
|
10135
10265
|
const ftsQuery = this.escapeFtsQuery(query);
|
|
10136
10266
|
const normalizedVersion = version.toLowerCase();
|
|
10267
|
+
const versionRow = this.statements.getVersionId.get(
|
|
10268
|
+
library.toLowerCase(),
|
|
10269
|
+
normalizedVersion
|
|
10270
|
+
);
|
|
10271
|
+
if (!versionRow) {
|
|
10272
|
+
return [];
|
|
10273
|
+
}
|
|
10274
|
+
const { id: versionId, library_id: libraryId } = versionRow;
|
|
10137
10275
|
if (this.isVectorSearchEnabled) {
|
|
10138
10276
|
const rawEmbedding = await this.embeddings.embedQuery(query);
|
|
10139
10277
|
const embedding = this.padVector(rawEmbedding);
|
|
@@ -10145,12 +10283,8 @@ class DocumentStore {
|
|
|
10145
10283
|
dv.rowid as id,
|
|
10146
10284
|
dv.distance as vec_distance
|
|
10147
10285
|
FROM documents_vec dv
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
JOIN versions v ON p.version_id = v.id
|
|
10151
|
-
JOIN libraries l ON v.library_id = l.id
|
|
10152
|
-
WHERE l.name = ?
|
|
10153
|
-
AND COALESCE(v.name, '') = COALESCE(?, '')
|
|
10286
|
+
WHERE dv.library_id = ?
|
|
10287
|
+
AND dv.version_id = ?
|
|
10154
10288
|
AND dv.embedding MATCH ?
|
|
10155
10289
|
AND dv.k = ?
|
|
10156
10290
|
ORDER BY dv.distance
|
|
@@ -10162,10 +10296,7 @@ class DocumentStore {
|
|
|
10162
10296
|
FROM documents_fts f
|
|
10163
10297
|
JOIN documents d ON f.rowid = d.id
|
|
10164
10298
|
JOIN pages p ON d.page_id = p.id
|
|
10165
|
-
|
|
10166
|
-
JOIN libraries l ON v.library_id = l.id
|
|
10167
|
-
WHERE l.name = ?
|
|
10168
|
-
AND COALESCE(v.name, '') = COALESCE(?, '')
|
|
10299
|
+
WHERE p.version_id = ?
|
|
10169
10300
|
AND documents_fts MATCH ?
|
|
10170
10301
|
ORDER BY fts_score
|
|
10171
10302
|
LIMIT ?
|
|
@@ -10191,12 +10322,11 @@ class DocumentStore {
|
|
|
10191
10322
|
)
|
|
10192
10323
|
`);
|
|
10193
10324
|
const rawResults = stmt.all(
|
|
10194
|
-
|
|
10195
|
-
|
|
10325
|
+
libraryId,
|
|
10326
|
+
versionId,
|
|
10196
10327
|
JSON.stringify(embedding),
|
|
10197
10328
|
vectorSearchK,
|
|
10198
|
-
|
|
10199
|
-
normalizedVersion,
|
|
10329
|
+
versionId,
|
|
10200
10330
|
ftsQuery,
|
|
10201
10331
|
overfetchLimit
|
|
10202
10332
|
);
|
|
@@ -10231,10 +10361,7 @@ class DocumentStore {
|
|
|
10231
10361
|
FROM documents_fts f
|
|
10232
10362
|
JOIN documents d ON f.rowid = d.id
|
|
10233
10363
|
JOIN pages p ON d.page_id = p.id
|
|
10234
|
-
|
|
10235
|
-
JOIN libraries l ON v.library_id = l.id
|
|
10236
|
-
WHERE l.name = ?
|
|
10237
|
-
AND COALESCE(v.name, '') = COALESCE(?, '')
|
|
10364
|
+
WHERE p.version_id = ?
|
|
10238
10365
|
AND documents_fts MATCH ?
|
|
10239
10366
|
AND NOT EXISTS (
|
|
10240
10367
|
SELECT 1 FROM json_each(json_extract(d.metadata, '$.types')) je
|
|
@@ -10243,12 +10370,7 @@ class DocumentStore {
|
|
|
10243
10370
|
ORDER BY fts_score
|
|
10244
10371
|
LIMIT ?
|
|
10245
10372
|
`);
|
|
10246
|
-
const rawResults = stmt.all(
|
|
10247
|
-
library.toLowerCase(),
|
|
10248
|
-
normalizedVersion,
|
|
10249
|
-
ftsQuery,
|
|
10250
|
-
limit
|
|
10251
|
-
);
|
|
10373
|
+
const rawResults = stmt.all(versionId, ftsQuery, limit);
|
|
10252
10374
|
return rawResults.map((row, index) => {
|
|
10253
10375
|
const result = {
|
|
10254
10376
|
...row,
|
|
@@ -10547,16 +10669,20 @@ class DocumentManagementService {
|
|
|
10547
10669
|
const libMap = await this.store.queryLibraryVersions();
|
|
10548
10670
|
const summaries = [];
|
|
10549
10671
|
for (const [library, versions] of libMap) {
|
|
10550
|
-
const vs =
|
|
10551
|
-
(v) =>
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10672
|
+
const vs = await Promise.all(
|
|
10673
|
+
versions.map(async (v) => {
|
|
10674
|
+
const scraperOptions = await this.store.getScraperOptions(v.versionId);
|
|
10675
|
+
return {
|
|
10676
|
+
id: v.versionId,
|
|
10677
|
+
ref: { library, version: v.version },
|
|
10678
|
+
status: v.status,
|
|
10679
|
+
// Include progress only while indexing is active; set undefined for COMPLETED
|
|
10680
|
+
progress: v.status === "completed" ? void 0 : { pages: v.progressPages, maxPages: v.progressMaxPages },
|
|
10681
|
+
counts: { documents: v.documentCount, uniqueUrls: v.uniqueUrlCount },
|
|
10682
|
+
indexedAt: v.indexedAt,
|
|
10683
|
+
sourceUrl: v.sourceUrl ?? void 0,
|
|
10684
|
+
preserveHashes: scraperOptions?.options.preserveHashes
|
|
10685
|
+
};
|
|
10560
10686
|
})
|
|
10561
10687
|
);
|
|
10562
10688
|
summaries.push({ library, versions: vs });
|
|
@@ -11122,7 +11248,10 @@ const enqueueScrapeInput = z.object({
|
|
|
11122
11248
|
});
|
|
11123
11249
|
const enqueueRefreshInput = z.object({
|
|
11124
11250
|
library: nonEmptyTrimmed,
|
|
11125
|
-
version: optionalTrimmed
|
|
11251
|
+
version: optionalTrimmed,
|
|
11252
|
+
options: z.object({
|
|
11253
|
+
preserveHashes: z.boolean().optional()
|
|
11254
|
+
}).optional()
|
|
11126
11255
|
});
|
|
11127
11256
|
const jobIdInput = z.object({ id: z.string().min(1) });
|
|
11128
11257
|
const getJobsInput = z.object({
|
|
@@ -11152,7 +11281,8 @@ function createPipelineRouter(trpc) {
|
|
|
11152
11281
|
}) => {
|
|
11153
11282
|
const jobId = await ctx.pipeline.enqueueRefreshJob(
|
|
11154
11283
|
input.library,
|
|
11155
|
-
input.version ?? null
|
|
11284
|
+
input.version ?? null,
|
|
11285
|
+
input.options
|
|
11156
11286
|
);
|
|
11157
11287
|
return { jobId };
|
|
11158
11288
|
}
|
|
@@ -11660,7 +11790,7 @@ const Layout = ({
|
|
|
11660
11790
|
children,
|
|
11661
11791
|
eventClientConfig
|
|
11662
11792
|
}) => {
|
|
11663
|
-
const versionString = version || "2.2.
|
|
11793
|
+
const versionString = version || "2.2.2";
|
|
11664
11794
|
const versionInitializer = `versionUpdate({ currentVersion: ${`'${versionString}'`} })`;
|
|
11665
11795
|
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
11666
11796
|
/* @__PURE__ */ jsxs("head", { children: [
|
|
@@ -12449,6 +12579,7 @@ const ScrapeFormContent = ({
|
|
|
12449
12579
|
const scrapeModeValue = initialValues?.scrapeMode || ScrapeMode.Auto;
|
|
12450
12580
|
const followRedirectsValue = initialValues?.followRedirects ?? true;
|
|
12451
12581
|
const ignoreErrorsValue = initialValues?.ignoreErrors ?? true;
|
|
12582
|
+
const preserveHashesValue = initialValues?.preserveHashes ?? scraperConfig?.preserveHashes ?? false;
|
|
12452
12583
|
const excludePatternsText = initialValues?.excludePatterns !== void 0 ? initialValues.excludePatterns : defaultExcludePatterns?.join("\n") || "";
|
|
12453
12584
|
const headersJson = JSON.stringify(initialValues?.headers || []);
|
|
12454
12585
|
const closeButtonAttrs = isAddVersionMode ? {
|
|
@@ -12623,7 +12754,7 @@ const ScrapeFormContent = ({
|
|
|
12623
12754
|
"div",
|
|
12624
12755
|
{
|
|
12625
12756
|
class: "bg-gray-50 dark:bg-gray-900 p-2 rounded-md",
|
|
12626
|
-
"data-should-open": isAddVersionMode && (maxPagesValue || maxDepthValue || scopeValue !== "subpages" || includePatternsValue || excludePatternsText || scrapeModeValue !== ScrapeMode.Auto) ? "true" : "false",
|
|
12757
|
+
"data-should-open": isAddVersionMode && (maxPagesValue || maxDepthValue || scopeValue !== "subpages" || includePatternsValue || excludePatternsText || scrapeModeValue !== ScrapeMode.Auto || preserveHashesValue) ? "true" : "false",
|
|
12627
12758
|
"x-data": "{ open: false }",
|
|
12628
12759
|
"x-init": "open = $el.dataset.shouldOpen === 'true'",
|
|
12629
12760
|
children: [
|
|
@@ -12862,6 +12993,27 @@ const ScrapeFormContent = ({
|
|
|
12862
12993
|
}
|
|
12863
12994
|
)
|
|
12864
12995
|
] }),
|
|
12996
|
+
/* @__PURE__ */ jsxs("div", { class: "flex items-center", children: [
|
|
12997
|
+
/* @__PURE__ */ jsx(
|
|
12998
|
+
"input",
|
|
12999
|
+
{
|
|
13000
|
+
id: "preserveHashes",
|
|
13001
|
+
name: "preserveHashes",
|
|
13002
|
+
type: "checkbox",
|
|
13003
|
+
checked: preserveHashesValue,
|
|
13004
|
+
class: "h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700"
|
|
13005
|
+
}
|
|
13006
|
+
),
|
|
13007
|
+
/* @__PURE__ */ jsx(
|
|
13008
|
+
"label",
|
|
13009
|
+
{
|
|
13010
|
+
for: "preserveHashes",
|
|
13011
|
+
class: "ml-1 block text-sm text-gray-900 dark:text-gray-300",
|
|
13012
|
+
children: "Preserve Hash Routes"
|
|
13013
|
+
}
|
|
13014
|
+
),
|
|
13015
|
+
/* @__PURE__ */ jsx(Tooltip, { text: "Enable this for documentation sites that use hash fragments as client-side routes rather than same-page anchors." })
|
|
13016
|
+
] }),
|
|
12865
13017
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
12866
13018
|
/* @__PURE__ */ jsxs("div", { class: "flex items-center mb-1", children: [
|
|
12867
13019
|
/* @__PURE__ */ jsx("label", { class: "block text-sm font-medium text-gray-700 dark:text-gray-300", children: "Custom HTTP Headers" }),
|
|
@@ -13146,6 +13298,7 @@ function registerNewJobRoutes(server, scrapeTool, scraperConfig) {
|
|
|
13146
13298
|
maxDepth: body.maxDepth ? Number.parseInt(body.maxDepth, 10) : void 0,
|
|
13147
13299
|
scope: body.scope,
|
|
13148
13300
|
scrapeMode: body.scrapeMode,
|
|
13301
|
+
preserveHashes: body.preserveHashes === "on",
|
|
13149
13302
|
// Checkboxes send 'on' when checked, otherwise undefined
|
|
13150
13303
|
followRedirects: body.followRedirects === "on",
|
|
13151
13304
|
ignoreErrors: body.ignoreErrors === "on",
|
|
@@ -13202,6 +13355,7 @@ const VersionDetailsRow = ({
|
|
|
13202
13355
|
const indexedDate = version.indexedAt ? new Date(version.indexedAt).toLocaleDateString() : "N/A";
|
|
13203
13356
|
const versionLabel = version.ref.version || "Latest";
|
|
13204
13357
|
const versionParam = version.ref.version || "";
|
|
13358
|
+
const preserveHashes = version.preserveHashes ?? false;
|
|
13205
13359
|
const sanitizedLibraryName = libraryName.replace(/[^a-zA-Z0-9-_]/g, "-");
|
|
13206
13360
|
const sanitizedVersionParam = versionParam.replace(/[^a-zA-Z0-9-_]/g, "-");
|
|
13207
13361
|
const rowId = `row-${sanitizedLibraryName}-${sanitizedVersionParam}`;
|
|
@@ -13258,6 +13412,7 @@ const VersionDetailsRow = ({
|
|
|
13258
13412
|
"hx-post": `/web/libraries/${encodeURIComponent(libraryName)}/versions/${encodeURIComponent(versionParam)}/refresh`,
|
|
13259
13413
|
"hx-swap": "none",
|
|
13260
13414
|
"hx-trigger": "trigger-refresh",
|
|
13415
|
+
"hx-vals": JSON.stringify({ preserveHashes }),
|
|
13261
13416
|
children: [
|
|
13262
13417
|
/* @__PURE__ */ jsx(
|
|
13263
13418
|
"svg",
|
|
@@ -13388,7 +13543,8 @@ const LibraryDetailCard = ({ library }) => {
|
|
|
13388
13543
|
uniqueUrls: v.uniqueUrlCount
|
|
13389
13544
|
},
|
|
13390
13545
|
indexedAt: v.indexedAt,
|
|
13391
|
-
sourceUrl: v.sourceUrl ?? void 0
|
|
13546
|
+
sourceUrl: v.sourceUrl ?? void 0,
|
|
13547
|
+
preserveHashes: v.preserveHashes
|
|
13392
13548
|
};
|
|
13393
13549
|
return /* @__PURE__ */ jsx(
|
|
13394
13550
|
VersionDetailsRow,
|
|
@@ -13597,7 +13753,8 @@ function registerLibraryDetailRoutes(server, listLibrariesTool, searchTool, scra
|
|
|
13597
13753
|
uniqueUrls: v.uniqueUrlCount
|
|
13598
13754
|
},
|
|
13599
13755
|
indexedAt: v.indexedAt,
|
|
13600
|
-
sourceUrl: v.sourceUrl ?? void 0
|
|
13756
|
+
sourceUrl: v.sourceUrl ?? void 0,
|
|
13757
|
+
preserveHashes: v.preserveHashes
|
|
13601
13758
|
};
|
|
13602
13759
|
return /* @__PURE__ */ jsx(
|
|
13603
13760
|
VersionDetailsRow,
|
|
@@ -13670,7 +13827,8 @@ function registerLibraryDetailRoutes(server, listLibrariesTool, searchTool, scra
|
|
|
13670
13827
|
value
|
|
13671
13828
|
})) : void 0,
|
|
13672
13829
|
followRedirects: opts.followRedirects,
|
|
13673
|
-
ignoreErrors: opts.ignoreErrors
|
|
13830
|
+
ignoreErrors: opts.ignoreErrors,
|
|
13831
|
+
preserveHashes: opts.preserveHashes
|
|
13674
13832
|
};
|
|
13675
13833
|
}
|
|
13676
13834
|
}
|
|
@@ -13817,10 +13975,12 @@ function registerLibrariesRoutes(server, listLibrariesTool, removeTool, refreshV
|
|
|
13817
13975
|
async (request, reply) => {
|
|
13818
13976
|
const { libraryName, versionParam } = request.params;
|
|
13819
13977
|
const version = versionParam === "latest" || versionParam === "" ? void 0 : versionParam;
|
|
13978
|
+
const preserveHashes = request.body?.preserveHashes === true || request.body?.preserveHashes === "true" ? true : request.body?.preserveHashes === false || request.body?.preserveHashes === "false" ? false : void 0;
|
|
13820
13979
|
try {
|
|
13821
13980
|
await refreshVersionTool.execute({
|
|
13822
13981
|
library: libraryName,
|
|
13823
13982
|
version,
|
|
13983
|
+
preserveHashes,
|
|
13824
13984
|
waitForCompletion: false
|
|
13825
13985
|
});
|
|
13826
13986
|
const versionDisplay = version || "latest";
|
|
@@ -14012,7 +14172,7 @@ class AppServer {
|
|
|
14012
14172
|
try {
|
|
14013
14173
|
if (telemetry.isEnabled()) {
|
|
14014
14174
|
telemetry.setGlobalContext({
|
|
14015
|
-
appVersion: "2.2.
|
|
14175
|
+
appVersion: "2.2.2",
|
|
14016
14176
|
appPlatform: process.platform,
|
|
14017
14177
|
appNodeVersion: process.version,
|
|
14018
14178
|
appServicesEnabled: this.getActiveServicesList(),
|
|
@@ -14458,12 +14618,13 @@ class PipelineClient {
|
|
|
14458
14618
|
);
|
|
14459
14619
|
}
|
|
14460
14620
|
}
|
|
14461
|
-
async enqueueRefreshJob(library, version) {
|
|
14621
|
+
async enqueueRefreshJob(library, version, options) {
|
|
14462
14622
|
try {
|
|
14463
14623
|
const normalizedVersion = typeof version === "string" && version.trim().length === 0 ? null : version ?? null;
|
|
14464
14624
|
const result = await this.client.enqueueRefreshJob.mutate({
|
|
14465
14625
|
library,
|
|
14466
|
-
version: normalizedVersion
|
|
14626
|
+
version: normalizedVersion,
|
|
14627
|
+
options
|
|
14467
14628
|
});
|
|
14468
14629
|
logger.debug(`Refresh job ${result.jobId} enqueued successfully`);
|
|
14469
14630
|
return result.jobId;
|
|
@@ -14610,7 +14771,10 @@ function isInScope(baseUrl, targetUrl, scope) {
|
|
|
14610
14771
|
return false;
|
|
14611
14772
|
}
|
|
14612
14773
|
}
|
|
14774
|
+
class FailureThresholdExceededError extends ScraperError {
|
|
14775
|
+
}
|
|
14613
14776
|
class BaseScraperStrategy {
|
|
14777
|
+
static FAILURE_RATE_MIN_SAMPLE = 10;
|
|
14614
14778
|
/**
|
|
14615
14779
|
* Set of normalized URLs that have been marked for processing.
|
|
14616
14780
|
*
|
|
@@ -14634,12 +14798,21 @@ class BaseScraperStrategy {
|
|
|
14634
14798
|
effectiveTotal = 0;
|
|
14635
14799
|
// Track effective total (limited by maxPages)
|
|
14636
14800
|
canonicalBaseUrl;
|
|
14801
|
+
// Final URL after initial redirect (depth 0)
|
|
14802
|
+
completedChildPageAttempts = 0;
|
|
14803
|
+
failedChildPages = 0;
|
|
14637
14804
|
options;
|
|
14638
14805
|
config;
|
|
14639
14806
|
constructor(config, options = {}) {
|
|
14640
14807
|
this.config = config;
|
|
14641
14808
|
this.options = options;
|
|
14642
14809
|
}
|
|
14810
|
+
getUrlNormalizerOptions(scrapeOptions) {
|
|
14811
|
+
return {
|
|
14812
|
+
...this.options.urlNormalizerOptions,
|
|
14813
|
+
removeHash: scrapeOptions.preserveHashes ? false : this.options.urlNormalizerOptions?.removeHash ?? true
|
|
14814
|
+
};
|
|
14815
|
+
}
|
|
14643
14816
|
/**
|
|
14644
14817
|
* Determines if a URL should be processed based on scope and include/exclude patterns in ScraperOptions.
|
|
14645
14818
|
* Scope is checked first, then patterns.
|
|
@@ -14656,19 +14829,69 @@ class BaseScraperStrategy {
|
|
|
14656
14829
|
}
|
|
14657
14830
|
return shouldIncludeUrl(url, options.includePatterns, options.excludePatterns);
|
|
14658
14831
|
}
|
|
14832
|
+
shouldCountTowardFailureThreshold(item, result) {
|
|
14833
|
+
return item.depth > 0 && !this.isRefreshDeletion(item, result);
|
|
14834
|
+
}
|
|
14835
|
+
isRefreshDeletion(item, result) {
|
|
14836
|
+
return item.pageId !== void 0 && result?.status === FetchStatus.NOT_FOUND;
|
|
14837
|
+
}
|
|
14838
|
+
recordChildPageCompletion(item, result) {
|
|
14839
|
+
if (!this.shouldCountTowardFailureThreshold(item, result)) {
|
|
14840
|
+
return;
|
|
14841
|
+
}
|
|
14842
|
+
this.completedChildPageAttempts++;
|
|
14843
|
+
}
|
|
14844
|
+
recordChildPageFailure(item) {
|
|
14845
|
+
if (item.depth === 0) {
|
|
14846
|
+
return;
|
|
14847
|
+
}
|
|
14848
|
+
this.completedChildPageAttempts++;
|
|
14849
|
+
this.failedChildPages++;
|
|
14850
|
+
}
|
|
14851
|
+
ensureFailureRateWithinThreshold() {
|
|
14852
|
+
if (this.completedChildPageAttempts < BaseScraperStrategy.FAILURE_RATE_MIN_SAMPLE || this.completedChildPageAttempts === 0) {
|
|
14853
|
+
return;
|
|
14854
|
+
}
|
|
14855
|
+
const failureRate = this.failedChildPages / this.completedChildPageAttempts;
|
|
14856
|
+
const threshold = this.config.scraper.abortOnFailureRate;
|
|
14857
|
+
if (failureRate > threshold) {
|
|
14858
|
+
throw new FailureThresholdExceededError(
|
|
14859
|
+
`Scrape aborted after ${this.failedChildPages}/${this.completedChildPageAttempts} child pages failed (${failureRate.toFixed(2)} > ${threshold.toFixed(2)})`,
|
|
14860
|
+
false
|
|
14861
|
+
);
|
|
14862
|
+
}
|
|
14863
|
+
}
|
|
14659
14864
|
async processBatch(batch, baseUrl, options, progressCallback, signal) {
|
|
14660
14865
|
const maxPages = options.maxPages ?? this.config.scraper.maxPages;
|
|
14866
|
+
let batchAbortError = null;
|
|
14867
|
+
const ensureFailureRateWithinThreshold = () => {
|
|
14868
|
+
try {
|
|
14869
|
+
this.ensureFailureRateWithinThreshold();
|
|
14870
|
+
} catch (error) {
|
|
14871
|
+
if (error instanceof FailureThresholdExceededError) {
|
|
14872
|
+
batchAbortError ??= error;
|
|
14873
|
+
}
|
|
14874
|
+
throw error;
|
|
14875
|
+
}
|
|
14876
|
+
};
|
|
14877
|
+
const throwIfBatchAborted = () => {
|
|
14878
|
+
if (batchAbortError) {
|
|
14879
|
+
throw batchAbortError;
|
|
14880
|
+
}
|
|
14881
|
+
if (signal?.aborted) {
|
|
14882
|
+
throw new CancellationError("Scraping cancelled during batch processing");
|
|
14883
|
+
}
|
|
14884
|
+
};
|
|
14661
14885
|
const results = await Promise.all(
|
|
14662
14886
|
batch.map(async (item) => {
|
|
14663
|
-
|
|
14664
|
-
throw new CancellationError("Scraping cancelled during batch processing");
|
|
14665
|
-
}
|
|
14887
|
+
throwIfBatchAborted();
|
|
14666
14888
|
const maxDepth = options.maxDepth ?? this.config.scraper.maxDepth;
|
|
14667
14889
|
if (item.depth > maxDepth) {
|
|
14668
14890
|
return [];
|
|
14669
14891
|
}
|
|
14670
14892
|
try {
|
|
14671
14893
|
const result = await this.processItem(item, options, signal);
|
|
14894
|
+
throwIfBatchAborted();
|
|
14672
14895
|
const shouldCount = item.pageId !== void 0 || result.content !== void 0;
|
|
14673
14896
|
let currentPageCount = this.pageCount;
|
|
14674
14897
|
if (shouldCount) {
|
|
@@ -14691,12 +14914,24 @@ class BaseScraperStrategy {
|
|
|
14691
14914
|
pageId: item.pageId
|
|
14692
14915
|
});
|
|
14693
14916
|
}
|
|
14917
|
+
this.recordChildPageCompletion(item, result);
|
|
14918
|
+
ensureFailureRateWithinThreshold();
|
|
14919
|
+
throwIfBatchAborted();
|
|
14694
14920
|
return [];
|
|
14695
14921
|
}
|
|
14696
14922
|
if (result.status === FetchStatus.NOT_FOUND) {
|
|
14923
|
+
const isRefreshDeletion = this.isRefreshDeletion(item, result);
|
|
14924
|
+
if (item.depth === 0 && !isRefreshDeletion) {
|
|
14925
|
+
throw new ScraperError(`Root page not found: ${item.url}`, false);
|
|
14926
|
+
}
|
|
14927
|
+
if (!isRefreshDeletion) {
|
|
14928
|
+
this.recordChildPageFailure(item);
|
|
14929
|
+
ensureFailureRateWithinThreshold();
|
|
14930
|
+
}
|
|
14931
|
+
throwIfBatchAborted();
|
|
14697
14932
|
logger.debug(`Page deleted (404): ${item.url}`);
|
|
14698
14933
|
if (shouldCount) {
|
|
14699
|
-
|
|
14934
|
+
const progress = {
|
|
14700
14935
|
pagesScraped: currentPageCount,
|
|
14701
14936
|
totalPages: this.effectiveTotal,
|
|
14702
14937
|
totalDiscovered: this.totalDiscovered,
|
|
@@ -14704,9 +14939,12 @@ class BaseScraperStrategy {
|
|
|
14704
14939
|
depth: item.depth,
|
|
14705
14940
|
maxDepth,
|
|
14706
14941
|
result: null,
|
|
14707
|
-
pageId: item.pageId
|
|
14708
|
-
|
|
14709
|
-
|
|
14942
|
+
pageId: item.pageId
|
|
14943
|
+
};
|
|
14944
|
+
if (isRefreshDeletion) {
|
|
14945
|
+
progress.deleted = true;
|
|
14946
|
+
}
|
|
14947
|
+
await progressCallback(progress);
|
|
14710
14948
|
}
|
|
14711
14949
|
return [];
|
|
14712
14950
|
}
|
|
@@ -14737,9 +14975,13 @@ class BaseScraperStrategy {
|
|
|
14737
14975
|
},
|
|
14738
14976
|
pageId: item.pageId
|
|
14739
14977
|
});
|
|
14978
|
+
throwIfBatchAborted();
|
|
14740
14979
|
}
|
|
14741
14980
|
const nextItems = result.links || [];
|
|
14742
14981
|
const linkBaseUrl = finalUrl ? new URL$1(finalUrl) : baseUrl;
|
|
14982
|
+
this.recordChildPageCompletion(item, result);
|
|
14983
|
+
ensureFailureRateWithinThreshold();
|
|
14984
|
+
throwIfBatchAborted();
|
|
14743
14985
|
return nextItems.map((value) => {
|
|
14744
14986
|
try {
|
|
14745
14987
|
const targetUrl = new URL$1(value, linkBaseUrl);
|
|
@@ -14756,9 +14998,17 @@ class BaseScraperStrategy {
|
|
|
14756
14998
|
return null;
|
|
14757
14999
|
}).filter((item2) => item2 !== null);
|
|
14758
15000
|
} catch (error) {
|
|
15001
|
+
if (error instanceof FailureThresholdExceededError || error instanceof CancellationError) {
|
|
15002
|
+
throw error;
|
|
15003
|
+
}
|
|
14759
15004
|
if (item.depth === 0) {
|
|
14760
15005
|
throw error;
|
|
14761
15006
|
}
|
|
15007
|
+
if (batchAbortError) {
|
|
15008
|
+
throw batchAbortError;
|
|
15009
|
+
}
|
|
15010
|
+
this.recordChildPageFailure(item);
|
|
15011
|
+
ensureFailureRateWithinThreshold();
|
|
14762
15012
|
if (options.ignoreErrors) {
|
|
14763
15013
|
logger.error(`❌ Failed to process ${item.url}: ${error}`);
|
|
14764
15014
|
return [];
|
|
@@ -14767,10 +15017,10 @@ class BaseScraperStrategy {
|
|
|
14767
15017
|
}
|
|
14768
15018
|
})
|
|
14769
15019
|
);
|
|
14770
|
-
const allLinks = results.flat();
|
|
15020
|
+
const allLinks = results.flat().filter((item) => item !== null);
|
|
14771
15021
|
const uniqueLinks = [];
|
|
14772
15022
|
for (const item of allLinks) {
|
|
14773
|
-
const normalizedUrl = normalizeUrl(item.url, this.options
|
|
15023
|
+
const normalizedUrl = normalizeUrl(item.url, this.getUrlNormalizerOptions(options));
|
|
14774
15024
|
if (!this.visited.has(normalizedUrl)) {
|
|
14775
15025
|
this.visited.add(normalizedUrl);
|
|
14776
15026
|
uniqueLinks.push(item);
|
|
@@ -14785,6 +15035,8 @@ class BaseScraperStrategy {
|
|
|
14785
15035
|
async scrape(options, progressCallback, signal) {
|
|
14786
15036
|
this.visited.clear();
|
|
14787
15037
|
this.pageCount = 0;
|
|
15038
|
+
this.completedChildPageAttempts = 0;
|
|
15039
|
+
this.failedChildPages = 0;
|
|
14788
15040
|
const initialQueue = options.initialQueue || [];
|
|
14789
15041
|
const isRefreshMode = initialQueue.length > 0;
|
|
14790
15042
|
this.canonicalBaseUrl = new URL$1(options.url);
|
|
@@ -14792,14 +15044,17 @@ class BaseScraperStrategy {
|
|
|
14792
15044
|
const queue = [];
|
|
14793
15045
|
const normalizedRootUrl = normalizeUrl(
|
|
14794
15046
|
options.url,
|
|
14795
|
-
this.options
|
|
15047
|
+
this.getUrlNormalizerOptions(options)
|
|
14796
15048
|
);
|
|
14797
15049
|
if (isRefreshMode) {
|
|
14798
15050
|
logger.debug(
|
|
14799
15051
|
`Starting refresh mode with ${initialQueue.length} pre-populated pages`
|
|
14800
15052
|
);
|
|
14801
15053
|
for (const item of initialQueue) {
|
|
14802
|
-
const normalizedUrl = normalizeUrl(
|
|
15054
|
+
const normalizedUrl = normalizeUrl(
|
|
15055
|
+
item.url,
|
|
15056
|
+
this.getUrlNormalizerOptions(options)
|
|
15057
|
+
);
|
|
14803
15058
|
if (!this.visited.has(normalizedUrl)) {
|
|
14804
15059
|
this.visited.add(normalizedUrl);
|
|
14805
15060
|
queue.push(item);
|
|
@@ -16061,6 +16316,23 @@ class WebScraperStrategy extends BaseScraperStrategy {
|
|
|
16061
16316
|
return false;
|
|
16062
16317
|
}
|
|
16063
16318
|
}
|
|
16319
|
+
restorePreservedHash(requestedUrl, actualUrl) {
|
|
16320
|
+
if (!requestedUrl.includes("#")) {
|
|
16321
|
+
return actualUrl;
|
|
16322
|
+
}
|
|
16323
|
+
try {
|
|
16324
|
+
const requested = new URL(requestedUrl);
|
|
16325
|
+
const actual = new URL(actualUrl);
|
|
16326
|
+
const normalizePathname = (pathname) => pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
|
|
16327
|
+
if (requested.origin === actual.origin && normalizePathname(requested.pathname) === normalizePathname(actual.pathname) && requested.search === actual.search) {
|
|
16328
|
+
actual.hash = requested.hash;
|
|
16329
|
+
return actual.toString();
|
|
16330
|
+
}
|
|
16331
|
+
} catch {
|
|
16332
|
+
return actualUrl;
|
|
16333
|
+
}
|
|
16334
|
+
return actualUrl;
|
|
16335
|
+
}
|
|
16064
16336
|
// Removed custom isInScope logic; using shared scope utility for consistent behavior
|
|
16065
16337
|
/**
|
|
16066
16338
|
* Processes a single queue item by fetching its content and processing it through pipelines.
|
|
@@ -16091,12 +16363,13 @@ class WebScraperStrategy extends BaseScraperStrategy {
|
|
|
16091
16363
|
// Pass ETag for conditional requests
|
|
16092
16364
|
};
|
|
16093
16365
|
const rawContent = await this.fetcher.fetch(url, fetchOptions);
|
|
16366
|
+
const effectiveSource = options.preserveHashes ? this.restorePreservedHash(url, rawContent.source) : rawContent.source;
|
|
16094
16367
|
logger.debug(
|
|
16095
16368
|
`Fetch result for ${url}: status=${rawContent.status}, etag=${rawContent.etag || "none"}`
|
|
16096
16369
|
);
|
|
16097
16370
|
if (rawContent.status !== FetchStatus.SUCCESS) {
|
|
16098
16371
|
logger.debug(`Skipping pipeline for ${url} due to status: ${rawContent.status}`);
|
|
16099
|
-
return { url:
|
|
16372
|
+
return { url: effectiveSource, links: [], status: rawContent.status };
|
|
16100
16373
|
}
|
|
16101
16374
|
let processed;
|
|
16102
16375
|
for (const pipeline of this.pipelines) {
|
|
@@ -16105,7 +16378,11 @@ class WebScraperStrategy extends BaseScraperStrategy {
|
|
|
16105
16378
|
logger.debug(
|
|
16106
16379
|
`Selected ${pipeline.constructor.name} for content type "${rawContent.mimeType}" (${url})`
|
|
16107
16380
|
);
|
|
16108
|
-
processed = await pipeline.process(
|
|
16381
|
+
processed = await pipeline.process(
|
|
16382
|
+
{ ...rawContent, source: effectiveSource },
|
|
16383
|
+
options,
|
|
16384
|
+
this.fetcher
|
|
16385
|
+
);
|
|
16109
16386
|
break;
|
|
16110
16387
|
}
|
|
16111
16388
|
}
|
|
@@ -16113,7 +16390,7 @@ class WebScraperStrategy extends BaseScraperStrategy {
|
|
|
16113
16390
|
logger.warn(
|
|
16114
16391
|
`⚠️ Unsupported content type "${rawContent.mimeType}" for URL ${url}. Skipping processing.`
|
|
16115
16392
|
);
|
|
16116
|
-
return { url:
|
|
16393
|
+
return { url: effectiveSource, links: [], status: FetchStatus.SUCCESS };
|
|
16117
16394
|
}
|
|
16118
16395
|
for (const err of processed.errors ?? []) {
|
|
16119
16396
|
logger.warn(`⚠️ Processing error for ${url}: ${err.message}`);
|
|
@@ -16123,13 +16400,13 @@ class WebScraperStrategy extends BaseScraperStrategy {
|
|
|
16123
16400
|
`⚠️ No processable content found for ${url} after pipeline execution.`
|
|
16124
16401
|
);
|
|
16125
16402
|
return {
|
|
16126
|
-
url:
|
|
16403
|
+
url: effectiveSource,
|
|
16127
16404
|
links: processed.links,
|
|
16128
16405
|
status: FetchStatus.SUCCESS
|
|
16129
16406
|
};
|
|
16130
16407
|
}
|
|
16131
16408
|
if (item.depth === 0) {
|
|
16132
|
-
this.canonicalBaseUrl = new URL(
|
|
16409
|
+
this.canonicalBaseUrl = new URL(effectiveSource);
|
|
16133
16410
|
}
|
|
16134
16411
|
const filteredLinks = processed.links?.filter((link) => {
|
|
16135
16412
|
try {
|
|
@@ -16150,7 +16427,7 @@ class WebScraperStrategy extends BaseScraperStrategy {
|
|
|
16150
16427
|
}
|
|
16151
16428
|
}) ?? [];
|
|
16152
16429
|
return {
|
|
16153
|
-
url:
|
|
16430
|
+
url: effectiveSource,
|
|
16154
16431
|
etag: rawContent.etag,
|
|
16155
16432
|
lastModified: rawContent.lastModified,
|
|
16156
16433
|
sourceContentType: rawContent.mimeType,
|
|
@@ -16529,6 +16806,20 @@ class PipelineManager {
|
|
|
16529
16806
|
scraperOptions: job.scraperOptions
|
|
16530
16807
|
};
|
|
16531
16808
|
}
|
|
16809
|
+
normalizeScraperOptions(options) {
|
|
16810
|
+
const normalizedOptions = {
|
|
16811
|
+
...options,
|
|
16812
|
+
scrapeMode: options.scrapeMode ?? ScrapeMode.Auto,
|
|
16813
|
+
preserveHashes: options.preserveHashes ?? this.appConfig.scraper.preserveHashes
|
|
16814
|
+
};
|
|
16815
|
+
if (normalizedOptions.preserveHashes && normalizedOptions.scrapeMode === ScrapeMode.Fetch) {
|
|
16816
|
+
logger.warn(
|
|
16817
|
+
`⚠️ Upgrading scrape mode to '${ScrapeMode.Playwright}' for ${options.url} because preserved hash routes are incompatible with '${ScrapeMode.Fetch}'.`
|
|
16818
|
+
);
|
|
16819
|
+
normalizedOptions.scrapeMode = ScrapeMode.Playwright;
|
|
16820
|
+
}
|
|
16821
|
+
return normalizedOptions;
|
|
16822
|
+
}
|
|
16532
16823
|
/**
|
|
16533
16824
|
* Starts the pipeline manager's worker processing.
|
|
16534
16825
|
*/
|
|
@@ -16644,6 +16935,7 @@ class PipelineManager {
|
|
|
16644
16935
|
);
|
|
16645
16936
|
await this.cancelJob(job2.id);
|
|
16646
16937
|
}
|
|
16938
|
+
const normalizedOptions = this.normalizeScraperOptions(options);
|
|
16647
16939
|
const jobId = v4();
|
|
16648
16940
|
const abortController = new AbortController();
|
|
16649
16941
|
let resolveCompletion;
|
|
@@ -16674,8 +16966,8 @@ class PipelineManager {
|
|
|
16674
16966
|
progressMaxPages: 0,
|
|
16675
16967
|
errorMessage: null,
|
|
16676
16968
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
16677
|
-
sourceUrl:
|
|
16678
|
-
scraperOptions:
|
|
16969
|
+
sourceUrl: normalizedOptions.url,
|
|
16970
|
+
scraperOptions: normalizedOptions
|
|
16679
16971
|
};
|
|
16680
16972
|
this.jobMap.set(jobId, job);
|
|
16681
16973
|
this.jobQueue.push(jobId);
|
|
@@ -16697,7 +16989,7 @@ class PipelineManager {
|
|
|
16697
16989
|
* If the version was never completed (interrupted or failed scrape), performs a
|
|
16698
16990
|
* full re-scrape from scratch instead of a refresh to ensure completeness.
|
|
16699
16991
|
*/
|
|
16700
|
-
async enqueueRefreshJob(library, version) {
|
|
16992
|
+
async enqueueRefreshJob(library, version, options) {
|
|
16701
16993
|
const normalizedVersion = version ?? "";
|
|
16702
16994
|
try {
|
|
16703
16995
|
const versionId = await this.store.ensureVersion({
|
|
@@ -16716,7 +17008,7 @@ class PipelineManager {
|
|
|
16716
17008
|
logger.info(
|
|
16717
17009
|
`⚠️ Version ${library}@${normalizedVersion || "latest"} has status "${versionInfo.status}". Performing full re-scrape instead of refresh.`
|
|
16718
17010
|
);
|
|
16719
|
-
return this.enqueueJobWithStoredOptions(library, normalizedVersion);
|
|
17011
|
+
return this.enqueueJobWithStoredOptions(library, normalizedVersion, options);
|
|
16720
17012
|
}
|
|
16721
17013
|
const pages = await this.store.getPagesByVersionId(versionId);
|
|
16722
17014
|
if (pages.length > 0) {
|
|
@@ -16747,6 +17039,7 @@ class PipelineManager {
|
|
|
16747
17039
|
version: normalizedVersion,
|
|
16748
17040
|
...storedOptions?.options || {},
|
|
16749
17041
|
// Include stored options if available (spread first)
|
|
17042
|
+
...options?.preserveHashes !== void 0 ? { preserveHashes: options.preserveHashes } : {},
|
|
16750
17043
|
// Override with refresh-specific options (these must come after the spread)
|
|
16751
17044
|
initialQueue,
|
|
16752
17045
|
// Pre-populated queue with existing pages
|
|
@@ -16766,7 +17059,7 @@ class PipelineManager {
|
|
|
16766
17059
|
* Enqueues a job using stored scraper options from a previous indexing run.
|
|
16767
17060
|
* If no stored options are found, throws an error.
|
|
16768
17061
|
*/
|
|
16769
|
-
async enqueueJobWithStoredOptions(library, version) {
|
|
17062
|
+
async enqueueJobWithStoredOptions(library, version, options) {
|
|
16770
17063
|
const normalizedVersion = version ?? "";
|
|
16771
17064
|
try {
|
|
16772
17065
|
const versionId = await this.store.ensureVersion({
|
|
@@ -16784,7 +17077,8 @@ class PipelineManager {
|
|
|
16784
17077
|
url: stored.sourceUrl,
|
|
16785
17078
|
library,
|
|
16786
17079
|
version: normalizedVersion,
|
|
16787
|
-
...storedOptions
|
|
17080
|
+
...storedOptions,
|
|
17081
|
+
...options?.preserveHashes !== void 0 ? { preserveHashes: options.preserveHashes } : {}
|
|
16788
17082
|
};
|
|
16789
17083
|
logger.info(
|
|
16790
17084
|
`🔄 Re-indexing ${library}@${normalizedVersion || "latest"} with stored options from ${stored.sourceUrl}`
|
|
@@ -17591,6 +17885,10 @@ function createRefreshCommand(cli) {
|
|
|
17591
17885
|
type: "string",
|
|
17592
17886
|
description: "Version of the library (optional)",
|
|
17593
17887
|
alias: "v"
|
|
17888
|
+
}).option("preserve-hashes", {
|
|
17889
|
+
type: "boolean",
|
|
17890
|
+
description: "Override the stored hash-route setting for this refresh job",
|
|
17891
|
+
alias: "preserveHashes"
|
|
17594
17892
|
}).option("embedding-model", {
|
|
17595
17893
|
type: "string",
|
|
17596
17894
|
description: "Embedding model configuration (e.g., 'openai:text-embedding-3-small')",
|
|
@@ -17608,6 +17906,7 @@ function createRefreshCommand(cli) {
|
|
|
17608
17906
|
command: "refresh",
|
|
17609
17907
|
library: argv.library,
|
|
17610
17908
|
version: argv.version,
|
|
17909
|
+
preserveHashes: argv.preserveHashes,
|
|
17611
17910
|
useServerUrl: !!argv.serverUrl
|
|
17612
17911
|
});
|
|
17613
17912
|
const library = argv.library;
|
|
@@ -17661,6 +17960,7 @@ function createRefreshCommand(cli) {
|
|
|
17661
17960
|
const result = await refreshTool.execute({
|
|
17662
17961
|
library,
|
|
17663
17962
|
version,
|
|
17963
|
+
preserveHashes: argv.preserveHashes,
|
|
17664
17964
|
waitForCompletion: true
|
|
17665
17965
|
// Always wait for completion in CLI
|
|
17666
17966
|
});
|
|
@@ -17791,6 +18091,10 @@ function createScrapeCommand(cli) {
|
|
|
17791
18091
|
description: "HTML processing strategy",
|
|
17792
18092
|
default: ScrapeMode.Auto,
|
|
17793
18093
|
alias: "scrapeMode"
|
|
18094
|
+
}).option("preserve-hashes", {
|
|
18095
|
+
type: "boolean",
|
|
18096
|
+
description: "Preserve URL hash fragments for hash-routed SPA documentation sites",
|
|
18097
|
+
alias: "preserveHashes"
|
|
17794
18098
|
}).option("include-pattern", {
|
|
17795
18099
|
type: "string",
|
|
17796
18100
|
array: true,
|
|
@@ -17836,6 +18140,7 @@ function createScrapeCommand(cli) {
|
|
|
17836
18140
|
const maxPages = argv.maxPages ?? appConfig.scraper.maxPages;
|
|
17837
18141
|
const maxDepth = argv.maxDepth ?? appConfig.scraper.maxDepth;
|
|
17838
18142
|
const maxConcurrency = argv.maxConcurrency ?? appConfig.scraper.maxConcurrency;
|
|
18143
|
+
const preserveHashes = typeof argv.preserveHashes === "boolean" ? argv.preserveHashes : appConfig.scraper.preserveHashes;
|
|
17839
18144
|
appConfig.scraper.maxPages = maxPages;
|
|
17840
18145
|
appConfig.scraper.maxDepth = maxDepth;
|
|
17841
18146
|
appConfig.scraper.maxConcurrency = maxConcurrency;
|
|
@@ -17849,6 +18154,7 @@ function createScrapeCommand(cli) {
|
|
|
17849
18154
|
maxConcurrency,
|
|
17850
18155
|
scope: argv.scope,
|
|
17851
18156
|
scrapeMode: argv.scrapeMode,
|
|
18157
|
+
preserveHashes,
|
|
17852
18158
|
followRedirects: argv.followRedirects,
|
|
17853
18159
|
hasHeaders: argv.header.length > 0,
|
|
17854
18160
|
hasIncludePatterns: argv.includePattern.length > 0,
|
|
@@ -17909,6 +18215,7 @@ function createScrapeCommand(cli) {
|
|
|
17909
18215
|
scope: argv.scope,
|
|
17910
18216
|
followRedirects: argv.followRedirects,
|
|
17911
18217
|
scrapeMode: argv.scrapeMode,
|
|
18218
|
+
preserveHashes,
|
|
17912
18219
|
includePatterns: argv.includePattern?.length > 0 ? argv.includePattern : void 0,
|
|
17913
18220
|
excludePatterns: argv.excludePattern?.length > 0 ? argv.excludePattern : void 0,
|
|
17914
18221
|
headers: Object.keys(headers).length > 0 ? headers : void 0,
|
|
@@ -18193,7 +18500,7 @@ function createCli(argv) {
|
|
|
18193
18500
|
let globalEventBus = null;
|
|
18194
18501
|
let globalTelemetryService = null;
|
|
18195
18502
|
const commandStartTimes = /* @__PURE__ */ new Map();
|
|
18196
|
-
const cli = registerGlobalOutputOptions(yargs(hideBin(argv))).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("2.2.
|
|
18503
|
+
const cli = registerGlobalOutputOptions(yargs(hideBin(argv))).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("2.2.2").option("verbose", {
|
|
18197
18504
|
type: "boolean",
|
|
18198
18505
|
description: "Enable verbose (debug) logging",
|
|
18199
18506
|
default: false
|
|
@@ -18254,7 +18561,7 @@ function createCli(argv) {
|
|
|
18254
18561
|
if (shouldEnableTelemetry() && telemetry.isEnabled()) {
|
|
18255
18562
|
const commandName = argv2._[0]?.toString() || "default";
|
|
18256
18563
|
telemetry.setGlobalContext({
|
|
18257
|
-
appVersion: "2.2.
|
|
18564
|
+
appVersion: "2.2.2",
|
|
18258
18565
|
appPlatform: process.platform,
|
|
18259
18566
|
appNodeVersion: process.version,
|
|
18260
18567
|
appInterface: "cli",
|
|
@@ -18400,4 +18707,4 @@ export {
|
|
|
18400
18707
|
cleanupCliCommand,
|
|
18401
18708
|
runCli
|
|
18402
18709
|
};
|
|
18403
|
-
//# sourceMappingURL=main-
|
|
18710
|
+
//# sourceMappingURL=main-DPijzQ1K.js.map
|