@autorag/librarian 2.0.0 → 2.2.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.
Files changed (63) hide show
  1. package/README.md +104 -2
  2. package/dist/agent/agent.d.ts +11 -0
  3. package/dist/agent/search-bm25-tool.d.ts +1 -1
  4. package/dist/agent/search-documents.d.ts +1 -0
  5. package/dist/agent/search-minsync-tool.d.ts +1 -1
  6. package/dist/cli/config.d.ts +6 -0
  7. package/dist/cli/index.js +5871 -587
  8. package/dist/datasource/chunk-store.d.ts +67 -0
  9. package/dist/datasource/connector-skill.d.ts +107 -0
  10. package/dist/datasource/connector.d.ts +72 -0
  11. package/dist/datasource/crawler-client.d.ts +9 -0
  12. package/dist/datasource/crawler-skill.d.ts +41 -0
  13. package/dist/datasource/crawler-types.d.ts +53 -0
  14. package/dist/datasource/http.d.ts +49 -0
  15. package/dist/datasource/index.d.ts +16 -0
  16. package/dist/datasource/skills/discrawl/client.d.ts +23 -0
  17. package/dist/datasource/skills/discrawl/config.d.ts +9 -0
  18. package/dist/datasource/skills/discrawl/index.d.ts +5 -0
  19. package/dist/datasource/skills/discrawl/methods.d.ts +55 -0
  20. package/dist/datasource/skills/discrawl/paths.d.ts +30 -0
  21. package/dist/datasource/skills/discrawl/skill.d.ts +58 -0
  22. package/dist/datasource/skills/discrawl/types.d.ts +198 -0
  23. package/dist/datasource/skills/factory.d.ts +35 -0
  24. package/dist/datasource/skills/gdrive/connector.d.ts +30 -0
  25. package/dist/datasource/skills/gdrive/index.d.ts +3 -0
  26. package/dist/datasource/skills/gdrive/rclone-connector.d.ts +51 -0
  27. package/dist/datasource/skills/gdrive/skill.d.ts +24 -0
  28. package/dist/datasource/skills/github/connector.d.ts +28 -0
  29. package/dist/datasource/skills/github/index.d.ts +2 -0
  30. package/dist/datasource/skills/github/skill.d.ts +20 -0
  31. package/dist/datasource/skills/gmail/connector.d.ts +30 -0
  32. package/dist/datasource/skills/gmail/himalaya-connector.d.ts +40 -0
  33. package/dist/datasource/skills/gmail/index.d.ts +3 -0
  34. package/dist/datasource/skills/gmail/skill.d.ts +24 -0
  35. package/dist/datasource/skills/mail-export/connector.d.ts +21 -0
  36. package/dist/datasource/skills/mail-export/index.d.ts +2 -0
  37. package/dist/datasource/skills/mail-export/skill.d.ts +20 -0
  38. package/dist/datasource/skills/notion/index.d.ts +15 -0
  39. package/dist/datasource/skills/obsidian/client.d.ts +15 -0
  40. package/dist/datasource/skills/obsidian/index.d.ts +6 -0
  41. package/dist/datasource/skills/obsidian/methods.d.ts +26 -0
  42. package/dist/datasource/skills/obsidian/paths.d.ts +27 -0
  43. package/dist/datasource/skills/obsidian/skill.d.ts +43 -0
  44. package/dist/datasource/skills/obsidian/types.d.ts +90 -0
  45. package/dist/datasource/skills/rss/connector.d.ts +28 -0
  46. package/dist/datasource/skills/rss/index.d.ts +2 -0
  47. package/dist/datasource/skills/rss/skill.d.ts +22 -0
  48. package/dist/datasource/skills/slack/index.d.ts +15 -0
  49. package/dist/datasource/skills/spotlight/connector.d.ts +59 -0
  50. package/dist/datasource/skills/spotlight/index.d.ts +2 -0
  51. package/dist/datasource/skills/spotlight/skill.d.ts +20 -0
  52. package/dist/datasource/skills/telecrawl/index.d.ts +15 -0
  53. package/dist/datasource/skills/wacrawl/index.d.ts +15 -0
  54. package/dist/index.js +5971 -673
  55. package/dist/parser/defaults.d.ts +2 -0
  56. package/dist/parser/hwp-markdown.d.ts +25 -0
  57. package/dist/parser/hwp.d.ts +7 -0
  58. package/dist/parser/index.d.ts +2 -1
  59. package/dist/parser/rhwp-adapter.d.ts +30 -0
  60. package/dist/retrieval/merger.d.ts +1 -0
  61. package/dist/retrieval/scope.d.ts +10 -0
  62. package/package.json +19 -18
  63. package/skills/autorag-setup/SKILL.md +74 -0
