mcp-researchpowerpack 3.9.4 → 4.3.0
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 +116 -208
- package/dist/index.js +280 -337
- package/dist/index.js.map +7 -1
- package/dist/mcp-use.json +7 -0
- package/dist/src/clients/reddit.js +278 -0
- package/dist/src/clients/reddit.js.map +7 -0
- package/dist/src/clients/scraper.js +326 -0
- package/dist/src/clients/scraper.js.map +7 -0
- package/dist/src/clients/search.js +217 -0
- package/dist/src/clients/search.js.map +7 -0
- package/dist/src/config/index.js +138 -0
- package/dist/src/config/index.js.map +7 -0
- package/dist/src/prompts/deep-research.js +41 -0
- package/dist/src/prompts/deep-research.js.map +7 -0
- package/dist/src/prompts/reddit-sentiment.js +47 -0
- package/dist/src/prompts/reddit-sentiment.js.map +7 -0
- package/dist/src/schemas/reddit.js +21 -0
- package/dist/src/schemas/reddit.js.map +7 -0
- package/dist/src/schemas/scrape-links.js +26 -0
- package/dist/src/schemas/scrape-links.js.map +7 -0
- package/dist/src/schemas/start-research.js +17 -0
- package/dist/src/schemas/start-research.js.map +7 -0
- package/dist/src/schemas/web-search.js +53 -0
- package/dist/src/schemas/web-search.js.map +7 -0
- package/dist/src/services/llm-processor.js +675 -0
- package/dist/src/services/llm-processor.js.map +7 -0
- package/dist/src/services/markdown-cleaner.js +62 -0
- package/dist/src/services/markdown-cleaner.js.map +7 -0
- package/dist/src/services/workflow-state.js +116 -0
- package/dist/src/services/workflow-state.js.map +7 -0
- package/dist/src/tools/mcp-helpers.js +50 -0
- package/dist/src/tools/mcp-helpers.js.map +7 -0
- package/dist/src/tools/reddit.js +277 -0
- package/dist/src/tools/reddit.js.map +7 -0
- package/dist/src/tools/registry.js +18 -0
- package/dist/src/tools/registry.js.map +7 -0
- package/dist/src/tools/scrape.js +334 -0
- package/dist/src/tools/scrape.js.map +7 -0
- package/dist/src/tools/search.js +423 -0
- package/dist/src/tools/search.js.map +7 -0
- package/dist/src/tools/start-research.js +199 -0
- package/dist/src/tools/start-research.js.map +7 -0
- package/dist/src/tools/utils.js +29 -0
- package/dist/src/tools/utils.js.map +7 -0
- package/dist/src/utils/bootstrap-guard.js +27 -0
- package/dist/src/utils/bootstrap-guard.js.map +7 -0
- package/dist/src/utils/concurrency.js +62 -0
- package/dist/src/utils/concurrency.js.map +7 -0
- package/dist/src/utils/content-extractor.js +61 -0
- package/dist/src/utils/content-extractor.js.map +7 -0
- package/dist/src/utils/errors.js +211 -0
- package/dist/src/utils/errors.js.map +7 -0
- package/dist/src/utils/logger.js +25 -0
- package/dist/src/utils/logger.js.map +7 -0
- package/dist/src/utils/markdown-formatter.js +15 -0
- package/dist/src/utils/markdown-formatter.js.map +7 -0
- package/dist/src/utils/reddit-keyword-guard.js +29 -0
- package/dist/src/utils/reddit-keyword-guard.js.map +7 -0
- package/dist/src/utils/response.js +81 -0
- package/dist/src/utils/response.js.map +7 -0
- package/dist/src/utils/retry.js +13 -0
- package/dist/src/utils/retry.js.map +7 -0
- package/dist/src/utils/sanitize.js +10 -0
- package/dist/src/utils/sanitize.js.map +7 -0
- package/dist/src/utils/source-type.js +41 -0
- package/dist/src/utils/source-type.js.map +7 -0
- package/dist/src/utils/url-aggregator.js +227 -0
- package/dist/src/utils/url-aggregator.js.map +7 -0
- package/dist/src/utils/workflow-key.js +14 -0
- package/dist/src/utils/workflow-key.js.map +7 -0
- package/dist/src/version.js +32 -0
- package/dist/src/version.js.map +7 -0
- package/package.json +33 -28
- package/dist/clients/reddit.d.ts +0 -69
- package/dist/clients/reddit.d.ts.map +0 -1
- package/dist/clients/reddit.js +0 -369
- package/dist/clients/reddit.js.map +0 -1
- package/dist/clients/research.d.ts +0 -67
- package/dist/clients/research.d.ts.map +0 -1
- package/dist/clients/research.js +0 -290
- package/dist/clients/research.js.map +0 -1
- package/dist/clients/scraper.d.ts +0 -72
- package/dist/clients/scraper.d.ts.map +0 -1
- package/dist/clients/scraper.js +0 -338
- package/dist/clients/scraper.js.map +0 -1
- package/dist/clients/search.d.ts +0 -57
- package/dist/clients/search.d.ts.map +0 -1
- package/dist/clients/search.js +0 -223
- package/dist/clients/search.js.map +0 -1
- package/dist/config/index.d.ts +0 -78
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -201
- package/dist/config/index.js.map +0 -1
- package/dist/config/loader.d.ts +0 -40
- package/dist/config/loader.d.ts.map +0 -1
- package/dist/config/loader.js +0 -322
- package/dist/config/loader.js.map +0 -1
- package/dist/config/types.d.ts +0 -81
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -6
- package/dist/config/types.js.map +0 -1
- package/dist/config/yaml/tools.yaml +0 -146
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/schemas/deep-research.d.ts +0 -64
- package/dist/schemas/deep-research.d.ts.map +0 -1
- package/dist/schemas/deep-research.js +0 -224
- package/dist/schemas/deep-research.js.map +0 -1
- package/dist/schemas/scrape-links.d.ts +0 -32
- package/dist/schemas/scrape-links.d.ts.map +0 -1
- package/dist/schemas/scrape-links.js +0 -34
- package/dist/schemas/scrape-links.js.map +0 -1
- package/dist/schemas/web-search.d.ts +0 -22
- package/dist/schemas/web-search.d.ts.map +0 -1
- package/dist/schemas/web-search.js +0 -21
- package/dist/schemas/web-search.js.map +0 -1
- package/dist/services/file-attachment.d.ts +0 -30
- package/dist/services/file-attachment.d.ts.map +0 -1
- package/dist/services/file-attachment.js +0 -207
- package/dist/services/file-attachment.js.map +0 -1
- package/dist/services/llm-processor.d.ts +0 -29
- package/dist/services/llm-processor.d.ts.map +0 -1
- package/dist/services/llm-processor.js +0 -244
- package/dist/services/llm-processor.js.map +0 -1
- package/dist/services/markdown-cleaner.d.ts +0 -8
- package/dist/services/markdown-cleaner.d.ts.map +0 -1
- package/dist/services/markdown-cleaner.js +0 -74
- package/dist/services/markdown-cleaner.js.map +0 -1
- package/dist/tools/definitions.d.ts +0 -16
- package/dist/tools/definitions.d.ts.map +0 -1
- package/dist/tools/definitions.js +0 -17
- package/dist/tools/definitions.js.map +0 -1
- package/dist/tools/reddit.d.ts +0 -14
- package/dist/tools/reddit.d.ts.map +0 -1
- package/dist/tools/reddit.js +0 -265
- package/dist/tools/reddit.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -71
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -252
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/research.d.ts +0 -14
- package/dist/tools/research.d.ts.map +0 -1
- package/dist/tools/research.js +0 -196
- package/dist/tools/research.js.map +0 -1
- package/dist/tools/scrape.d.ts +0 -14
- package/dist/tools/scrape.d.ts.map +0 -1
- package/dist/tools/scrape.js +0 -234
- package/dist/tools/scrape.js.map +0 -1
- package/dist/tools/search.d.ts +0 -10
- package/dist/tools/search.d.ts.map +0 -1
- package/dist/tools/search.js +0 -158
- package/dist/tools/search.js.map +0 -1
- package/dist/tools/utils.d.ts +0 -105
- package/dist/tools/utils.d.ts.map +0 -1
- package/dist/tools/utils.js +0 -159
- package/dist/tools/utils.js.map +0 -1
- package/dist/utils/concurrency.d.ts +0 -28
- package/dist/utils/concurrency.d.ts.map +0 -1
- package/dist/utils/concurrency.js +0 -92
- package/dist/utils/concurrency.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -95
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -390
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -39
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -57
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/markdown-formatter.d.ts +0 -5
- package/dist/utils/markdown-formatter.d.ts.map +0 -1
- package/dist/utils/markdown-formatter.js +0 -15
- package/dist/utils/markdown-formatter.js.map +0 -1
- package/dist/utils/response.d.ts +0 -93
- package/dist/utils/response.d.ts.map +0 -1
- package/dist/utils/response.js +0 -170
- package/dist/utils/response.js.map +0 -1
- package/dist/utils/retry.d.ts +0 -43
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js +0 -57
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/url-aggregator.d.ts +0 -90
- package/dist/utils/url-aggregator.d.ts.map +0 -1
- package/dist/utils/url-aggregator.js +0 -538
- package/dist/utils/url-aggregator.js.map +0 -1
- package/dist/version.d.ts +0 -29
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -55
- package/dist/version.js.map +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const webSearchParamsSchema: z.ZodObject<{
|
|
3
|
-
keywords: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
4
|
-
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
keywords: string[];
|
|
6
|
-
}, {
|
|
7
|
-
keywords: string[];
|
|
8
|
-
}>;
|
|
9
|
-
export type WebSearchParams = z.infer<typeof webSearchParamsSchema>;
|
|
10
|
-
export interface WebSearchOutput {
|
|
11
|
-
readonly content: string;
|
|
12
|
-
readonly metadata: {
|
|
13
|
-
readonly total_keywords: number;
|
|
14
|
-
readonly total_results: number;
|
|
15
|
-
readonly execution_time_ms: number;
|
|
16
|
-
readonly total_unique_urls?: number;
|
|
17
|
-
readonly consensus_url_count?: number;
|
|
18
|
-
readonly frequency_threshold?: number;
|
|
19
|
-
readonly errorCode?: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=web-search.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/schemas/web-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0BxB,eAAO,MAAM,qBAAqB;;;;;;EAAiC,CAAC;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;QACnC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QACpC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
// Keyword schema with validation
|
|
3
|
-
const keywordSchema = z
|
|
4
|
-
.string({ required_error: 'web_search: Keyword is required' })
|
|
5
|
-
.min(1, { message: 'web_search: Keyword cannot be empty' })
|
|
6
|
-
.max(500, { message: 'web_search: Keyword too long (max 500 characters)' })
|
|
7
|
-
.refine(k => k.trim().length > 0, { message: 'web_search: Keyword cannot be whitespace only' });
|
|
8
|
-
// Input schema for web_search tool
|
|
9
|
-
const keywordsSchema = z
|
|
10
|
-
.array(keywordSchema, {
|
|
11
|
-
required_error: 'web_search: Keywords array is required',
|
|
12
|
-
invalid_type_error: 'web_search: Keywords must be an array'
|
|
13
|
-
})
|
|
14
|
-
.min(3, { message: 'web_search: MINIMUM 3 keywords required. Add more diverse keywords covering different perspectives.' })
|
|
15
|
-
.max(100, { message: 'web_search: Maximum 100 keywords allowed per request' })
|
|
16
|
-
.describe('Array of search keywords (MINIMUM 3, RECOMMENDED 5-7, MAX 100). Each keyword runs as a separate Google search in parallel. Use diverse keywords covering different angles for comprehensive results.');
|
|
17
|
-
const webSearchParamsShape = {
|
|
18
|
-
keywords: keywordsSchema,
|
|
19
|
-
};
|
|
20
|
-
export const webSearchParamsSchema = z.object(webSearchParamsShape);
|
|
21
|
-
//# sourceMappingURL=web-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../src/schemas/web-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iCAAiC;AACjC,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,CAAC,EAAE,cAAc,EAAE,iCAAiC,EAAE,CAAC;KAC7D,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,qCAAqC,EAAE,CAAC;KAC1D,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,mDAAmD,EAAE,CAAC;KAC1E,MAAM,CACL,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EACxB,EAAE,OAAO,EAAE,+CAA+C,EAAE,CAC7D,CAAC;AAEJ,mCAAmC;AACnC,MAAM,cAAc,GAAG,CAAC;KACrB,KAAK,CAAC,aAAa,EAAE;IACpB,cAAc,EAAE,wCAAwC;IACxD,kBAAkB,EAAE,uCAAuC;CAC5D,CAAC;KACD,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,qGAAqG,EAAE,CAAC;KAC1H,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,sDAAsD,EAAE,CAAC;KAC7E,QAAQ,CAAC,sMAAsM,CAAC,CAAC;AAEpN,MAAM,oBAAoB,GAAG;IAC3B,QAAQ,EAAE,cAAc;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File attachment service for reading and formatting file contents
|
|
3
|
-
*/
|
|
4
|
-
interface FileAttachment {
|
|
5
|
-
readonly path: string;
|
|
6
|
-
readonly start_line?: number | undefined;
|
|
7
|
-
readonly end_line?: number | undefined;
|
|
8
|
-
readonly description?: string | undefined;
|
|
9
|
-
}
|
|
10
|
-
export declare class FileAttachmentService {
|
|
11
|
-
/**
|
|
12
|
-
* Format multiple file attachments into a markdown section
|
|
13
|
-
*/
|
|
14
|
-
formatAttachments(attachments: FileAttachment[]): Promise<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Format a single file attachment
|
|
17
|
-
*/
|
|
18
|
-
private formatSingleFile;
|
|
19
|
-
/**
|
|
20
|
-
* Format code block with line numbers and smart truncation
|
|
21
|
-
*/
|
|
22
|
-
private formatCodeBlock;
|
|
23
|
-
/**
|
|
24
|
-
* Validate line range and return corrected values
|
|
25
|
-
*/
|
|
26
|
-
private validateLineRange;
|
|
27
|
-
private detectLanguage;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=file-attachment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-attachment.d.ts","sourceRoot":"","sources":["../../src/services/file-attachment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,UAAU,cAAc;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AASD,qBAAa,qBAAqB;IAChC;;OAEG;IACG,iBAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBvE;;OAEG;YACW,gBAAgB;IAsE9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAiCvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoEzB,OAAO,CAAC,cAAc;CAcvB"}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File attachment service for reading and formatting file contents
|
|
3
|
-
*/
|
|
4
|
-
import { access, readFile } from 'node:fs/promises';
|
|
5
|
-
import { extname } from 'node:path';
|
|
6
|
-
import { pMap } from '../utils/concurrency.js';
|
|
7
|
-
/** Maximum lines shown before smart truncation kicks in */
|
|
8
|
-
const TRUNCATION_THRESHOLD = 600;
|
|
9
|
-
/** Number of leading lines to keep when truncating */
|
|
10
|
-
const TRUNCATION_HEAD_LINES = 500;
|
|
11
|
-
/** Number of trailing lines to keep when truncating */
|
|
12
|
-
const TRUNCATION_TAIL_LINES = 100;
|
|
13
|
-
/** Default concurrency for parallel file reads */
|
|
14
|
-
const FILE_READ_CONCURRENCY = 5;
|
|
15
|
-
export class FileAttachmentService {
|
|
16
|
-
/**
|
|
17
|
-
* Format multiple file attachments into a markdown section
|
|
18
|
-
*/
|
|
19
|
-
async formatAttachments(attachments) {
|
|
20
|
-
if (!attachments || attachments.length === 0) {
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
const results = await pMap(attachments, (attachment) => this.formatSingleFile(attachment), FILE_READ_CONCURRENCY);
|
|
24
|
-
// Build the attachments section
|
|
25
|
-
const parts = ['\n\n---\n\n# 📎 ATTACHED FILES\n\n'];
|
|
26
|
-
parts.push(`*${results.length} file${results.length > 1 ? 's' : ''} attached for context*\n\n`);
|
|
27
|
-
for (const result of results) {
|
|
28
|
-
parts.push(result.content);
|
|
29
|
-
parts.push('\n\n');
|
|
30
|
-
}
|
|
31
|
-
return parts.join('');
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Format a single file attachment
|
|
35
|
-
*/
|
|
36
|
-
async formatSingleFile(attachment) {
|
|
37
|
-
const { path, start_line, end_line, description } = attachment;
|
|
38
|
-
// Check if file exists
|
|
39
|
-
try {
|
|
40
|
-
await access(path);
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return {
|
|
44
|
-
success: false,
|
|
45
|
-
path,
|
|
46
|
-
content: `## ❌ ${path}\n\n**FILE NOT FOUND**\n${description ? `\n*Description:* ${description}\n` : ''}`,
|
|
47
|
-
error: 'File not found',
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
// Read file content
|
|
52
|
-
const content = await readFile(path, 'utf-8');
|
|
53
|
-
const lines = content.split('\n');
|
|
54
|
-
const language = this.detectLanguage(path);
|
|
55
|
-
// Validate line ranges
|
|
56
|
-
const validatedRange = this.validateLineRange(start_line, end_line, lines.length);
|
|
57
|
-
if (!validatedRange.valid) {
|
|
58
|
-
return {
|
|
59
|
-
success: false,
|
|
60
|
-
path,
|
|
61
|
-
content: `## ⚠️ ${path}\n\n**INVALID LINE RANGE**: ${validatedRange.error}\n${description ? `\n*Description:* ${description}\n` : ''}`,
|
|
62
|
-
error: validatedRange.error,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
// Extract relevant lines
|
|
66
|
-
const startIdx = validatedRange.start - 1;
|
|
67
|
-
const endIdx = validatedRange.end - 1;
|
|
68
|
-
const selectedLines = lines.slice(startIdx, endIdx + 1);
|
|
69
|
-
// Build formatted output
|
|
70
|
-
let formatted = `## 📄 ${path}\n\n`;
|
|
71
|
-
// Add metadata
|
|
72
|
-
const isPartial = start_line !== undefined || end_line !== undefined;
|
|
73
|
-
formatted += `**Language:** ${language} | `;
|
|
74
|
-
formatted += `**Lines:** ${isPartial ? `${validatedRange.start}-${validatedRange.end}` : lines.length} | `;
|
|
75
|
-
formatted += `**Size:** ${(content.length / 1024).toFixed(2)} KB\n`;
|
|
76
|
-
if (description) {
|
|
77
|
-
formatted += `\n*${description}*\n`;
|
|
78
|
-
}
|
|
79
|
-
formatted += '\n';
|
|
80
|
-
// Add file content with line numbers
|
|
81
|
-
formatted += this.formatCodeBlock(selectedLines, language, startIdx);
|
|
82
|
-
return {
|
|
83
|
-
success: true,
|
|
84
|
-
path,
|
|
85
|
-
content: formatted,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return {
|
|
90
|
-
success: false,
|
|
91
|
-
path,
|
|
92
|
-
content: `## ❌ ${path}\n\n**ERROR READING FILE**: Unable to read the specified file. Please verify the file path exists and is accessible.\n${description ? `\n*Description:* ${description}\n` : ''}`,
|
|
93
|
-
error: 'Unable to read the specified file',
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Format code block with line numbers and smart truncation
|
|
99
|
-
*/
|
|
100
|
-
formatCodeBlock(lines, language, startIdx) {
|
|
101
|
-
const parts = [`\`\`\`${language.toLowerCase()}\n`];
|
|
102
|
-
// Smart truncation for very large files (keep first N lines + last M lines)
|
|
103
|
-
if (lines.length > TRUNCATION_THRESHOLD) {
|
|
104
|
-
// First N lines
|
|
105
|
-
const firstLines = lines.slice(0, TRUNCATION_HEAD_LINES);
|
|
106
|
-
for (let idx = 0; idx < firstLines.length; idx++) {
|
|
107
|
-
const lineNumber = startIdx + idx + 1;
|
|
108
|
-
parts.push(`${lineNumber.toString().padStart(4, ' ')}: ${firstLines[idx]}\n`);
|
|
109
|
-
}
|
|
110
|
-
// Truncation marker
|
|
111
|
-
parts.push(`\n... [${lines.length - TRUNCATION_THRESHOLD} lines truncated for brevity] ...\n\n`);
|
|
112
|
-
// Last M lines
|
|
113
|
-
const lastLines = lines.slice(-TRUNCATION_TAIL_LINES);
|
|
114
|
-
for (let idx = 0; idx < lastLines.length; idx++) {
|
|
115
|
-
const lineNumber = startIdx + lines.length - TRUNCATION_TAIL_LINES + idx + 1;
|
|
116
|
-
parts.push(`${lineNumber.toString().padStart(4, ' ')}: ${lastLines[idx]}\n`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
// Show all lines with numbers
|
|
121
|
-
for (let idx = 0; idx < lines.length; idx++) {
|
|
122
|
-
const lineNumber = startIdx + idx + 1;
|
|
123
|
-
parts.push(`${lineNumber.toString().padStart(4, ' ')}: ${lines[idx]}\n`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
parts.push('```');
|
|
127
|
-
return parts.join('');
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Validate line range and return corrected values
|
|
131
|
-
*/
|
|
132
|
-
validateLineRange(start_line, end_line, totalLines) {
|
|
133
|
-
// No range specified - return full file
|
|
134
|
-
if (start_line === undefined && end_line === undefined) {
|
|
135
|
-
return { valid: true, start: 1, end: totalLines };
|
|
136
|
-
}
|
|
137
|
-
// Only start_line specified
|
|
138
|
-
if (start_line !== undefined && end_line === undefined) {
|
|
139
|
-
if (start_line < 1 || start_line > totalLines) {
|
|
140
|
-
return {
|
|
141
|
-
valid: false,
|
|
142
|
-
start: 1,
|
|
143
|
-
end: totalLines,
|
|
144
|
-
error: `start_line ${start_line} out of range (1-${totalLines})`,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return { valid: true, start: start_line, end: totalLines };
|
|
148
|
-
}
|
|
149
|
-
// Only end_line specified
|
|
150
|
-
if (start_line === undefined && end_line !== undefined) {
|
|
151
|
-
if (end_line < 1 || end_line > totalLines) {
|
|
152
|
-
return {
|
|
153
|
-
valid: false,
|
|
154
|
-
start: 1,
|
|
155
|
-
end: totalLines,
|
|
156
|
-
error: `end_line ${end_line} out of range (1-${totalLines})`,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return { valid: true, start: 1, end: end_line };
|
|
160
|
-
}
|
|
161
|
-
// Both specified
|
|
162
|
-
if (start_line !== undefined && end_line !== undefined) {
|
|
163
|
-
if (start_line < 1 || start_line > totalLines) {
|
|
164
|
-
return {
|
|
165
|
-
valid: false,
|
|
166
|
-
start: 1,
|
|
167
|
-
end: totalLines,
|
|
168
|
-
error: `start_line ${start_line} out of range (1-${totalLines})`,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
if (end_line < 1 || end_line > totalLines) {
|
|
172
|
-
return {
|
|
173
|
-
valid: false,
|
|
174
|
-
start: 1,
|
|
175
|
-
end: totalLines,
|
|
176
|
-
error: `end_line ${end_line} out of range (1-${totalLines})`,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
if (start_line > end_line) {
|
|
180
|
-
return {
|
|
181
|
-
valid: false,
|
|
182
|
-
start: 1,
|
|
183
|
-
end: totalLines,
|
|
184
|
-
error: `start_line ${start_line} cannot be greater than end_line ${end_line}`,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
return { valid: true, start: start_line, end: end_line };
|
|
188
|
-
}
|
|
189
|
-
return { valid: true, start: 1, end: totalLines };
|
|
190
|
-
}
|
|
191
|
-
detectLanguage(filePath) {
|
|
192
|
-
const ext = extname(filePath).toLowerCase();
|
|
193
|
-
const map = {
|
|
194
|
-
'.js': 'javascript', '.jsx': 'javascript', '.mjs': 'javascript',
|
|
195
|
-
'.ts': 'typescript', '.tsx': 'typescript',
|
|
196
|
-
'.py': 'python', '.go': 'go', '.rs': 'rust', '.rb': 'ruby',
|
|
197
|
-
'.java': 'java', '.c': 'c', '.cpp': 'cpp', '.h': 'c',
|
|
198
|
-
'.json': 'json', '.yaml': 'yaml', '.yml': 'yaml', '.toml': 'toml',
|
|
199
|
-
'.md': 'markdown', '.html': 'html', '.css': 'css', '.sql': 'sql',
|
|
200
|
-
'.sh': 'bash', '.xml': 'xml',
|
|
201
|
-
};
|
|
202
|
-
if (filePath.endsWith('Dockerfile'))
|
|
203
|
-
return 'dockerfile';
|
|
204
|
-
return map[ext] || 'text';
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
//# sourceMappingURL=file-attachment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-attachment.js","sourceRoot":"","sources":["../../src/services/file-attachment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,O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,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY;YACzC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;YAC1D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG;YACpD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;YACjE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;YAChE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK;SAC7B,CAAC;QACF,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,OAAO,YAAY,CAAC;QACzD,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Processor for content extraction
|
|
3
|
-
* Uses OpenRouter via OPENROUTER_API_KEY for AI-powered content filtering
|
|
4
|
-
* Implements robust retry logic and NEVER throws
|
|
5
|
-
*/
|
|
6
|
-
import OpenAI from 'openai';
|
|
7
|
-
import { type StructuredError } from '../utils/errors.js';
|
|
8
|
-
/** Default concurrency for parallel LLM extractions */
|
|
9
|
-
export declare const DEFAULT_LLM_CONCURRENCY: 3;
|
|
10
|
-
interface ProcessingConfig {
|
|
11
|
-
readonly use_llm: boolean;
|
|
12
|
-
readonly what_to_extract: string | undefined;
|
|
13
|
-
readonly max_tokens?: number;
|
|
14
|
-
}
|
|
15
|
-
interface LLMResult {
|
|
16
|
-
readonly content: string;
|
|
17
|
-
readonly processed: boolean;
|
|
18
|
-
readonly error?: string;
|
|
19
|
-
readonly errorDetails?: StructuredError;
|
|
20
|
-
}
|
|
21
|
-
export declare function createLLMProcessor(): OpenAI | null;
|
|
22
|
-
/**
|
|
23
|
-
* Process content with LLM extraction
|
|
24
|
-
* NEVER throws - always returns a valid LLMResult
|
|
25
|
-
* Implements retry logic with exponential backoff for transient failures
|
|
26
|
-
*/
|
|
27
|
-
export declare function processContentWithLLM(content: string, config: ProcessingConfig, processor?: OpenAI | null, signal?: AbortSignal): Promise<LLMResult>;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=llm-processor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llm-processor.d.ts","sourceRoot":"","sources":["../../src/services/llm-processor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAG5B,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAiBlD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,UAAU,SAAS;IACjB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC;CACzC;AA8BD,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CA2BlD;AA8DD;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EACzB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,SAAS,CAAC,CA6IpB"}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Processor for content extraction
|
|
3
|
-
* Uses OpenRouter via OPENROUTER_API_KEY for AI-powered content filtering
|
|
4
|
-
* Implements robust retry logic and NEVER throws
|
|
5
|
-
*/
|
|
6
|
-
import OpenAI from 'openai';
|
|
7
|
-
import { RESEARCH, LLM_EXTRACTION, CEREBRAS, getCapabilities } from '../config/index.js';
|
|
8
|
-
import { classifyError, sleep, ErrorCode, withRequestTimeout, withStallProtection, } from '../utils/errors.js';
|
|
9
|
-
import { mcpLog } from '../utils/logger.js';
|
|
10
|
-
/** Default concurrency for parallel LLM extractions */
|
|
11
|
-
export const DEFAULT_LLM_CONCURRENCY = 3;
|
|
12
|
-
/** Maximum input characters for LLM processing (~25k tokens) */
|
|
13
|
-
const MAX_LLM_INPUT_CHARS = 100_000;
|
|
14
|
-
/** LLM client timeout in milliseconds */
|
|
15
|
-
const LLM_CLIENT_TIMEOUT_MS = 120_000;
|
|
16
|
-
/** Jitter factor for exponential backoff */
|
|
17
|
-
const BACKOFF_JITTER_FACTOR = 0.3;
|
|
18
|
-
/** Stall detection timeout — abort if no response in this time */
|
|
19
|
-
const LLM_STALL_TIMEOUT_MS = 15_000;
|
|
20
|
-
/** Hard request deadline for LLM calls */
|
|
21
|
-
const LLM_REQUEST_DEADLINE_MS = 30_000;
|
|
22
|
-
// LLM-specific retry configuration
|
|
23
|
-
const LLM_RETRY_CONFIG = {
|
|
24
|
-
maxRetries: 2,
|
|
25
|
-
baseDelayMs: 1000,
|
|
26
|
-
maxDelayMs: 5000,
|
|
27
|
-
};
|
|
28
|
-
// OpenRouter/OpenAI specific retryable error codes (using Set for type-safe lookup)
|
|
29
|
-
const RETRYABLE_LLM_ERROR_CODES = new Set([
|
|
30
|
-
'rate_limit_exceeded',
|
|
31
|
-
'server_error',
|
|
32
|
-
'timeout',
|
|
33
|
-
'service_unavailable',
|
|
34
|
-
]);
|
|
35
|
-
/** Type guard for errors with an HTTP status code */
|
|
36
|
-
function hasStatus(error) {
|
|
37
|
-
return (typeof error === 'object' &&
|
|
38
|
-
error !== null &&
|
|
39
|
-
'status' in error &&
|
|
40
|
-
typeof error.status === 'number');
|
|
41
|
-
}
|
|
42
|
-
let llmClient = null;
|
|
43
|
-
let cerebrasClient = null;
|
|
44
|
-
export function createLLMProcessor() {
|
|
45
|
-
if (!getCapabilities().llmExtraction)
|
|
46
|
-
return null;
|
|
47
|
-
// Cerebras takes priority when enabled
|
|
48
|
-
if (CEREBRAS.ENABLED) {
|
|
49
|
-
if (!cerebrasClient) {
|
|
50
|
-
cerebrasClient = new OpenAI({
|
|
51
|
-
baseURL: CEREBRAS.BASE_URL,
|
|
52
|
-
apiKey: CEREBRAS.API_KEY,
|
|
53
|
-
timeout: LLM_CLIENT_TIMEOUT_MS,
|
|
54
|
-
maxRetries: 0,
|
|
55
|
-
});
|
|
56
|
-
mcpLog('info', `LLM extraction using Cerebras (${CEREBRAS.MODEL})`, 'llm');
|
|
57
|
-
}
|
|
58
|
-
return cerebrasClient;
|
|
59
|
-
}
|
|
60
|
-
// Default: OpenRouter
|
|
61
|
-
if (!llmClient) {
|
|
62
|
-
llmClient = new OpenAI({
|
|
63
|
-
baseURL: RESEARCH.BASE_URL,
|
|
64
|
-
apiKey: RESEARCH.API_KEY,
|
|
65
|
-
timeout: LLM_CLIENT_TIMEOUT_MS,
|
|
66
|
-
maxRetries: 0,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return llmClient;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Check if an LLM error is retryable
|
|
73
|
-
*/
|
|
74
|
-
function isRetryableLLMError(error) {
|
|
75
|
-
if (!error || typeof error !== 'object')
|
|
76
|
-
return false;
|
|
77
|
-
// Stall/timeout protection errors - always retry these
|
|
78
|
-
const stallCode = error?.code;
|
|
79
|
-
if (stallCode === 'ESTALLED' || stallCode === 'ETIMEDOUT') {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
// Check HTTP status codes
|
|
83
|
-
if (hasStatus(error)) {
|
|
84
|
-
if (error.status === 429 || error.status === 500 || error.status === 502 || error.status === 503 || error.status === 504) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Check error codes from OpenAI/OpenRouter
|
|
89
|
-
const record = error;
|
|
90
|
-
const code = typeof record.code === 'string' ? record.code : undefined;
|
|
91
|
-
const nested = typeof record.error === 'object' && record.error !== null
|
|
92
|
-
? record.error
|
|
93
|
-
: null;
|
|
94
|
-
const errorCode = code ??
|
|
95
|
-
(nested && typeof nested.code === 'string' ? nested.code : undefined) ??
|
|
96
|
-
(nested && typeof nested.type === 'string' ? nested.type : undefined);
|
|
97
|
-
if (errorCode && RETRYABLE_LLM_ERROR_CODES.has(errorCode)) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
// Check message for common patterns
|
|
101
|
-
const message = typeof record.message === 'string' ? record.message.toLowerCase() : '';
|
|
102
|
-
if (message.includes('rate limit') ||
|
|
103
|
-
message.includes('timeout') ||
|
|
104
|
-
message.includes('timed out') ||
|
|
105
|
-
message.includes('service unavailable') ||
|
|
106
|
-
message.includes('server error') ||
|
|
107
|
-
message.includes('connection') ||
|
|
108
|
-
message.includes('econnreset')) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Calculate backoff delay with jitter for LLM retries
|
|
115
|
-
*/
|
|
116
|
-
function calculateLLMBackoff(attempt) {
|
|
117
|
-
const exponentialDelay = LLM_RETRY_CONFIG.baseDelayMs * Math.pow(2, attempt);
|
|
118
|
-
const jitter = Math.random() * BACKOFF_JITTER_FACTOR * exponentialDelay;
|
|
119
|
-
return Math.min(exponentialDelay + jitter, LLM_RETRY_CONFIG.maxDelayMs);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Process content with LLM extraction
|
|
123
|
-
* NEVER throws - always returns a valid LLMResult
|
|
124
|
-
* Implements retry logic with exponential backoff for transient failures
|
|
125
|
-
*/
|
|
126
|
-
export async function processContentWithLLM(content, config, processor, signal) {
|
|
127
|
-
// Early returns for invalid/skip conditions
|
|
128
|
-
if (!config.use_llm) {
|
|
129
|
-
return { content, processed: false };
|
|
130
|
-
}
|
|
131
|
-
if (!processor) {
|
|
132
|
-
return {
|
|
133
|
-
content,
|
|
134
|
-
processed: false,
|
|
135
|
-
error: 'LLM processor not available (OPENROUTER_API_KEY not set)',
|
|
136
|
-
errorDetails: {
|
|
137
|
-
code: ErrorCode.AUTH_ERROR,
|
|
138
|
-
message: 'LLM processor not available',
|
|
139
|
-
retryable: false,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
if (!content?.trim()) {
|
|
144
|
-
return { content: content || '', processed: false, error: 'Empty content provided' };
|
|
145
|
-
}
|
|
146
|
-
// Truncate extremely long content to avoid token limits
|
|
147
|
-
const truncatedContent = content.length > MAX_LLM_INPUT_CHARS
|
|
148
|
-
? content.substring(0, MAX_LLM_INPUT_CHARS) + '\n\n[Content truncated due to length]'
|
|
149
|
-
: content;
|
|
150
|
-
const prompt = config.what_to_extract
|
|
151
|
-
? `Extract and clean the following content. Focus on: ${config.what_to_extract}\n\nContent:\n${truncatedContent}`
|
|
152
|
-
: `Clean and extract the main content from the following text, removing navigation, ads, and irrelevant elements:\n\n${truncatedContent}`;
|
|
153
|
-
// Select model based on Cerebras availability
|
|
154
|
-
const activeModel = CEREBRAS.ENABLED ? CEREBRAS.MODEL : LLM_EXTRACTION.MODEL;
|
|
155
|
-
// Build request body
|
|
156
|
-
const requestBody = {
|
|
157
|
-
model: activeModel,
|
|
158
|
-
messages: [{ role: 'user', content: prompt }],
|
|
159
|
-
max_tokens: config.max_tokens || LLM_EXTRACTION.MAX_TOKENS,
|
|
160
|
-
};
|
|
161
|
-
// Cerebras doesn't support reasoning parameter
|
|
162
|
-
if (!CEREBRAS.ENABLED && LLM_EXTRACTION.ENABLE_REASONING) {
|
|
163
|
-
requestBody.reasoning = { enabled: true };
|
|
164
|
-
}
|
|
165
|
-
let lastError;
|
|
166
|
-
// Retry loop
|
|
167
|
-
for (let attempt = 0; attempt <= LLM_RETRY_CONFIG.maxRetries; attempt++) {
|
|
168
|
-
try {
|
|
169
|
-
if (attempt === 0) {
|
|
170
|
-
mcpLog('info', `Starting extraction with ${activeModel}${CEREBRAS.ENABLED ? ' (Cerebras)' : ''}`, 'llm');
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
mcpLog('warning', `Retry attempt ${attempt}/${LLM_RETRY_CONFIG.maxRetries}`, 'llm');
|
|
174
|
-
}
|
|
175
|
-
const response = await withStallProtection((stallSignal) => withRequestTimeout((timeoutSignal) => {
|
|
176
|
-
// Merge external signal, stall signal, and timeout signal
|
|
177
|
-
const mergedController = new AbortController();
|
|
178
|
-
const abortMerged = () => mergedController.abort();
|
|
179
|
-
signal?.addEventListener('abort', abortMerged, { once: true });
|
|
180
|
-
stallSignal.addEventListener('abort', abortMerged, { once: true });
|
|
181
|
-
timeoutSignal.addEventListener('abort', abortMerged, { once: true });
|
|
182
|
-
return processor.chat.completions.create(requestBody, { signal: mergedController.signal }).finally(() => {
|
|
183
|
-
signal?.removeEventListener('abort', abortMerged);
|
|
184
|
-
stallSignal.removeEventListener('abort', abortMerged);
|
|
185
|
-
timeoutSignal.removeEventListener('abort', abortMerged);
|
|
186
|
-
});
|
|
187
|
-
}, LLM_REQUEST_DEADLINE_MS, `LLM extraction (${activeModel})`), LLM_STALL_TIMEOUT_MS, 3, `LLM extraction (${activeModel})`);
|
|
188
|
-
const result = response.choices?.[0]?.message?.content;
|
|
189
|
-
if (result && result.trim()) {
|
|
190
|
-
mcpLog('info', `Successfully extracted ${result.length} characters`, 'llm');
|
|
191
|
-
return { content: result, processed: true };
|
|
192
|
-
}
|
|
193
|
-
// Empty response - not retryable
|
|
194
|
-
mcpLog('warning', 'Received empty response from LLM', 'llm');
|
|
195
|
-
return {
|
|
196
|
-
content,
|
|
197
|
-
processed: false,
|
|
198
|
-
error: 'LLM returned empty response',
|
|
199
|
-
errorDetails: {
|
|
200
|
-
code: ErrorCode.INTERNAL_ERROR,
|
|
201
|
-
message: 'LLM returned empty response',
|
|
202
|
-
retryable: false,
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
catch (err) {
|
|
207
|
-
lastError = classifyError(err);
|
|
208
|
-
// Log the error
|
|
209
|
-
const status = hasStatus(err) ? err.status : undefined;
|
|
210
|
-
const code = typeof err === 'object' && err !== null && 'code' in err
|
|
211
|
-
? String(err.code)
|
|
212
|
-
: undefined;
|
|
213
|
-
mcpLog('error', `Error (attempt ${attempt + 1}): ${lastError.message} [status=${status}, code=${code}, retryable=${isRetryableLLMError(err)}]`, 'llm');
|
|
214
|
-
// Check if we should retry
|
|
215
|
-
if (isRetryableLLMError(err) && attempt < LLM_RETRY_CONFIG.maxRetries) {
|
|
216
|
-
const delayMs = calculateLLMBackoff(attempt);
|
|
217
|
-
mcpLog('warning', `Retrying in ${delayMs}ms...`, 'llm');
|
|
218
|
-
try {
|
|
219
|
-
await sleep(delayMs, signal);
|
|
220
|
-
}
|
|
221
|
-
catch {
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
// Non-retryable or max retries reached
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
// All attempts failed - return original content with error info
|
|
231
|
-
const errorMessage = lastError?.message || 'Unknown LLM error';
|
|
232
|
-
mcpLog('error', `All attempts failed: ${errorMessage}. Returning original content.`, 'llm');
|
|
233
|
-
return {
|
|
234
|
-
content, // Return original content as fallback
|
|
235
|
-
processed: false,
|
|
236
|
-
error: `LLM extraction failed: ${errorMessage}`,
|
|
237
|
-
errorDetails: lastError || {
|
|
238
|
-
code: ErrorCode.UNKNOWN_ERROR,
|
|
239
|
-
message: errorMessage,
|
|
240
|
-
retryable: false,
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=llm-processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llm-processor.js","sourceRoot":"","sources":["../../src/services/llm-processor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EACL,aAAa,EACb,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,uDAAuD;AACvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAU,CAAC;AAElD,gEAAgE;AAChE,MAAM,mBAAmB,GAAG,OAAgB,CAAC;AAE7C,yCAAyC;AACzC,MAAM,qBAAqB,GAAG,OAAgB,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,qBAAqB,GAAG,GAAY,CAAC;AAE3C,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,MAAe,CAAC;AAE7C,0CAA0C;AAC1C,MAAM,uBAAuB,GAAG,MAAe,CAAC;AAehD,mCAAmC;AACnC,MAAM,gBAAgB,GAAG;IACvB,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,IAAI;CACR,CAAC;AAEX,oFAAoF;AACpF,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,qBAAqB;IACrB,cAAc;IACd,SAAS;IACT,qBAAqB;CACtB,CAAC,CAAC;AAEH,qDAAqD;AACrD,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,IAAI,KAAK;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AC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAEvJ,2BAA2B;YAC3B,IAAI,mBAAmB,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,gBAAgB,CAAC,UAAU,EAAE,CAAC;gBACtE,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBAC7C,MAAM,CAAC,SAAS,EAAE,eAAe,OAAO,OAAO,EAAE,KAAK,CAAC,CAAC;gBACxD,IAAI,CAAC;oBAAC,MAAM,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC;oBAAC,MAAM;gBAAC,CAAC;gBACtD,SAAS;YACX,CAAC;YAED,uCAAuC;YACvC,MAAM;QACR,CAAC;IACH,CAAC;IAED,gEAAgE;IAChE,MAAM,YAAY,GAAG,SAAS,EAAE,OAAO,IAAI,mBAAmB,CAAC;IAC/D,MAAM,CAAC,OAAO,EAAE,wBAAwB,YAAY,+BAA+B,EAAE,KAAK,CAAC,CAAC;IAE5F,OAAO;QACL,OAAO,EAAE,sCAAsC;QAC/C,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,0BAA0B,YAAY,EAAE;QAC/C,YAAY,EAAE,SAAS,IAAI;YACzB,IAAI,EAAE,SAAS,CAAC,aAAa;YAC7B,OAAO,EAAE,YAAY;YACrB,SAAS,EAAE,KAAK;SACjB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare class MarkdownCleaner {
|
|
2
|
-
/**
|
|
3
|
-
* Process HTML content and convert to clean Markdown
|
|
4
|
-
* NEVER throws - returns original content on any error for graceful degradation
|
|
5
|
-
*/
|
|
6
|
-
processContent(htmlContent: string): string;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=markdown-cleaner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-cleaner.d.ts","sourceRoot":"","sources":["../../src/services/markdown-cleaner.ts"],"names":[],"mappings":"AAsCA,qBAAa,eAAe;IAC1B;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;CAwC5C"}
|