@autorag/librarian 2.10.1 → 2.10.3

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.
Files changed (73) hide show
  1. package/NOTICE +0 -3
  2. package/README.md +76 -33
  3. package/dist/agent/agent.d.ts +96 -18
  4. package/dist/agent/evidence-ledger.d.ts +54 -5
  5. package/dist/agent/evidence-persistence.d.ts +24 -0
  6. package/dist/agent/jev-extension.d.ts +5 -3
  7. package/dist/agent/search-documents.d.ts +1 -1
  8. package/dist/agent/system-prompt.d.ts +0 -2
  9. package/dist/agent/tool-burst-guard.d.ts +26 -0
  10. package/dist/cli/config.d.ts +37 -23
  11. package/dist/cli/index.js +2122 -1153
  12. package/dist/cloud/config.d.ts +16 -10
  13. package/dist/cloud/credential.d.ts +17 -0
  14. package/dist/cloud/errors.d.ts +6 -6
  15. package/dist/cloud/index.d.ts +5 -4
  16. package/dist/cloud/jev-backend.d.ts +15 -13
  17. package/dist/cloud/models.d.ts +4 -4
  18. package/dist/cloud/oauth-login.d.ts +3 -3
  19. package/dist/cloud/provider.d.ts +16 -11
  20. package/dist/cloud/token.d.ts +2 -2
  21. package/dist/core.d.ts +2 -1
  22. package/dist/core.js +2265 -1313
  23. package/dist/datasource/aliased-skill.d.ts +2 -2
  24. package/dist/datasource/connector-skill.d.ts +2 -2
  25. package/dist/datasource/crawler-skill.d.ts +2 -2
  26. package/dist/datasource/described-skill.d.ts +2 -2
  27. package/dist/datasource/index.d.ts +1 -1
  28. package/dist/datasource/retry.d.ts +49 -0
  29. package/dist/datasource/skills/clawgallery/skill.d.ts +4 -4
  30. package/dist/datasource/skills/discrawl/skill.d.ts +5 -5
  31. package/dist/datasource/skills/github-gist/skill.d.ts +2 -2
  32. package/dist/datasource/skills/lazykatok/skill.d.ts +5 -5
  33. package/dist/datasource/skills/mailcrawl/skill.d.ts +2 -2
  34. package/dist/datasource/skills/obsidian/skill.d.ts +5 -5
  35. package/dist/datasource/types.d.ts +13 -1
  36. package/dist/embedding-runtime/cache.d.ts +9 -0
  37. package/dist/index.d.ts +1 -2
  38. package/dist/index.js +2338 -1387
  39. package/dist/jikji/client.d.ts +13 -2
  40. package/dist/jikji/index.d.ts +1 -1
  41. package/dist/jikji/path-map.d.ts +9 -0
  42. package/dist/jikji/prepare-budget.d.ts +18 -0
  43. package/dist/jikji/serial-queue.d.ts +17 -0
  44. package/dist/jikji/types.d.ts +17 -0
  45. package/dist/mcp/index.js +2326 -1374
  46. package/dist/minsync/client.d.ts +3 -1
  47. package/dist/minsync/index.d.ts +1 -1
  48. package/dist/minsync/installer.d.ts +1 -1
  49. package/dist/minsync/method.d.ts +1 -1
  50. package/dist/minsync/types.d.ts +8 -1
  51. package/dist/mirror/atomic-write.d.ts +6 -0
  52. package/dist/mirror/index-store.d.ts +8 -1
  53. package/dist/mirror/index.d.ts +2 -2
  54. package/dist/mirror/sync.d.ts +57 -1
  55. package/dist/p2p/simplex-server.d.ts +0 -1
  56. package/dist/parser/defaults.d.ts +8 -0
  57. package/dist/parser/errors.d.ts +10 -0
  58. package/dist/parser/isolated.d.ts +77 -0
  59. package/dist/parser/kordoc.d.ts +1 -0
  60. package/dist/parser/parse-worker.d.ts +1 -0
  61. package/dist/parser/parse-worker.js +780 -0
  62. package/dist/parser/types.d.ts +5 -0
  63. package/dist/process/abort-reason.d.ts +2 -0
  64. package/dist/retrieval/index.d.ts +1 -1
  65. package/dist/retrieval/rerank.d.ts +16 -10
  66. package/package.json +5 -5
  67. package/skills/autorag/SKILL.md +2 -1
  68. package/skills/autorag-doctor/SKILL.md +7 -0
  69. package/skills/autorag-lite-setup/SKILL.md +2 -2
  70. package/skills/autorag-setup/SKILL.md +42 -17
  71. package/dist/manifest/index.d.ts +0 -2
  72. package/dist/manifest/loader.d.ts +0 -3
  73. package/dist/manifest/types.d.ts +0 -8