@@ -1,6 +1,8 @@
1
+ import { type HwpParserOptions } from "./hwp.js";
1
2
  import { type OcrParserOptions } from "./ocr.js";
2
3
  import { ParserRegistry } from "./registry.js";
3
4
  export interface DefaultParserRegistryOptions {
4
5
  readonly ocr?: OcrParserOptions;
6
+ readonly hwp?: HwpParserOptions;
5
7
  }
6
8
  export declare function createDefaultParserRegistry(options?: DefaultParserRegistryOptions): ParserRegistry;
@@ -0,0 +1,25 @@
1
+ export interface HwpExtractedDocument {
2
+ readonly paragraphs: readonly HwpBodyParagraph[];
3
+ readonly tables: readonly HwpTable[];
4
+ }
5
+ export interface HwpBodyParagraph {
6
+ readonly sectionIndex: number;
7
+ readonly paragraphIndex: number;
8
+ readonly text: string;
9
+ }
10
+ export interface HwpTable {
11
+ readonly sectionIndex: number;
12
+ readonly parentParagraphIndex: number;
13
+ readonly controlIndex: number;
14
+ readonly rowCount: number;
15
+ readonly columnCount: number;
16
+ readonly cells: readonly HwpTableCell[];
17
+ }
18
+ export interface HwpTableCell {
19
+ readonly row: number;
20
+ readonly column: number;
21
+ readonly rowSpan: number;
22
+ readonly columnSpan: number;
23
+ readonly paragraphs: readonly string[];
24
+ }
25
+ export declare function renderHwpMarkdown(document: HwpExtractedDocument): string;
@@ -1,6 +1,13 @@
1
+ import { type HwpExtractionLimits, type HwpExtractor } from "./rhwp-adapter.js";
1
2
  import { type ParseInput, type ParseOutput, Parser } from "./types.js";
3
+ export interface HwpParserOptions {
4
+ readonly limits?: HwpExtractionLimits;
5
+ readonly extractor?: HwpExtractor;
6
+ }
2
7
  export declare class HwpParser extends Parser {
3
8
  readonly name = "hwp";
4
9
  readonly extensions: readonly [".hwpx", ".hwp"];
10
+ private readonly extractor;
11
+ constructor(options?: HwpParserOptions);
5
12
  parse(input: ParseInput): Promise<ParseOutput>;
6
13
  }
@@ -1,10 +1,11 @@
1
1
  export { createDefaultParserRegistry, type DefaultParserRegistryOptions } from "./defaults.js";
2
2
  export { EmlParser } from "./eml.js";
3
3
  export { ParseError } from "./errors.js";
4
- export { HwpParser } from "./hwp.js";
4
+ export { HwpParser, type HwpParserOptions } from "./hwp.js";
5
5
  export { ImageOcrParser, type OcrEngine, type OcrEngineInput, type OcrParserOptions } from "./ocr.js";
6
6
  export { DocxParser, PptxParser, XlsxParser } from "./office.js";
7
7
  export { OpendataloaderPdfParser, type PdfConverter } from "./opendataloader-pdf.js";
8
8
  export { PlainTextParser } from "./plain-text.js";
9
9
  export { ParserRegistry } from "./registry.js";
10
+ export type { HwpExtractionLimits, HwpExtractor } from "./rhwp-adapter.js";
10
11
  export { type ParseInput, type ParseOutput, Parser } from "./types.js";
