@autorag/librarian 2.4.0 → 2.4.1

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.
@@ -3,6 +3,8 @@ export declare class JikjiClient {
3
3
  private readonly options;
4
4
  private resolvedCommand;
5
5
  constructor(options?: JikjiOptions);
6
+ /** Jikji stores prepared corpus metadata under a hidden directory in each root. */
7
+ isPrepared(root: string): boolean;
6
8
  /**
7
9
  * Resolve the jikji command following the priority chain:
8
10
  * 1. explicit binaryPath
@@ -1,7 +1,7 @@
1
1
  export { MinSyncClient, type MinSyncClientOptions, type MinSyncQueryMode } from "./client.js";
2
2
  export { MINSYNC_CONFIG_DIR, MINSYNC_CONFIG_FILE, minSyncConfigPath, rewriteEmbedderConfig, } from "./embedder-config.js";
3
3
  export { type EnsureMinSyncBinaryOptions, ensureMinSyncBinary, executableName, fetchLatestMinSyncRelease, type InstalledMinSyncBinary, MINSYNC_VERSION, type MinSyncRelease, type MinSyncReleaseAsset, MinSyncReleaseError, selectReleaseAsset, } from "./installer.js";
4
- export { MinSyncBM25Method, type MinSyncBM25MethodOptions, MinSyncHybridMethod, type MinSyncHybridMethodOptions, MinSyncVectorMethod, type MinSyncVectorMethodOptions, } from "./method.js";
4
+ export { MinSyncHybridMethod, type MinSyncHybridMethodOptions, MinSyncVectorMethod, type MinSyncVectorMethodOptions, } from "./method.js";
5
5
  export { MINSYNC_FILES_SUBDIR, MINSYNC_SUBDIR, minSyncDocumentPath, minSyncWorkspaceRoot } from "./paths.js";
6
6
  export type { MinSyncChunkerConfig, MinSyncEmbedderConfig, MinSyncOptions, MinSyncQueryHit, MinSyncSyncResult, } from "./types.js";
7
7
  export { buildMinSyncPathMap, type MinSyncWorkspaceEntry, type MinSyncWorkspaceSyncResult, syncMinSyncWorkspace, } from "./workspace.js";
@@ -1,10 +1,10 @@
1
- import { type BM25Status, type BM25SyncResult } from "../retrieval/methods/bm25.js";
2
1
  import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../retrieval/types.js";
3
2
  import type { MinSyncQueryMode } from "./client.js";
4
3
  import { type EnsureMinSyncBinaryOptions } from "./installer.js";
5
4
  import type { MinSyncEmbedderConfig, MinSyncSyncResult } from "./types.js";
6
5
  export interface MinSyncVectorMethodOptions {
7
6
  readonly root: string;
7
+ /** Test/embedded override; CLI config intentionally does not persist this. */
8
8
  readonly binaryPath?: string;
9
9
  readonly workspacePath?: string;
10
10
  readonly installer?: Omit<EnsureMinSyncBinaryOptions, "root">;
@@ -13,7 +13,6 @@ export interface MinSyncVectorMethodOptions {
13
13
  readonly maxChunkSize?: number;
14
14
  readonly mode?: MinSyncQueryMode;
15
15
  }
16
- export type MinSyncBM25MethodOptions = Omit<MinSyncVectorMethodOptions, "mode">;
17
16
  export type MinSyncHybridMethodOptions = Omit<MinSyncVectorMethodOptions, "mode">;
18
17
  export declare class MinSyncVectorMethod implements RetrievalMethod {
19
18
  private readonly root;
@@ -27,31 +26,20 @@ export declare class MinSyncVectorMethod implements RetrievalMethod {
27
26
  constructor(options: MinSyncVectorMethodOptions);
28
27
  describe(): RetrievalMethodDescriptor;
29
28
  sync(): Promise<MinSyncSyncResult>;
30
- /** True when a configured binary path is missing (an explicit degraded state). */
29
+ /** MinSync is resolved from PATH, then the workspace cache. */
31
30
  isBinaryMissing(): boolean;
31
+ /** A vector index is ready only after MinSync has written its cursor. */
32
+ isReady(): boolean;
32
33
  retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
33
34
  /**
34
- * Resolve the minsync binary path following the priority chain:
35
- * 1. explicit binaryPath if set and exists
36
- * 2. PATH lookup for `minsync`
37
- * 3. cached join(root, '.autorag', 'bin', execName) if exists
38
- * 4. if autoInstall===true, try ensureMinSyncBinary in try/catch => install-failed degrade
39
- * 5. else return undefined (missing-binary degrade)
35
+ * Resolve the MinSync CLI from the user's global PATH first, then the
36
+ * workspace cache, and finally the verified auto-install fallback.
40
37
  *
41
38
  * Returns: string path on success, undefined for missing-binary, or a MinSyncSyncResult
42
39
  * for install-failed.
43
40
  */
44
41
  protected resolveBinary(): Promise<string | undefined | MinSyncSyncResult>;
45
42
  }
46
- export declare class MinSyncBM25Method extends MinSyncVectorMethod {
47
- private status;
48
- constructor(options: MinSyncBM25MethodOptions);
49
- describe(): RetrievalMethodDescriptor;
50
- retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
51
- syncFromMinSync(result: MinSyncSyncResult): BM25SyncResult;
52
- getStatus(): BM25Status;
53
- private resolveBinaryForRetrieve;
54
- }
55
43
  export declare class MinSyncHybridMethod extends MinSyncVectorMethod {
56
44
  constructor(options: MinSyncHybridMethodOptions);
57
45
  describe(): RetrievalMethodDescriptor;
@@ -1,7 +1,5 @@
1
1
  export type { MergeOptions } from "./merger.js";
2
2
  export { ParallelRetriever, ResultMerger } from "./merger.js";
3
- export type { BM25Engine, BM25ReadinessState, BM25Status, BM25SyncResult } from "./methods/bm25.js";
4
- export { BM25_SUBDIR, BM25UnavailableError, hasLegacyBm25Artifacts, removeLegacyBm25Artifacts, } from "./methods/bm25.js";
5
3
  export { RetrievalMethodRegistry } from "./registry.js";
6
4
  export { matchesVirtualPathScope, normalizeVirtualPath, normalizeVirtualPathScope, virtualPathScopeToRegExp, } from "./scope.js";
7
5
  export type { CuratedResult, NumberedResult, RetrievalDiagnostic, RetrievalDiagnosticCode, RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult, RetrievalWithDiagnostics, } from "./types.js";
@@ -1,8 +1,8 @@
1
- import type { RetrievalMethod } from "./types.js";
1
+ import type { RetrievalMethod, RetrievalMethodDescriptor } from "./types.js";
2
2
  export declare class RetrievalMethodRegistry {
3
3
  private readonly methods;
4
4
  register(method: RetrievalMethod): void;
5
5
  get(name: string): RetrievalMethod | undefined;
6
6
  list(): RetrievalMethod[];
7
- getByType(type: "posix" | "vector" | "bm25" | "hybrid" | "visual"): RetrievalMethod[];
7
+ getByType(type: RetrievalMethodDescriptor["type"]): RetrievalMethod[];
8
8
  }
@@ -26,7 +26,7 @@ export interface RetrievalMethod {
26
26
  describe(): RetrievalMethodDescriptor;
27
27
  retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
28
28
  }
29
- export type RetrievalDiagnosticCode = "retrieval-method-failed" | "minsync-unavailable" | "bm25-unavailable" | "bm25-degraded-fallback";
29
+ export type RetrievalDiagnosticCode = "retrieval-method-failed" | "minsync-unavailable";
30
30
  /** Path-opaque diagnostic emitted by the multi-method retrieval pipeline. */
31
31
  export interface RetrievalDiagnostic {
32
32
  code: RetrievalDiagnosticCode;
@@ -11,8 +11,6 @@ export type DiscoverRun = (binary: string, args: readonly string[]) => Promise<{
11
11
  stdout: string;
12
12
  }>;
13
13
  export declare function listRcloneRemotes(run?: DiscoverRun): Promise<readonly Choice[]>;
14
- export declare function listMailAccounts(run?: DiscoverRun): Promise<readonly Choice[]>;
15
- export declare function listHimalayaAccounts(run?: DiscoverRun): Promise<readonly Choice[]>;
16
14
  export declare function choicesForType(type: string, run?: DiscoverRun): Promise<{
17
15
  rcloneRemotes: readonly Choice[];
18
16
  mailAccounts: readonly Choice[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorag/librarian",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Self-evolving librarian agent on Pi framework with pluggable retrieval methods",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,7 +11,7 @@ summarize, compare, or answer questions from local PDFs, wikis, notes, research
11
11
  papers, knowledge bases, or authorized datasources.
12
12
 
13
13
  AutoRAG is the specialized librarian agent. One configured model plans the
14
- search, calls BM25, MinSync, Jikji, datasource, and filesystem tools, reads
14
+ search, calls MinSync, Jikji, datasource, and filesystem tools, reads
15
15
  sources, judges evidence, and curates the final answer. There is no subagent or
16
16
  separate model role.
17
17
 
@@ -46,7 +46,7 @@ checks credential presence, and normally probes one live completion. If the
46
46
  model, authentication, configuration, or indexes are unhealthy, use
47
47
  `autorag-setup` rather than guessing private provider details.
48
48
 
49
- BM25, MinSync, and Jikji should normally be healthy. MinSync and Jikji
49
+ MinSync and Jikji should normally be healthy. MinSync and Jikji
50
50
  auto-install on first use by default. If they are missing or stale, run a full
51
51
  `autorag refresh` or return to setup rather than silently degrading to
52
52
  lexical-only search.
@@ -65,15 +65,28 @@ autorag search "what were the key findings in the Q3 report" --top-k 5 --json --
65
65
  `summary`, optional `source`), and `sessionId`. Use that `sessionId` for
66
66
  feedback. `--json` without `--debug` is only `answer` plus `results`.
67
67
 
68
+ To inspect the exact persisted evidence behind numbered results, use:
69
+
70
+ ```bash
71
+ autorag evidence <sessionId> --result 1 --json
72
+ ```
73
+
74
+ The response includes the original source, retrieval method, stable evidence
75
+ ID, raw excerpt/content, and any available `chunkIndex`, `lineNumber`,
76
+ `retrievalResultId`, and metadata. Omit `--result` to inspect every result in
77
+ the session. Prefer this command whenever the caller wants detailed chunk text
78
+ rather than only the curated summary.
79
+
68
80
  - `--scope` narrows datasource retrieval to a requested sub-path; it cannot
69
81
  grant access.
70
82
  - `--tags` further narrows already-authorized datasource results and never
71
83
  grants new access.
72
84
  - `--json` is required for programmatic consumption.
73
- - `--debug` is required for `sessionId`, evidence, and diagnostics.
85
+ - `--debug` is required for `sessionId` and diagnostics in search output.
86
+ - `autorag evidence` is the detailed source/chunk inspection path.
74
87
 
75
88
  Do not bypass the librarian with ad hoc raw search when the user requested
76
- AutoRAG. The search loop can use Jikji, BM25, MinSync, datasource retrieval, and
89
+ AutoRAG. The search loop can use Jikji, MinSync lexical/vector/hybrid retrieval, datasource retrieval, and
77
90
  direct source reading as appropriate. If search fails because of model,
78
91
  provider, auth, or timeout problems, diagnose with `autorag health --json`.
79
92
 
@@ -99,9 +112,9 @@ autorag index reset --method bm25 --yes --json
99
112
  autorag memory inspect --json
100
113
  ```
101
114
 
102
- Prefer a full refresh so parsed mirrors, BM25, MinSync, Jikji, and configured
115
+ Prefer a full refresh so parsed mirrors, MinSync, Jikji, and configured
103
116
  datasources stay aligned. `--method` accepts
104
- `parsed,bm25,minsync,datasources,jikji,all`. Use it only for deliberate
117
+ `parsed,minsync,datasources,jikji,all`. Use it only for deliberate
105
118
  narrowing. Scheduled maintenance should use non-daemon `autorag watch --once`,
106
119
  typically every 15–30 minutes, with the same config used by search and no
107
120
  overlapping runs.
@@ -127,7 +127,7 @@ Use `--force` only when intentionally replacing an existing config. Legacy cwd
127
127
 
128
128
  ### Retrieval defaults
129
129
 
130
- BM25, MinSync, and Jikji are enabled by default. Leave them enabled unless the
130
+ MinSync and Jikji are enabled by default. Leave them enabled unless the
131
131
  user explicitly asks otherwise. MinSync auto-installs a verified GitHub release
132
132
  into `<workspace>/.autorag/bin` on first use (`minSync.autoInstall` defaults to
133
133
  true). Set `"autoInstall": false` only when managing the binary yourself. Jikji
@@ -175,7 +175,7 @@ aliases with `"type": "<template>"`. Unknown names are skipped with an
175
175
  "github": { "connector": { "repos": ["owner/repo"], "tokenEnv": "GITHUB_TOKEN" } },
176
176
  "google-drive": { "type": "cloud-drive", "connector": { "provider": "google-drive", "remote": "gdrive:" } },
177
177
  "archive-drive": { "type": "cloud-drive", "connector": { "remote": "archive:" } },
178
- "gmail": { "connector": { "backend": "himalaya", "account": "gmail", "folder": "INBOX" } },
178
+ "gmail": { "connector": { "tokenEnv": "GMAIL_ACCESS_TOKEN", "labelIds": ["INBOX"] } },
179
179
  "mailcrawl": { "instanceId": "personal", "connector": { "account": "personal", "mailbox": "INBOX", "binaryPath": "mailcrawl" } },
180
180
  "obsidian": { "connector": { "vaultPath": "/path/to/vault" } },
181
181
  "rss": { "connector": { "feeds": [{ "url": "https://example.com/feed.xml" }] } }
@@ -195,6 +195,9 @@ and configured through its own Himalaya account. AutoRAG runs its local `sync`
195
195
  and `index` lifecycle, then uses the mailcrawl CLI for BM25, semantic, or
196
196
  hybrid search. Do not use 0.1.3 or earlier: a no-op sync followed by `index`
197
197
  fails with `text array must be non-empty`.
198
+ Use mailcrawl for Himalaya-backed IMAP/Maildir retrieval. The legacy
199
+ `gmail` connector option `backend: "himalaya"` is no longer registered; migrate
200
+ that configuration to an explicit `mailcrawl` datasource.
198
201
 
199
202
  ## Verify and build indexes
200
203
 
@@ -212,12 +215,15 @@ autorag search "summarize the collection" --top-k 3 --json --debug
212
215
  performs one live completion probe.
213
216
  - `health --skip-probes` is only for intentionally offline validation and does
214
217
  not prove live provider access.
215
- - `refresh` syncs parsed mirrors, BM25, MinSync, Jikji, and authorized
218
+ - `refresh` syncs parsed mirrors, MinSync, Jikji, and authorized
216
219
  datasources. `--method <csv>` may deliberately narrow it
217
- (`parsed,bm25,minsync,datasources,jikji,all`).
220
+ (`parsed,minsync,datasources,jikji,all`).
218
221
  - Use `refresh --force` for a full resync only when incremental refresh is not
219
222
  enough. Keep destructive reset/rebuild operations scoped to workspace
220
223
  `.autorag` indexes, never source documents.
224
+ - After a search, use `autorag evidence <sessionId> --json` to inspect the
225
+ exact source chunks behind numbered results, including source, method,
226
+ stable evidence ID, excerpt/content, chunk index, and line number.
221
227
 
222
228
  ## Keep indexes fresh
223
229
 
@@ -1,26 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { Type } from "typebox";
3
- import type { BM25Status } from "../retrieval/methods/bm25.js";
4
- import type { RetrievalResult } from "../retrieval/types.js";
5
- export declare const SEARCH_BM25_DOCUMENTS_TOOL_NAME = "lexical_search_local_docs";
6
- declare const searchBM25Schema: Type.TObject<{
7
- query: Type.TString;
8
- topK: Type.TOptional<Type.TInteger>;
9
- scope: Type.TOptional<Type.TString>;
10
- }>;
11
- export interface SearchBM25DocumentsDetails {
12
- readonly method: "bm25";
13
- readonly resultCount: number;
14
- readonly sources: readonly string[];
15
- readonly readiness: BM25Status["readiness"];
16
- readonly engine: BM25Status["engine"];
17
- }
18
- export interface BM25SearchMethod {
19
- getStatus(): BM25Status;
20
- retrieve(query: string, options: {
21
- topK?: number;
22
- scope?: string;
23
- }): Promise<RetrievalResult[]>;
24
- }
25
- export declare function createSearchBM25DocumentsTool(getMethod: () => BM25SearchMethod | undefined, resolveScope?: (scope: string | undefined) => string | undefined): AgentTool<typeof searchBM25Schema, SearchBM25DocumentsDetails>;
26
- export {};
@@ -1,51 +0,0 @@
1
- /**
2
- * Himalaya-backed mail connector (issue #1304, IMAP path).
3
- *
4
- * Uses the external `himalaya` CLI (https://pimalaya.org) as the trusted
5
- * bridge to any IMAP/Maildir account it has configured — Gmail included —
6
- * so no OAuth token plumbing is needed here. Mirrors the katok pattern:
7
- * AutoRAG never opens the mailbox itself; it spawns the CLI, parses JSON
8
- * envelopes, and reads message bodies. Never throws; failures map onto the
9
- * coarse connector failure union with path/PII-opaque messages.
10
- */
11
- import { type ConnectorFetchResult, type DatasourceConnector } from "../../connector.js";
12
- export interface HimalayaRunResult {
13
- readonly ok: boolean;
14
- readonly stdout: string;
15
- readonly stderr: string;
16
- readonly code: number | null;
17
- }
18
- export type HimalayaRunner = (args: readonly string[], timeoutMs: number) => Promise<HimalayaRunResult>;
19
- export interface HimalayaConnectorOptions {
20
- /** Path to the himalaya binary. Default bare `himalaya` PATH lookup. */
21
- readonly binaryPath?: string;
22
- /** Himalaya account name (`himalaya account list`). Default account when omitted. */
23
- readonly account?: string;
24
- /** Mail folder, e.g. `INBOX`. Himalaya's default folder when omitted. */
25
- readonly folder?: string;
26
- /** Envelopes per listing page. Default 100. */
27
- readonly pageSize?: number;
28
- /** Max messages whose bodies are fetched per run. Default 50. */
29
- readonly maxDocuments?: number;
30
- /**
31
- * Workspace root for the connector's envelope fingerprint state. When set,
32
- * subsequent refreshes fetch only new or changed envelopes and update the
33
- * shared chunk store incrementally.
34
- */
35
- readonly workspaceRoot?: string;
36
- /** Per-spawn timeout. Default 30s (IMAP fetches can be slow). */
37
- readonly timeoutMs?: number;
38
- /** Injectable process runner for tests. */
39
- readonly runner?: HimalayaRunner;
40
- /** Explicit operator-owned config path, passed read-only to Himalaya. */
41
- readonly configPath?: string;
42
- }
43
- export declare class HimalayaConnector implements DatasourceConnector {
44
- private readonly options;
45
- private readonly runner;
46
- constructor(options?: HimalayaConnectorOptions);
47
- fetch(): Promise<ConnectorFetchResult>;
48
- private loadState;
49
- private saveState;
50
- private statePath;
51
- }
@@ -1,23 +0,0 @@
1
- export type BM25ReadinessState = "disabled" | "dependency_unavailable" | "index_missing" | "indexing" | "ready" | "error";
2
- /** Local BM25 is always MinSync-backed when enabled. */
3
- export type BM25Engine = "minsync" | "none";
4
- export interface BM25SyncResult {
5
- readonly indexPath: string;
6
- readonly indexedChunks: number;
7
- readonly readiness: BM25ReadinessState;
8
- readonly engine: BM25Engine;
9
- }
10
- export interface BM25Status {
11
- readonly readiness: BM25ReadinessState;
12
- readonly engine: BM25Engine;
13
- readonly message?: string;
14
- }
15
- /** Legacy AutoRAG-local BM25 artifact directory. Never an active index. */
16
- export declare const BM25_SUBDIR: string;
17
- export declare class BM25UnavailableError extends Error {
18
- readonly readiness: BM25ReadinessState;
19
- constructor(readiness: BM25ReadinessState, message: string);
20
- }
21
- /** Remove leftover `.autorag/bm25` artifacts from the pre-MinSync BM25 path. */
22
- export declare function removeLegacyBm25Artifacts(root: string): void;
23
- export declare function hasLegacyBm25Artifacts(root: string): boolean;