@@ -37,7 +37,9 @@ export declare class MinSyncClient {
37
37
  private readIdentity;
38
38
  private writeIdentity;
39
39
  private identityMismatch;
40
- sync(force?: boolean): Promise<MinSyncSyncResult>;
40
+ sync(force?: boolean, signal?: AbortSignal): Promise<MinSyncSyncResult>;
41
+ private lockHeldResult;
42
+ private checkAndSync;
41
43
  query(text: string, topK: number, mode?: MinSyncQueryMode, signal?: AbortSignal): Promise<readonly MinSyncQueryHit[]>;
42
44
  private spawn;
43
45
  }
@@ -5,5 +5,5 @@ export { type EnsureMinSyncBinaryOptions, ensureMinSyncBinary, executableName, f
5
5
  export { ensureLocalEmbedder, LocalEmbedderError, type LocalEmbedderPreflightOptions, } from "./local-embedder.js";
6
6
  export { MinSyncHybridMethod, type MinSyncHybridMethodOptions, MinSyncVectorMethod, type MinSyncVectorMethodOptions, } from "./method.js";
7
7
  export { MINSYNC_FILES_SUBDIR, MINSYNC_SUBDIR, minSyncDocumentPath, minSyncWorkspaceRoot } from "./paths.js";
8
- export type { MinSyncChunkerConfig, MinSyncDiagnostic, MinSyncEmbedderConfig, MinSyncOptions, MinSyncQueryHit, MinSyncSyncResult, } from "./types.js";
8
+ export type { MinSyncChunkerConfig, MinSyncDiagnostic, MinSyncEmbedderConfig, MinSyncFileFailure, MinSyncOptions, MinSyncQueryHit, MinSyncSyncResult, } from "./types.js";
9
9
  export { buildMinSyncPathMap, type MinSyncWorkspaceEntry, type MinSyncWorkspaceSyncResult, syncMinSyncWorkspace, } from "./workspace.js";
@@ -1,4 +1,4 @@
1
- export declare const MINSYNC_VERSION = "0.4.7";
1
+ export declare const MINSYNC_VERSION = "0.4.8";
2
2
  export declare const MINSYNC_CARGO_INSTALL_TIMEOUT_MS: number;
3
3
  export interface MinSyncReleaseAsset {
4
4
  readonly name: string;
@@ -34,7 +34,7 @@ export declare class MinSyncVectorMethod implements RetrievalMethod {
34
34
  private readonly scopedTopK;
35
35
  constructor(options: MinSyncVectorMethodOptions);
36
36
  describe(): RetrievalMethodDescriptor;
37
- sync(force?: boolean): Promise<MinSyncSyncResult>;
37
+ sync(force?: boolean, signal?: AbortSignal): Promise<MinSyncSyncResult>;
38
38
  private syncUnlocked;
39
39
  /** Report unavailable binaries without treating auto-install as already failed. */
40
40
  isBinaryMissing(): boolean;
@@ -39,8 +39,15 @@ export interface MinSyncSyncResult {
39
39
  * unindexable document is never dropped silently.
40
40
  */
41
41
  readonly stagingExcluded?: readonly string[];
42
+ /** Files MinSync skipped (exit 6, `partial`); the sync itself completed and the next sync retries them. */
43
+ readonly filesFailed?: readonly MinSyncFileFailure[];
42
44
  }
43
- export type MinSyncDiagnosticCode = "embedder-unavailable" | "sync-failed" | "no-hit" | "embedding-identity-mismatch" | "migration-required";
45
+ export interface MinSyncFileFailure {
46
+ readonly path: string;
47
+ readonly stage: string;
48
+ readonly error: string;
49
+ }
50
+ export type MinSyncDiagnosticCode = "embedder-unavailable" | "sync-failed" | "minsync-lock-held" | "no-hit" | "embedding-identity-mismatch" | "migration-required";
44
51
  export interface MinSyncDiagnostic {
45
52
  readonly code: MinSyncDiagnosticCode;
46
53
  readonly message: string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Write `content` to `path` through a sibling temp file and an atomic rename.
3
+ * On any failure the temp file is removed before the error is rethrown, so a full
4
+ * disk or an I/O error never leaves `*.tmp` orphans in the mirror.
5
+ */
6
+ export declare function writeFileAtomic(path: string, content: string): void;
@@ -8,11 +8,14 @@ export interface ParsedMirrorEntry {
8
8
  readonly updatedAt: string;
9
9
  }
10
10
  /** Why refresh deliberately left a source out of the parsed mirror. */
11
- export type ParsedMirrorSkipReason = "duplicate-excluded" | "user-excluded" | "parser-skipped" | "parser-failed";
11
+ export type ParsedMirrorSkipReason = "duplicate-excluded" | "user-excluded" | "parser-skipped" | "parser-failed" | "source-unreadable";
12
12
  /**
13
13
  * A source the last refresh decided not to mirror, pinned to the exact version it
14
14
  * decided on. Staleness checks compare against this record instead of re-deriving
15
15
  * the decision, so a deliberately skipped file is not reported as a new source.
16
+ *
17
+ * Retryable skips (`parser-failed`, `source-unreadable`) also carry the parser stamp, so refresh
18
+ * can honor the record without reading or parsing the file again.
16
19
  */
17
20
  export interface ParsedMirrorSkipEntry {
18
21
  readonly virtualPath: string;
@@ -21,6 +24,10 @@ export interface ParsedMirrorSkipEntry {
21
24
  readonly sourceMtimeNs: number;
22
25
  readonly sourceSizeBytes: number;
23
26
  readonly updatedAt: string;
27
+ /** `Parser.name` the skip was decided with. */
28
+ readonly parserName?: string;
29
+ /** `Parser.version` the skip was decided with. Absent on records written before version stamps. */
30
+ readonly parserVersion?: string;
24
31
  }
25
32
  export interface ParsedMirrorIndex {
26
33
  readonly version: 1;
@@ -1,5 +1,5 @@
1
1
  export type { ParsedMirrorEntry, ParsedMirrorIndex } from "./index-store.js";
2
2
  export { emptyMirrorIndex, loadMirrorIndex, saveMirrorIndex } from "./index-store.js";
3
3
  export { isParsedRefreshComplete, parsedMirrorIndexPath, parsedMirrorRoot, parsedOutputPath, refreshReadinessPath, } from "./paths.js";
4
- export type { ParsedMirrorDiagnostic, ParsedMirrorDiagnosticCode, ParsedMirrorSyncOptions, ParsedMirrorSyncResult, } from "./sync.js";
5
- export { DEFAULT_MAX_SOURCE_BYTES, detectMirrorStaleness, isPathExcluded, syncParsedMirrors } from "./sync.js";
4
+ export type { ParsedMirrorDiagnostic, ParsedMirrorDiagnosticCode, ParsedMirrorProgress, ParsedMirrorSyncOptions, ParsedMirrorSyncResult, } from "./sync.js";
5
+ export { DEFAULT_MAX_SOURCE_BYTES, DEFAULT_TRANSIENT_RETRIES, detectMirrorStaleness, isPathExcluded, MirrorWorkspaceError, syncParsedMirrors, } from "./sync.js";
@@ -2,6 +2,12 @@ import { type DefaultParserRegistryOptions } from "../parser/defaults.js";
2
2
  import type { ParserRegistry } from "../parser/registry.js";
3
3
  /** Refuse to fully load/parse sources larger than this. Keeps Node heap stable on home folders. */
4
4
  export declare const DEFAULT_MAX_SOURCE_BYTES: number;
5
+ /** A refresh may delete at most this share of the indexed documents (above {@link MASS_DELETE_FLOOR}). */
6
+ export declare const DEFAULT_MAX_DELETE_RATIO = 0.3;
7
+ /** Directory entries examined per search root before the walk stops. */
8
+ export declare const DEFAULT_MAX_SCANNED_ENTRIES = 2000000;
9
+ /** Deepest directory level (search root = 0) the walk descends into. */
10
+ export declare const DEFAULT_MAX_WALK_DEPTH = 64;
5
11
  export interface ParsedMirrorSyncOptions {
6
12
  readonly root: string;
7
13
  readonly searchPaths: readonly string[];
@@ -14,8 +20,48 @@ export interface ParsedMirrorSyncOptions {
14
20
  readonly excludeSourcePaths?: ReadonlySet<string>;
15
21
  /** Absolute source paths or directories omitted by the user. */
16
22
  readonly userExcludedSourcePaths?: ReadonlySet<string>;
23
+ /**
24
+ * Retry sources that previously failed to parse or read once, ignoring their skip records.
25
+ * Healthy, unchanged mirrors are still left alone (unlike `force`).
26
+ */
27
+ readonly retrySkipped?: boolean;
28
+ /**
29
+ * Stops the sync between files and kills an in-flight parse worker. The sync rejects with the signal's
30
+ * reason after checkpointing the mirror, so finished files are not re-parsed next time.
31
+ */
32
+ readonly signal?: AbortSignal;
33
+ /** Called before each file and once more with `processed === total` when the parse phase ends. */
34
+ readonly onProgress?: (progress: ParsedMirrorProgress) => void;
35
+ /**
36
+ * Largest share of previously indexed documents one refresh may delete because their source
37
+ * disappeared. A larger deletion (above 100 documents) is suppressed with `mass-delete-suppressed`
38
+ * unless `force` is set. Default {@link DEFAULT_MAX_DELETE_RATIO}.
39
+ */
40
+ readonly maxDeleteRatio?: number;
41
+ /** Directory entries examined per search root before the walk stops with `walk-truncated`. */
42
+ readonly maxScannedEntries?: number;
43
+ /** Deepest directory level the walk descends into (search root = 0), else `walk-truncated`. */
44
+ readonly maxDepth?: number;
45
+ /**
46
+ * Retries for a transient I/O error (`EMFILE`, `EBUSY`, `EIO`, `ETIMEDOUT`) on one
47
+ * file's read or mirror write before the file is recorded as skipped. Default 3.
48
+ */
49
+ readonly transientRetries?: number;
50
+ /** Base delay between transient retries; doubles per retry. Default 50ms. */
51
+ readonly transientRetryBackoffMs?: number;
17
52
  }
18
- export type ParsedMirrorDiagnosticCode = "unsupported-file" | "parser-skipped" | "parser-failed" | "source-vanished" | "source-unreadable" | "duplicate-excluded" | "deleted-mirror" | "stale-index" | "pdf-extract-thin" | "parser-warning";
53
+ /** Parse-phase progress. Every scanned file counts as processed, whether parsed, unchanged, skipped or excluded. */
54
+ export interface ParsedMirrorProgress {
55
+ readonly processed: number;
56
+ readonly total: number;
57
+ /** Running totals for the files processed so far; the final event carries the sync result's counts. */
58
+ readonly written: number;
59
+ readonly deleted: number;
60
+ readonly skipped: number;
61
+ /** The file about to be processed; absent on the final event. */
62
+ readonly currentVirtualPath?: string;
63
+ }
64
+ export type ParsedMirrorDiagnosticCode = "unsupported-file" | "parser-skipped" | "parser-failed" | "parser-crashed" | "source-vanished" | "source-unreadable" | "source-read-failed" | "mirror-write-failed" | "duplicate-excluded" | "deleted-mirror" | "stale-index" | "pdf-extract-thin" | "parser-warning" | "search-root-unavailable" | "mass-delete-suppressed" | "walk-truncated" | "directory-unreadable";
19
65
  /**
20
66
  * Refresh diagnostic. `source` is an opaque virtual path, never a real filesystem path.
21
67
  * `message` keeps the underlying error text, which may include a filesystem path.
@@ -35,6 +81,16 @@ export interface ParsedMirrorSyncResult {
35
81
  readonly indexPath: string;
36
82
  readonly diagnostics: readonly ParsedMirrorDiagnostic[];
37
83
  }
84
+ /** Default retries for a transient per-file I/O error. Mirrors the `refresh.transientRetries` config default. */
85
+ export declare const DEFAULT_TRANSIENT_RETRIES = 3;
86
+ /**
87
+ * A failure that makes continuing the refresh pointless: the workspace volume is full or the
88
+ * workspace is not writable. Per-file failures never use this class.
89
+ */
90
+ export declare class MirrorWorkspaceError extends Error {
91
+ readonly code: string | undefined;
92
+ constructor(workspace: string, cause: unknown);
93
+ }
38
94
  export declare function syncParsedMirrors(options: ParsedMirrorSyncOptions): Promise<ParsedMirrorSyncResult>;
39
95
  /**
40
96
  * Cheap, parse-free staleness check: compares current source files (by mtime and
@@ -91,7 +91,6 @@ export interface StartSimplexPeerServerOptions {
91
91
  readonly injectionClassifier?: boolean;
92
92
  readonly injectionClassifierModel?: InjectionClassifierModel;
93
93
  readonly buildPeerResponse?: PeerResponseBuilder;
94
- readonly searchTimeoutMs?: number;
95
94
  readonly pseudonymize?: boolean;
96
95
  readonly logger?: (entry: SimplexPeerLog) => void;
97
96
  }
@@ -7,6 +7,14 @@ export interface DefaultParserRegistryOptions {
7
7
  readonly kordoc?: KordocParserOptions;
8
8
  /** Global document languages; selects the OCR engine when OCR is enabled. */
9
9
  readonly languages?: readonly LanguageTag[];
10
+ /**
11
+ * Hard per-file parse deadline in milliseconds (default 120000). kordoc, pptx and eml parse in a worker
12
+ * thread during a refresh; a parse still running at the deadline has its worker terminated and the file
13
+ * is skipped as `parser-failed`. A synchronous spin cannot be interrupted any other way.
14
+ */
15
+ readonly fileTimeoutMs?: number;
16
+ /** V8 old-generation heap limit in MB for the parse worker. An out-of-memory parse becomes a `parser-failed` skip. */
17
+ readonly maxHeapMb?: number;
10
18
  }
11
19
  /** Workspace-relative directory for Tesseract traineddata, so models never land in the process working directory. */
12
20
  export declare function tesseractCachePathFor(workspacePath: string): string;
@@ -3,3 +3,13 @@ export declare class ParseError extends Error {
3
3
  readonly virtualPath: string;
4
4
  constructor(parserName: string, virtualPath: string, cause: unknown);
5
5
  }
6
+ export type ParseIsolationFailureCode = "PARSE_TIMEOUT" | "WORKER_OOM" | "WORKER_CRASHED";
7
+ /**
8
+ * Why an isolated parse worker was lost. Carried as the `cause` of a
9
+ * {@link ParseError} so a timeout, an out-of-memory kill, and a crash stay
10
+ * distinguishable from a parser's own failure.
11
+ */
12
+ export declare class ParseIsolationError extends Error {
13
+ readonly code: ParseIsolationFailureCode;
14
+ constructor(code: ParseIsolationFailureCode, message: string);
15
+ }
@@ -0,0 +1,77 @@
1
+ import type { DefaultParserRegistryOptions } from "./defaults.js";
2
+ import type { ParseInput, ParseOutput } from "./types.js";
3
+ /** Per-file parse deadline when `parserOptions.fileTimeoutMs` is not set. */
4
+ export declare const DEFAULT_PARSE_FILE_TIMEOUT_MS = 120000;
5
+ /**
6
+ * Parsers that run third-party or format-parsing code which can spin, exhaust
7
+ * the heap, or crash on a hostile file. Plain text decoding stays in-process.
8
+ */
9
+ export declare const ISOLATED_PARSER_NAMES: ReadonlySet<string>;
10
+ /** The structured-cloneable subset of {@link DefaultParserRegistryOptions} a worker can rebuild its registry from. */
11
+ export interface WorkerParserOptions {
12
+ readonly languages?: DefaultParserRegistryOptions["languages"];
13
+ readonly ocr?: DefaultParserRegistryOptions["ocr"];
14
+ readonly kordoc?: {
15
+ readonly ocr?: boolean | "force";
16
+ };
17
+ }
18
+ export interface ParseWorkerRequest {
19
+ readonly id: number;
20
+ readonly parserName: string;
21
+ readonly virtualPath: string;
22
+ readonly sourcePath?: string;
23
+ readonly bytes: Uint8Array;
24
+ }
25
+ export type ParseWorkerResponse = {
26
+ readonly id: number;
27
+ readonly ok: true;
28
+ readonly output: ParseOutput;
29
+ } | {
30
+ readonly id: number;
31
+ readonly ok: false;
32
+ readonly kind: "parse-error";
33
+ readonly parserName: string;
34
+ readonly message: string;
35
+ readonly stack?: string;
36
+ } | {
37
+ readonly id: number;
38
+ readonly ok: false;
39
+ readonly kind: "error";
40
+ readonly message: string;
41
+ readonly stack?: string;
42
+ };
43
+ /**
44
+ * Parser options a worker thread can receive, or `undefined` when they hold a
45
+ * function (an injected `kordoc.parse` or OCR provider) that cannot cross the
46
+ * thread boundary. Such options stay in-process.
47
+ */
48
+ export declare function workerParserOptions(options: DefaultParserRegistryOptions): WorkerParserOptions | undefined;
49
+ /** Rejects a non-positive or non-finite `fileTimeoutMs` / `maxHeapMb` before any file is parsed. */
50
+ export declare function validateIsolationOptions(options: Pick<DefaultParserRegistryOptions, "fileTimeoutMs" | "maxHeapMb">): void;
51
+ export interface IsolatedParseRunnerOptions {
52
+ readonly parserOptions: WorkerParserOptions;
53
+ readonly fileTimeoutMs?: number;
54
+ /** V8 `resourceLimits.maxOldGenerationSizeMb` for the worker. Unset keeps Node's default. */
55
+ readonly maxHeapMb?: number;
56
+ /** Override the worker entry (tests). */
57
+ readonly workerUrl?: URL;
58
+ }
59
+ /**
60
+ * Runs parsers inside a worker thread so one file can be hard-killed. A
61
+ * `Promise.race` deadline cannot interrupt a synchronous spin, but
62
+ * `Worker.terminate()` can; a heap limit turns an out-of-memory parse into a
63
+ * catchable worker error instead of a host crash.
64
+ *
65
+ * One worker serves files in sequence and is reused until it is lost (deadline,
66
+ * out of memory, crash, abort); the next file then gets a fresh worker. Every
67
+ * worker-side loss rejects with a {@link ParseError} whose cause is a
68
+ * {@link ParseIsolationError}, so the caller's existing per-file skip applies.
69
+ */
70
+ export declare class IsolatedParseRunner {
71
+ #private;
72
+ constructor(options: IsolatedParseRunnerOptions);
73
+ /** Parse one file. Rejects with the signal's reason when `signal` aborts, after killing the worker. */
74
+ parse(parserName: string, input: ParseInput, signal?: AbortSignal): Promise<ParseOutput>;
75
+ /** Terminate the worker, if one is alive. The runner stays usable and spawns a fresh worker on demand. */
76
+ close(): Promise<void>;
77
+ }
@@ -54,6 +54,7 @@ export declare const KORDOC_IMAGE_EXTENSIONS: readonly [".png", ".jpg", ".jpeg",
54
54
  export declare class KordocParser extends Parser {
55
55
  #private;
56
56
  readonly name = "kordoc";
57
+ readonly version: string;
57
58
  readonly extensions: readonly string[];
58
59
  constructor(options?: KordocParserOptions);
59
60
  parse(input: ParseInput): Promise<ParseOutput>;
@@ -0,0 +1 @@
1
+ export {};