@@ -0,0 +1,30 @@
1
+ import type { HwpExtractedDocument } from "./hwp-markdown.js";
2
+ export interface HwpExtractionLimits {
3
+ readonly maxSections?: number;
4
+ readonly maxBodyParagraphs?: number;
5
+ readonly maxTables?: number;
6
+ readonly maxCells?: number;
7
+ readonly maxCellParagraphs?: number;
8
+ readonly maxCharacters?: number;
9
+ }
10
+ export type HwpExtractor = (bytes: Uint8Array) => Promise<HwpExtractedDocument>;
11
+ export interface RhwpDocumentApi {
12
+ free(): void;
13
+ getCellInfo(sectionIndex: number, parentParagraphIndex: number, controlIndex: number, cellIndex: number): string;
14
+ getCellParagraphCount(sectionIndex: number, parentParagraphIndex: number, controlIndex: number, cellIndex: number): number;
15
+ getCellParagraphLength(sectionIndex: number, parentParagraphIndex: number, controlIndex: number, cellIndex: number, cellParagraphIndex: number): number;
16
+ getPageControlLayout(pageNumber: number): string;
17
+ getParagraphCount(sectionIndex: number): number;
18
+ getParagraphLength(sectionIndex: number, paragraphIndex: number): number;
19
+ getSectionCount(): number;
20
+ getTableDimensions(sectionIndex: number, parentParagraphIndex: number, controlIndex: number): string;
21
+ getTextInCell(sectionIndex: number, parentParagraphIndex: number, controlIndex: number, cellIndex: number, cellParagraphIndex: number, characterOffset: number, count: number): string;
22
+ getTextRange(sectionIndex: number, paragraphIndex: number, characterOffset: number, count: number): string;
23
+ pageCount(): number;
24
+ }
25
+ export interface RhwpRuntime {
26
+ initialize(): Promise<void>;
27
+ open(bytes: Uint8Array): RhwpDocumentApi;
28
+ }
29
+ export declare function createRhwpExtractor(runtime?: RhwpRuntime, overrides?: HwpExtractionLimits): HwpExtractor;
30
+ export declare function extractHwpWithRhwp(bytes: Uint8Array, limits?: HwpExtractionLimits): Promise<HwpExtractedDocument>;
@@ -1,6 +1,7 @@
1
1
  import type { RetrievalMethod, RetrievalOptions, RetrievalResult, RetrievalWithDiagnostics } from "./types.js";
2
2
  export interface MergeOptions {
3
3
  topK: number;
4
+ /** Retained for API compatibility; exact-source aggregation is always enabled. */
4
5
  dedup: boolean;
5
6
  }
