@autorag/librarian 2.13.9 → 2.13.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +56 -32
- package/dist/core.d.ts +5 -0
- package/dist/core.js +46 -23
- package/dist/filesystem/path-exclusions.d.ts +12 -1
- package/dist/index.js +158 -31
- package/dist/mcp/index.js +205 -34
- package/dist/mcp/reloading-lite.d.ts +25 -0
- package/dist/mcp/server.d.ts +16 -0
- package/dist/mirror/sync.d.ts +1 -0
- package/dist/profiles.js +49 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3668,20 +3668,30 @@ var init_bundle = __esm(() => {
|
|
|
3668
3668
|
});
|
|
3669
3669
|
|
|
3670
3670
|
// src/filesystem/path-exclusions.ts
|
|
3671
|
-
import { posix as posix2, win32 as win322 } from "node:path";
|
|
3671
|
+
import { matchesGlob, posix as posix2, win32 as win322 } from "node:path";
|
|
3672
|
+
function isGlobExclusion(entry) {
|
|
3673
|
+
return /[*?[]/u.test(entry);
|
|
3674
|
+
}
|
|
3675
|
+
function matchesGlobExclusion(path, glob) {
|
|
3676
|
+
const slashed = path.replaceAll("\\", "/");
|
|
3677
|
+
if (matchesGlob(slashed, glob))
|
|
3678
|
+
return true;
|
|
3679
|
+
return glob.startsWith("**/") && matchesGlob(slashed, glob.slice(3));
|
|
3680
|
+
}
|
|
3672
3681
|
function createPathExclusionMatcher(excludedPaths, platform = process.platform) {
|
|
3673
3682
|
const paths = platform === "win32" ? win322 : posix2;
|
|
3674
3683
|
const normalize = (path) => {
|
|
3675
3684
|
const absolute = paths.resolve(path);
|
|
3676
3685
|
return platform === "win32" ? absolute.toLowerCase() : absolute;
|
|
3677
3686
|
};
|
|
3678
|
-
const
|
|
3687
|
+
const globs = excludedPaths.filter(isGlobExclusion).map((glob) => platform === "win32" ? glob.toLowerCase() : glob);
|
|
3688
|
+
const excluded = excludedPaths.filter((path) => !isGlobExclusion(path)).map((path) => {
|
|
3679
3689
|
const absolute = normalize(path);
|
|
3680
3690
|
return { absolute, prefix: absolute.endsWith(paths.sep) ? absolute : `${absolute}${paths.sep}` };
|
|
3681
3691
|
});
|
|
3682
3692
|
return (path) => {
|
|
3683
3693
|
const absolute = normalize(path);
|
|
3684
|
-
return excluded.some((entry) => absolute === entry.absolute || absolute.startsWith(entry.prefix));
|
|
3694
|
+
return excluded.some((entry) => absolute === entry.absolute || absolute.startsWith(entry.prefix)) || globs.some((glob) => matchesGlobExclusion(absolute, glob));
|
|
3685
3695
|
};
|
|
3686
3696
|
}
|
|
3687
3697
|
var init_path_exclusions = () => {};
|
|
@@ -10333,7 +10343,7 @@ var init_cloud = __esm(() => {
|
|
|
10333
10343
|
// src/mirror/sync.ts
|
|
10334
10344
|
import { createHash as createHash11 } from "node:crypto";
|
|
10335
10345
|
import { opendir, readFile, stat as stat3 } from "node:fs/promises";
|
|
10336
|
-
import { basename as basename9, dirname as dirname12, extname as extname6, join as join27, resolve as resolve11
|
|
10346
|
+
import { basename as basename9, dirname as dirname12, extname as extname6, join as join27, resolve as resolve11 } from "node:path";
|
|
10337
10347
|
import { setTimeout as sleep3 } from "node:timers/promises";
|
|
10338
10348
|
function errorCode(error) {
|
|
10339
10349
|
if (!(error instanceof Error))
|
|
@@ -10880,13 +10890,14 @@ function normalizeExtension2(extension) {
|
|
|
10880
10890
|
return lower.startsWith(".") ? lower : `.${lower}`;
|
|
10881
10891
|
}
|
|
10882
10892
|
function isPathExcluded(sourcePath, excluded) {
|
|
10883
|
-
if (excluded === undefined)
|
|
10893
|
+
if (excluded === undefined || excluded.size === 0)
|
|
10884
10894
|
return false;
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10895
|
+
let matcher = matcherBySet.get(excluded);
|
|
10896
|
+
if (matcher === undefined) {
|
|
10897
|
+
matcher = createPathExclusionMatcher([...excluded]);
|
|
10898
|
+
matcherBySet.set(excluded, matcher);
|
|
10888
10899
|
}
|
|
10889
|
-
return
|
|
10900
|
+
return matcher(sourcePath);
|
|
10890
10901
|
}
|
|
10891
10902
|
function walkLimits(options) {
|
|
10892
10903
|
return {
|
|
@@ -11053,10 +11064,11 @@ async function collectFiles(state, directory, depth) {
|
|
|
11053
11064
|
warnDirectoryUnreadable(state, directory, code);
|
|
11054
11065
|
}
|
|
11055
11066
|
}
|
|
11056
|
-
var DEFAULT_MAX_SOURCE_BYTES, DEFAULT_MAX_DELETE_RATIO = 0.3, MASS_DELETE_FLOOR = 100, DEFAULT_MAX_SCANNED_ENTRIES = 2000000, DEFAULT_MAX_WALK_DEPTH = 64, DEFAULT_MIRROR_BATCH_SIZE = 25, PRODUCT_ARTIFACT_FILE_NAMES, SKIP_DIR_NAMES, PARSER_FAILURE_MESSAGE = "The registered parser failed on this file; it was skipped during indexing.", PARSER_CRASH_MESSAGE = "The registered parser crashed unexpectedly on this file; it was skipped during indexing.", DEFAULT_TRANSIENT_RETRIES = 3, DEFAULT_TRANSIENT_BACKOFF_MS = 50, TRANSIENT_ERROR_CODES, WORKSPACE_ERROR_CODES, MirrorWorkspaceError, STANDALONE_OCR_IMAGE_EXTENSIONS, SEARCH_ROOT_UNAVAILABLE_MESSAGES;
|
|
11067
|
+
var DEFAULT_MAX_SOURCE_BYTES, DEFAULT_MAX_DELETE_RATIO = 0.3, MASS_DELETE_FLOOR = 100, DEFAULT_MAX_SCANNED_ENTRIES = 2000000, DEFAULT_MAX_WALK_DEPTH = 64, DEFAULT_MIRROR_BATCH_SIZE = 25, PRODUCT_ARTIFACT_FILE_NAMES, SKIP_DIR_NAMES, PARSER_FAILURE_MESSAGE = "The registered parser failed on this file; it was skipped during indexing.", PARSER_CRASH_MESSAGE = "The registered parser crashed unexpectedly on this file; it was skipped during indexing.", DEFAULT_TRANSIENT_RETRIES = 3, DEFAULT_TRANSIENT_BACKOFF_MS = 50, TRANSIENT_ERROR_CODES, WORKSPACE_ERROR_CODES, MirrorWorkspaceError, STANDALONE_OCR_IMAGE_EXTENSIONS, matcherBySet, SEARCH_ROOT_UNAVAILABLE_MESSAGES;
|
|
11057
11068
|
var init_sync = __esm(() => {
|
|
11058
11069
|
init_cli2();
|
|
11059
11070
|
init_cloud_placeholder();
|
|
11071
|
+
init_path_exclusions();
|
|
11060
11072
|
init_source_paths();
|
|
11061
11073
|
init_binary();
|
|
11062
11074
|
init_stage();
|
|
@@ -11115,6 +11127,7 @@ var init_sync = __esm(() => {
|
|
|
11115
11127
|
}
|
|
11116
11128
|
};
|
|
11117
11129
|
STANDALONE_OCR_IMAGE_EXTENSIONS = new Set(KORDOC_IMAGE_EXTENSIONS);
|
|
11130
|
+
matcherBySet = new WeakMap;
|
|
11118
11131
|
SEARCH_ROOT_UNAVAILABLE_MESSAGES = {
|
|
11119
11132
|
gone: "A search root no longer exists; its previously indexed documents were left untouched.",
|
|
11120
11133
|
"not-a-directory": "A search root is no longer a directory; its previously indexed documents were left untouched.",
|
|
@@ -16189,7 +16202,7 @@ var init_automation_profiles = __esm(() => {
|
|
|
16189
16202
|
|
|
16190
16203
|
// src/automation/config.ts
|
|
16191
16204
|
import { existsSync as existsSync19, readFileSync as readFileSync14, realpathSync as realpathSync7 } from "node:fs";
|
|
16192
|
-
import { basename as basename10, dirname as dirname15, isAbsolute as isAbsolute8, join as join30, matchesGlob, relative as relative5, resolve as resolve12 } from "node:path";
|
|
16205
|
+
import { basename as basename10, dirname as dirname15, isAbsolute as isAbsolute8, join as join30, matchesGlob as matchesGlob2, relative as relative5, resolve as resolve12 } from "node:path";
|
|
16193
16206
|
function automationsConfigPath(env = process.env) {
|
|
16194
16207
|
return join30(resolveAutoRAGHome(env), "automations.json");
|
|
16195
16208
|
}
|
|
@@ -16365,9 +16378,9 @@ function deleteAutomation(configPath, id) {
|
|
|
16365
16378
|
function globMatches(relPosix, pattern) {
|
|
16366
16379
|
if (pattern === "**")
|
|
16367
16380
|
return true;
|
|
16368
|
-
if (
|
|
16381
|
+
if (matchesGlob2(relPosix, pattern))
|
|
16369
16382
|
return true;
|
|
16370
|
-
if (pattern.startsWith("**/") &&
|
|
16383
|
+
if (pattern.startsWith("**/") && matchesGlob2(relPosix, pattern.slice(3)))
|
|
16371
16384
|
return true;
|
|
16372
16385
|
return false;
|
|
16373
16386
|
}
|
|
@@ -17164,7 +17177,7 @@ var init_permission_judgment = __esm(() => {
|
|
|
17164
17177
|
|
|
17165
17178
|
// src/agent/permission-gate.ts
|
|
17166
17179
|
import { statSync as statSync7 } from "node:fs";
|
|
17167
|
-
import { isAbsolute as isAbsolute9, relative as relative6, sep as
|
|
17180
|
+
import { isAbsolute as isAbsolute9, relative as relative6, sep as sep6 } from "node:path";
|
|
17168
17181
|
import { matchesKey } from "@earendil-works/pi-tui";
|
|
17169
17182
|
function pathExists(path) {
|
|
17170
17183
|
try {
|
|
@@ -17227,7 +17240,7 @@ class PermissionController {
|
|
|
17227
17240
|
if (path === root)
|
|
17228
17241
|
return true;
|
|
17229
17242
|
const rel = relative6(root, path);
|
|
17230
|
-
if (rel !== "" && rel !== ".." && !rel.startsWith(`..${
|
|
17243
|
+
if (rel !== "" && rel !== ".." && !rel.startsWith(`..${sep6}`) && !isAbsolute9(rel))
|
|
17231
17244
|
return true;
|
|
17232
17245
|
}
|
|
17233
17246
|
return false;
|
|
@@ -18679,7 +18692,7 @@ var init_connector = () => {};
|
|
|
18679
18692
|
// src/datasource/sidecar/config.ts
|
|
18680
18693
|
import { readFileSync as readFileSync17 } from "node:fs";
|
|
18681
18694
|
import { homedir as homedir5 } from "node:os";
|
|
18682
|
-
import { dirname as dirname17, isAbsolute as isAbsolute10, join as join34, resolve as resolve14, sep as
|
|
18695
|
+
import { dirname as dirname17, isAbsolute as isAbsolute10, join as join34, resolve as resolve14, sep as sep7 } from "node:path";
|
|
18683
18696
|
import { parse as parseToml } from "smol-toml";
|
|
18684
18697
|
function resolveSidecarOptions(input) {
|
|
18685
18698
|
const { connector, workspaceRoot } = input;
|
|
@@ -18719,7 +18732,7 @@ function archivePathFromCrawlerConfig(input) {
|
|
|
18719
18732
|
function expandHome(path) {
|
|
18720
18733
|
if (path === "~")
|
|
18721
18734
|
return homedir5();
|
|
18722
|
-
const prefixed = path.startsWith("~/") ||
|
|
18735
|
+
const prefixed = path.startsWith("~/") || sep7 === "\\" && path.startsWith("~\\");
|
|
18723
18736
|
return prefixed ? join34(homedir5(), path.slice(2)) : path;
|
|
18724
18737
|
}
|
|
18725
18738
|
var init_config3 = __esm(() => {
|
|
@@ -25973,7 +25986,7 @@ import {
|
|
|
25973
25986
|
writeFileSync as writeFileSync13
|
|
25974
25987
|
} from "node:fs";
|
|
25975
25988
|
import { opendir as opendir2, stat as stat4 } from "node:fs/promises";
|
|
25976
|
-
import { basename as basename11, dirname as dirname23, extname as extname8, join as join40, relative as relative7, sep as
|
|
25989
|
+
import { basename as basename11, dirname as dirname23, extname as extname8, join as join40, relative as relative7, sep as sep8 } from "node:path";
|
|
25977
25990
|
function errnoCode2(error) {
|
|
25978
25991
|
const code = error instanceof Error ? error.code : undefined;
|
|
25979
25992
|
return typeof code === "string" ? code : "UNKNOWN";
|
|
@@ -26043,7 +26056,7 @@ async function listVaultNotes(vaultPath) {
|
|
|
26043
26056
|
return { notes, unreadableFolders, collisions };
|
|
26044
26057
|
}
|
|
26045
26058
|
function toRelative(vaultPath, path) {
|
|
26046
|
-
return relative7(vaultPath, path).split(
|
|
26059
|
+
return relative7(vaultPath, path).split(sep8).join("/").normalize("NFC");
|
|
26047
26060
|
}
|
|
26048
26061
|
function loadStagingState2(statePath) {
|
|
26049
26062
|
try {
|
|
@@ -26127,7 +26140,7 @@ function removeUnexpected(filesRoot, directory, wanted) {
|
|
|
26127
26140
|
return removed;
|
|
26128
26141
|
}
|
|
26129
26142
|
function toStagedRelative(filesRoot, path) {
|
|
26130
|
-
return relative7(filesRoot, path).split(
|
|
26143
|
+
return relative7(filesRoot, path).split(sep8).join("/").normalize("NFC");
|
|
26131
26144
|
}
|
|
26132
26145
|
var NOTE_EXTENSIONS, SKIPPED_DIRECTORIES, MAX_WALK_DEPTH = 64, VaultUnavailableError;
|
|
26133
26146
|
var init_staging = __esm(() => {
|
|
@@ -28048,7 +28061,7 @@ function resolveExcludePaths(value, origin) {
|
|
|
28048
28061
|
if (!Array.isArray(value) || value.some((path) => typeof path !== "string" || path.length === 0)) {
|
|
28049
28062
|
throw new ConfigError("Config field 'excludePaths' must be a non-empty string array");
|
|
28050
28063
|
}
|
|
28051
|
-
return
|
|
28064
|
+
return value.map((entry) => isGlobExclusion(entry) ? entry : resolvePersistedPath(entry, origin));
|
|
28052
28065
|
}
|
|
28053
28066
|
function resolvePersistedPath(path, origin) {
|
|
28054
28067
|
return isAbsolute11(path) ? path : resolve15(origin, path);
|
|
@@ -29353,6 +29366,7 @@ var init_config5 = __esm(() => {
|
|
|
29353
29366
|
init_factory();
|
|
29354
29367
|
init_embedding();
|
|
29355
29368
|
init_file_lock();
|
|
29369
|
+
init_path_exclusions();
|
|
29356
29370
|
init_language();
|
|
29357
29371
|
init_atomic_write();
|
|
29358
29372
|
init_rerank();
|
|
@@ -38606,7 +38620,7 @@ var init_web_search_tool = __esm(() => {
|
|
|
38606
38620
|
// src/agent/agent.ts
|
|
38607
38621
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
38608
38622
|
import { existsSync as existsSync34, watch as fsWatch, mkdirSync as mkdirSync24, realpathSync as realpathSync8, statSync as statSync11, writeFileSync as writeFileSync17 } from "node:fs";
|
|
38609
|
-
import { basename as basename15, dirname as dirname27, join as join55, relative as relative8, resolve as resolve18, sep as
|
|
38623
|
+
import { basename as basename15, dirname as dirname27, join as join55, relative as relative8, resolve as resolve18, sep as sep9 } from "node:path";
|
|
38610
38624
|
import { clampThinkingLevel } from "@earendil-works/pi-ai/compat";
|
|
38611
38625
|
import { getAgentDir as getAgentDir6, keyText } from "@earendil-works/pi-coding-agent";
|
|
38612
38626
|
function describeDecisionModel(status) {
|
|
@@ -41279,7 +41293,7 @@ ${this.discoveryHint((tools) => `When exploring local files and folders, activel
|
|
|
41279
41293
|
return { ok: false, reason: "cloud-root-skipped", stdout: "", stderr: "", code: null };
|
|
41280
41294
|
}
|
|
41281
41295
|
const canonicalSourcePath = canonicalPath(sourcePath);
|
|
41282
|
-
const exclude = scope.nestedCloudRoots.map((root) => relative8(canonicalSourcePath, root.path).split(
|
|
41296
|
+
const exclude = scope.nestedCloudRoots.map((root) => relative8(canonicalSourcePath, root.path).split(sep9).join("/")).filter((pattern) => pattern !== "" && !pattern.startsWith(".."));
|
|
41283
41297
|
return client.prepare(sourcePath, { ...options, ...exclude.length === 0 ? {} : { exclude } });
|
|
41284
41298
|
}));
|
|
41285
41299
|
}
|
|
@@ -41793,6 +41807,8 @@ function toMinSyncReasonDiagnostic(reason) {
|
|
|
41793
41807
|
};
|
|
41794
41808
|
}
|
|
41795
41809
|
function pinExcludedPath(path) {
|
|
41810
|
+
if (isGlobExclusion(path))
|
|
41811
|
+
return path;
|
|
41796
41812
|
const resolvedPath = resolve18(path);
|
|
41797
41813
|
try {
|
|
41798
41814
|
return join55(realpathSync8(dirname27(resolvedPath)), basename15(resolvedPath));
|
|
@@ -41841,6 +41857,7 @@ var init_agent = __esm(() => {
|
|
|
41841
41857
|
init_embedding();
|
|
41842
41858
|
init_everything();
|
|
41843
41859
|
init_cloud_placeholder();
|
|
41860
|
+
init_path_exclusions();
|
|
41844
41861
|
init_fsearch();
|
|
41845
41862
|
init_diagnostics();
|
|
41846
41863
|
init_jikji();
|
|
@@ -42058,6 +42075,12 @@ class AutoRAGLite {
|
|
|
42058
42075
|
getMemorySchema() {
|
|
42059
42076
|
return structuredClone(this.memory.getSchema());
|
|
42060
42077
|
}
|
|
42078
|
+
convertFiles(request, signal) {
|
|
42079
|
+
return this.agent.convertFiles(request, signal);
|
|
42080
|
+
}
|
|
42081
|
+
listFileConversions(from, signal) {
|
|
42082
|
+
return this.agent.listFileConversions(from, signal);
|
|
42083
|
+
}
|
|
42061
42084
|
}
|
|
42062
42085
|
function createAutoRAGLite(options = {}) {
|
|
42063
42086
|
const input = { flags: options.flags ?? {} };
|
|
@@ -42927,7 +42950,7 @@ import { z as z4 } from "zod";
|
|
|
42927
42950
|
// src/filesystem/name-search.ts
|
|
42928
42951
|
import { realpathSync as realpathSync9 } from "node:fs";
|
|
42929
42952
|
import { lstat as lstat2, readdir as readdir5 } from "node:fs/promises";
|
|
42930
|
-
import { basename as basename16, dirname as dirname28, isAbsolute as isAbsolute14, join as join56, relative as relative9, resolve as resolve19, sep as
|
|
42953
|
+
import { basename as basename16, dirname as dirname28, isAbsolute as isAbsolute14, join as join56, relative as relative9, resolve as resolve19, sep as sep10 } from "node:path";
|
|
42931
42954
|
var SKIP_DIR_NAMES2 = {
|
|
42932
42955
|
".git": true,
|
|
42933
42956
|
".autorag": true,
|
|
@@ -42955,7 +42978,7 @@ function fsErrorCode(error) {
|
|
|
42955
42978
|
return typeof code === "string" ? code : undefined;
|
|
42956
42979
|
}
|
|
42957
42980
|
function isContained(childReal, parentReal) {
|
|
42958
|
-
const prefix = parentReal.endsWith(
|
|
42981
|
+
const prefix = parentReal.endsWith(sep10) ? parentReal : `${parentReal}${sep10}`;
|
|
42959
42982
|
return childReal === parentReal || childReal.startsWith(prefix);
|
|
42960
42983
|
}
|
|
42961
42984
|
function pinExcludedPath2(path) {
|
|
@@ -42968,14 +42991,14 @@ function pinExcludedPath2(path) {
|
|
|
42968
42991
|
}
|
|
42969
42992
|
function isExcluded2(absPath, excluded) {
|
|
42970
42993
|
for (const excludedPath of excluded) {
|
|
42971
|
-
const prefix = excludedPath.endsWith(
|
|
42994
|
+
const prefix = excludedPath.endsWith(sep10) ? excludedPath : `${excludedPath}${sep10}`;
|
|
42972
42995
|
if (absPath === excludedPath || absPath.startsWith(prefix))
|
|
42973
42996
|
return true;
|
|
42974
42997
|
}
|
|
42975
42998
|
return false;
|
|
42976
42999
|
}
|
|
42977
43000
|
function matchesEntry(context, absPath, name) {
|
|
42978
|
-
const haystackRaw = context.matchPath ? relative9(context.rootReal, absPath).split(
|
|
43001
|
+
const haystackRaw = context.matchPath ? relative9(context.rootReal, absPath).split(sep10).join("/") : name;
|
|
42979
43002
|
const haystack = context.matchCase ? haystackRaw : haystackRaw.toLowerCase();
|
|
42980
43003
|
const needle = context.matchCase ? context.query : context.query.toLowerCase();
|
|
42981
43004
|
return haystack.includes(needle);
|
|
@@ -43116,7 +43139,7 @@ async function filterFileNameSearchMatches(roots, candidates, excludePaths = [])
|
|
|
43116
43139
|
continue;
|
|
43117
43140
|
if (isExcluded2(real, excluded))
|
|
43118
43141
|
continue;
|
|
43119
|
-
const segments = real.split(
|
|
43142
|
+
const segments = real.split(sep10);
|
|
43120
43143
|
if (segments.some((segment) => SKIP_DIR_NAMES2[segment] === true))
|
|
43121
43144
|
continue;
|
|
43122
43145
|
matches.push({ path: real, type: stat.isDirectory() ? "folder" : "file" });
|
|
@@ -43240,6 +43263,16 @@ var evidenceInput = z4.strictObject({
|
|
|
43240
43263
|
sessionId: z4.string().trim().min(1),
|
|
43241
43264
|
resultNumber: z4.number().int().positive().optional()
|
|
43242
43265
|
});
|
|
43266
|
+
var convertInput = z4.strictObject({
|
|
43267
|
+
inputs: z4.array(z4.string().trim().min(1)).min(1).max(500),
|
|
43268
|
+
to: z4.string().trim().min(1),
|
|
43269
|
+
outputDir: z4.string().trim().min(1).optional(),
|
|
43270
|
+
recursive: z4.boolean().optional(),
|
|
43271
|
+
quality: z4.number().int().min(1).max(100).optional(),
|
|
43272
|
+
keepDates: z4.boolean().optional()
|
|
43273
|
+
});
|
|
43274
|
+
var convertFormatsInput = z4.strictObject({ from: z4.string().trim().min(1).optional() });
|
|
43275
|
+
var MAX_CONVERT_FILES = 200;
|
|
43243
43276
|
function exactGroupsFromScan(scan) {
|
|
43244
43277
|
const groups = new Map;
|
|
43245
43278
|
for (const file of scan.files) {
|
|
@@ -43261,6 +43294,57 @@ function jsonResult(value, isError = false) {
|
|
|
43261
43294
|
function toolError(code, message, extra = {}) {
|
|
43262
43295
|
return jsonResult({ ok: false, errorCode: code, message, ...extra }, true);
|
|
43263
43296
|
}
|
|
43297
|
+
var DIAGNOSTIC_EXAMPLES_PER_CODE = 3;
|
|
43298
|
+
function capDiagnostics(diagnostics) {
|
|
43299
|
+
const byCode = new Map;
|
|
43300
|
+
for (const entry of diagnostics) {
|
|
43301
|
+
const list = byCode.get(entry.code);
|
|
43302
|
+
if (list === undefined)
|
|
43303
|
+
byCode.set(entry.code, [entry]);
|
|
43304
|
+
else
|
|
43305
|
+
list.push(entry);
|
|
43306
|
+
}
|
|
43307
|
+
const out = [];
|
|
43308
|
+
for (const [code, entries] of byCode) {
|
|
43309
|
+
out.push(...entries.slice(0, DIAGNOSTIC_EXAMPLES_PER_CODE));
|
|
43310
|
+
const rest = entries.slice(DIAGNOSTIC_EXAMPLES_PER_CODE);
|
|
43311
|
+
if (rest.length === 0)
|
|
43312
|
+
continue;
|
|
43313
|
+
const reasons = new Map;
|
|
43314
|
+
for (const entry of rest) {
|
|
43315
|
+
const key = entry.reason ?? "unspecified";
|
|
43316
|
+
reasons.set(key, (reasons.get(key) ?? 0) + 1);
|
|
43317
|
+
}
|
|
43318
|
+
const split = [...reasons].map(([reason, count]) => `${reason}: ${count}`).join(", ");
|
|
43319
|
+
const severity = entries.some((entry) => entry.severity === "error") ? "error" : entries.some((entry) => entry.severity === "warning") ? "warning" : "info";
|
|
43320
|
+
out.push({
|
|
43321
|
+
code,
|
|
43322
|
+
severity,
|
|
43323
|
+
message: `${rest.length} more ${code} entries omitted (${split}); the first ${DIAGNOSTIC_EXAMPLES_PER_CODE} are shown above.`
|
|
43324
|
+
});
|
|
43325
|
+
}
|
|
43326
|
+
return out;
|
|
43327
|
+
}
|
|
43328
|
+
function convertResult(details) {
|
|
43329
|
+
const { result, links } = details;
|
|
43330
|
+
const files = result.files.slice(0, MAX_CONVERT_FILES).map((file) => ({
|
|
43331
|
+
source: file.source,
|
|
43332
|
+
state: file.state,
|
|
43333
|
+
outputs: file.outputs,
|
|
43334
|
+
...file.error !== undefined ? { error: file.error } : {},
|
|
43335
|
+
...file.notice !== undefined ? { notice: file.notice } : {}
|
|
43336
|
+
}));
|
|
43337
|
+
const body = {
|
|
43338
|
+
target: result.target,
|
|
43339
|
+
converted: result.converted,
|
|
43340
|
+
skipped: result.skipped,
|
|
43341
|
+
failed: result.failed,
|
|
43342
|
+
files,
|
|
43343
|
+
...result.files.length > files.length ? { omittedFiles: result.files.length - files.length } : {},
|
|
43344
|
+
links
|
|
43345
|
+
};
|
|
43346
|
+
return result.converted === 0 && result.failed > 0 ? toolError("convert-failed", "No file was converted.", body) : jsonResult({ ok: true, ...body });
|
|
43347
|
+
}
|
|
43264
43348
|
function isToolEnabled(name, options) {
|
|
43265
43349
|
return options.tools === undefined || options.tools.includes(name);
|
|
43266
43350
|
}
|
|
@@ -43386,7 +43470,10 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43386
43470
|
inputSchema: emptyInput,
|
|
43387
43471
|
outputSchema: objectOutput,
|
|
43388
43472
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
43389
|
-
}, async () =>
|
|
43473
|
+
}, async () => {
|
|
43474
|
+
const status = await lite.getRefreshStatus();
|
|
43475
|
+
return jsonResult({ ...status, diagnostics: capDiagnostics(status.diagnostics) });
|
|
43476
|
+
});
|
|
43390
43477
|
}
|
|
43391
43478
|
if (isToolEnabled("autorag.search", options)) {
|
|
43392
43479
|
server.registerTool("autorag.search", {
|
|
@@ -43425,7 +43512,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43425
43512
|
content: result.content
|
|
43426
43513
|
})),
|
|
43427
43514
|
unsearched: retrieved.unsearched,
|
|
43428
|
-
diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
|
|
43515
|
+
diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
|
|
43429
43516
|
});
|
|
43430
43517
|
} catch (error) {
|
|
43431
43518
|
return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { retryable: !(error instanceof RetrievalSelectionError) });
|
|
@@ -43480,7 +43567,7 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43480
43567
|
content: result.content
|
|
43481
43568
|
})),
|
|
43482
43569
|
unsearched: retrieved.unsearched,
|
|
43483
|
-
diagnostics: [...status.diagnostics, ...retrieved.diagnostics]
|
|
43570
|
+
diagnostics: capDiagnostics([...status.diagnostics, ...retrieved.diagnostics])
|
|
43484
43571
|
});
|
|
43485
43572
|
} catch (error) {
|
|
43486
43573
|
return toolError(error instanceof RetrievalSelectionError ? "invalid-selection" : "search-failed", error instanceof Error ? error.message : String(error), { datasourceId: entry.datasourceId, retryable: !(error instanceof RetrievalSelectionError) });
|
|
@@ -43555,6 +43642,46 @@ function createAutoRAGMcpServer(lite, options = {}) {
|
|
|
43555
43642
|
return datasource === undefined ? toolError("datasource-not-found", `No configured datasource named ${datasourceId}.`, { datasourceId }) : jsonResult({ ok: true, datasource });
|
|
43556
43643
|
});
|
|
43557
43644
|
}
|
|
43645
|
+
const convertEnabled = lite.config.filee?.enabled !== false;
|
|
43646
|
+
if (convertEnabled && !readOnly && isToolEnabled("autorag.convert", options)) {
|
|
43647
|
+
server.registerTool("autorag.convert", {
|
|
43648
|
+
title: "Convert Files",
|
|
43649
|
+
description: "Convert local files to another format offline with Filee: documents, spreadsheets, slides, HWP/HWPX, images, e-books, archives, audio, video, data. Writes new files next to each source (or into outputDir) and never replaces an existing file: a colliding name gets a number added. Each output is compared with its source by Dupey, so the result says whether the copy would count as a duplicate. Use autorag.convert.formats when unsure what a source can become.",
|
|
43650
|
+
inputSchema: convertInput,
|
|
43651
|
+
outputSchema: objectOutput,
|
|
43652
|
+
annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: false, openWorldHint: false }
|
|
43653
|
+
}, async ({ inputs, to, outputDir, recursive, quality, keepDates }, ctx) => {
|
|
43654
|
+
try {
|
|
43655
|
+
const details = await lite.convertFiles({
|
|
43656
|
+
inputs,
|
|
43657
|
+
to,
|
|
43658
|
+
...outputDir !== undefined ? { outputDir } : {},
|
|
43659
|
+
...recursive !== undefined ? { recursive } : {},
|
|
43660
|
+
...quality !== undefined ? { quality } : {},
|
|
43661
|
+
...keepDates !== undefined ? { keepDates } : {}
|
|
43662
|
+
}, ctx.mcpReq.signal);
|
|
43663
|
+
return convertResult(details);
|
|
43664
|
+
} catch (error) {
|
|
43665
|
+
return toolError("convert-failed", error instanceof Error ? error.message : String(error));
|
|
43666
|
+
}
|
|
43667
|
+
});
|
|
43668
|
+
}
|
|
43669
|
+
if (convertEnabled && isToolEnabled("autorag.convert.formats", options)) {
|
|
43670
|
+
server.registerTool("autorag.convert.formats", {
|
|
43671
|
+
title: "List Convertible Formats",
|
|
43672
|
+
description: "List the file formats Filee knows, or what one source format (heic, docx, hwp, mkv) can be converted to, including targets that need an optional engine. Read-only.",
|
|
43673
|
+
inputSchema: convertFormatsInput,
|
|
43674
|
+
outputSchema: objectOutput,
|
|
43675
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
43676
|
+
}, async ({ from }, ctx) => {
|
|
43677
|
+
try {
|
|
43678
|
+
const formats = await lite.listFileConversions(from, ctx.mcpReq.signal);
|
|
43679
|
+
return jsonResult({ ok: true, ...from !== undefined ? { from } : {}, formats });
|
|
43680
|
+
} catch (error) {
|
|
43681
|
+
return toolError("convert-failed", error instanceof Error ? error.message : String(error));
|
|
43682
|
+
}
|
|
43683
|
+
});
|
|
43684
|
+
}
|
|
43558
43685
|
if (!readOnly && isToolEnabled("autorag.report", options)) {
|
|
43559
43686
|
server.registerTool("autorag.report", {
|
|
43560
43687
|
title: "Persist AutoRAG Curated Report",
|