6
7
  export declare class ResultMerger {
@@ -1,4 +1,14 @@
1
+ export interface RetrievalScopeBinding {
2
+ readonly virtualPrefix: string;
3
+ readonly physicalRoots: readonly string[];
4
+ }
5
+ export declare class RetrievalScopeError extends Error {
6
+ readonly code = "invalid-retrieval-scope";
7
+ constructor(virtualPrefixes: readonly string[]);
8
+ }
1
9
  export declare function normalizeVirtualPath(value: string): string;
2
10
  export declare function normalizeVirtualPathScope(scope: string | undefined): string | undefined;
11
+ export declare function resolveRetrievalScope(scope: string | undefined, bindings: readonly RetrievalScopeBinding[], platform?: NodeJS.Platform, passthroughVirtualPrefixes?: readonly string[]): string | undefined;
12
+ export declare function buildRetrievalScopeBindings(workspaceRoot: string, searchPaths: readonly string[], configuredSearchPaths?: readonly string[]): readonly RetrievalScopeBinding[];
3
13
  export declare function matchesVirtualPathScope(virtualPath: string, scope: string | undefined): boolean;
4
14
  export declare function virtualPathScopeToRegExp(scope: string): RegExp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorag/librarian",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Self-evolving librarian agent on Pi framework with pluggable retrieval methods",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  "bin": {
20
- "autorag": "./dist/cli/index.js"
20
+ "autorag": "dist/cli/index.js"
21
21
  },
22
22
  "files": [
23
23
  "dist",
@@ -39,28 +39,29 @@
39
39
  "node": ">=24.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@earendil-works/pi-agent-core": "^0.80.10",
43
- "@earendil-works/pi-ai": "^0.80.10",
44
- "@earendil-works/pi-coding-agent": "0.80.10",
45
- "@opendataloader/pdf": "^2.4.7",
42
+ "@earendil-works/pi-agent-core": "^0.84.2",
43
+ "@earendil-works/pi-ai": "^0.84.2",
44
+ "@earendil-works/pi-coding-agent": "0.84.2",
45
+ "@opendataloader/pdf": "^2.5.2",
46
46
  "@pngwasi/node-tantivy-binding": "^0.3.4",
47
+ "@rhwp/core": "0.8.4",
47
48
  "chardet": "^2.2.0",
48
- "fast-xml-parser": "^5.9.3",
49
- "iconv-lite": "^0.7.2",
49
+ "fast-xml-parser": "^5.11.0",
50
+ "iconv-lite": "^0.7.3",
50
51
  "jszip": "^3.10.1",
51
- "mailparser": "^3.9.12",
52
- "pi-subagents": "0.35.1",
53
- "slides-grab": "^1.3.1",
54
- "smol-toml": "1.7.0",
52
+ "mailparser": "^3.9.15",
53
+ "pi-subagents": "0.53.0",
54
+ "slides-grab": "^1.5.0",
55
+ "smol-toml": "1.8.0",
55
56
  "tesseract.js": "^7.0.0",
56
- "typebox": "^1.1.24",
57
- "yaml": "^2.8.2"
57
+ "typebox": "^1.3.16",
58
+ "yaml": "^2.9.0"
58
59
  },
59
60
  "devDependencies": {
60
- "@biomejs/biome": "2.3.5",
61
+ "@biomejs/biome": "2.5.9",
61
62
  "@types/mailparser": "^3.4.6",
62
- "@types/node": "^24.3.0",
63
- "typescript": "^5.7.3",
64
- "vitest": "^4.1.10"
63
+ "@types/node": "^26.2.0",
64
+ "typescript": "^7.0.2",
65
+ "vitest": "^4.1.11"
65
66
  }
66
67
  }
@@ -232,6 +232,80 @@ via the role-specific flags or:
232
232
  - legacy single-model aliases: `AUTORAG_MODEL_PROVIDER` / `AUTORAG_MODEL_ID`
233
233
  - `AUTORAG_SEARCH_PATHS`, `AUTORAG_WORKSPACE`, `AUTORAG_MEMORY_PATH`
234
234
 
235
+ ## Configure datasource skills (optional)
236
+
237
+ External datasources (WhatsApp, Telegram, Slack, Discord, Notion, GitHub Issues/PRs, Google
238
+ Drive, Gmail, local mail exports, Obsidian vaults, RSS/news) are configured
239
+ as **datasource skills** in the trusted config file — never via model/tool
240
+ arguments. Add a `datasources` section (skill name → config) plus a trusted
241
+ `datasourceAccess` allow-list to `config.json`:
242
+
243
+ ```jsonc
244
+ {
245
+ "datasources": {
246
+ "whatsapp": { "instanceId": "personal", "connector": { "binaryPath": "wacrawl" } },
247
+ "telegram": { "instanceId": "personal", "connector": { "binaryPath": "telecrawl" } },
248
+ "slack": { "connector": { "binaryPath": "slacrawl", "configPath": "/path/to/slacrawl.yaml", "syncSource": "primary" } },
249
+ "discord": { "connector": { "tokenEnv": "DISCORD_BOT_TOKEN", "guildId": "..." } },
250
+ "notion": { "connector": { "binaryPath": "notcrawl", "configPath": "/path/to/notcrawl.yaml" } },
251
+ "github": { "connector": { "repos": ["owner/repo"], "tokenEnv": "GITHUB_TOKEN" } },
252
+ "gdrive": { "connector": { "backend": "rclone", "remote": "gdrive:" } },
253
+ "gmail": { "connector": { "backend": "himalaya", "account": "gmail", "folder": "INBOX" } },
254
+ "mail-export": { "connector": { "paths": ["/path/to/exports"] } },
255
+ "obsidian": { "connector": { "vaultPath": "/path/to/vault" } },
256
+ "rss": { "connector": { "feeds": [{ "url": "https://example.com/feed.xml" }] } }
257
+ },
258
+ "datasourceAccess": {
259
+ "allowedTags": ["whatsapp", "telegram", "slack", "github", "rss"],
260
+ "allowedScopes": ["/whatsapp/**", "/telegram/**", "/slack/**", "/github/**", "/rss/**"]
261
+ }
262
+ }
263
+ ```
264
+
265
+ Rules:
266
+
267
+ - REST connector tokens are configured as **environment variable names** (`tokenEnv`), never
268
+ raw secrets in the file. Each skill has a default env var
269
+ (`DISCORD_BOT_TOKEN`, `GITHUB_TOKEN`,
270
+ `GDRIVE_ACCESS_TOKEN`, `GMAIL_ACCESS_TOKEN`).
271
+ - **CLI-bridge backends** (recommended where available): `gmail` accepts
272
+ `"backend": "himalaya"` to index any IMAP/Maildir account the external
273
+ [himalaya](https://pimalaya.org) CLI has configured (no OAuth plumbing);
274
+ `gdrive` accepts `"backend": "rclone"` to index a Google Drive remote (or
275
+ any of rclone's 70+ backends) configured via `rclone config` — Docs/Sheets
276
+ are exported as text through `--drive-export-formats`. Auth lives entirely
277
+ in the external tool's own config, matching the katok pattern.
278
+ - `whatsapp` requires the external
279
+ [wacrawl](https://github.com/openclaw/wacrawl) binary
280
+ (`brew install openclaw/tap/wacrawl`). Optional trusted connector fields are
281
+ `binaryPath`, `databasePath`, and `sourcePath`. Live desktop ingestion is
282
+ macOS-only; the crawler owns Full Disk Access and archive setup.
283
+ - `telegram` requires the external
284
+ [telecrawl](https://github.com/openclaw/telecrawl) binary
285
+ (`brew install openclaw/tap/telecrawl`). Optional trusted connector fields
286
+ are `binaryPath`, `databasePath`, and `sourcePath`. Live desktop ingestion
287
+ is macOS-only; the crawler owns Full Disk Access and archive setup.
288
+ - `slack` requires the external
289
+ [slacrawl](https://github.com/openclaw/slacrawl) binary
290
+ (`brew install openclaw/tap/slacrawl`). Optional trusted connector fields
291
+ are `binaryPath`, `configPath`, and `syncSource`; Slack credentials and
292
+ remote source definitions stay in slacrawl's own configuration.
293
+ - `notion` requires the external
294
+ [notcrawl](https://github.com/openclaw/notcrawl) binary
295
+ (`brew install openclaw/tap/notcrawl`). Optional trusted connector fields
296
+ are `binaryPath` and `configPath`; Notion credentials and workspace
297
+ definitions stay in notcrawl's own configuration.
298
+ - Access is **default-deny**: without `datasourceAccess.allowedTags`, no
299
+ datasource skill is announced or searchable, even when configured.
300
+ `allowedScopes` are opaque slash-hierarchical roots like `/slack/<instance>/**`.
301
+ - Per-skill options: `instanceId`, `pollingIntervalMs`, `tags`, and the
302
+ connector-specific `connector` object. `false` or `{ "enabled": false }`
303
+ disables an entry. Unknown skill names fail config resolution.
304
+ - `autorag refresh --method datasources` indexes them; chunks persist under
305
+ `<workspace>/.autorag/datasources/<skill>/<instance>/`.
306
+ - Verify with the manual QA harness: `bun scripts/manual-qa/run-qa.ts`
307
+ (see `docs/manual-qa-datasources.md`).
308
+
235
309
  ## Build indexes after install
236
310
 
237
311
  Installation + `init` alone does **not** make search useful. Immediately after