@autorag/librarian 2.1.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 (41) hide show
  1. package/README.md +73 -15
  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-minsync-tool.d.ts +1 -1
  5. package/dist/cli/index.js +4206 -2039
  6. package/dist/datasource/connector-skill.d.ts +1 -1
  7. package/dist/datasource/connector.d.ts +1 -1
  8. package/dist/datasource/crawler-client.d.ts +9 -0
  9. package/dist/datasource/crawler-skill.d.ts +41 -0
  10. package/dist/datasource/crawler-types.d.ts +53 -0
  11. package/dist/datasource/index.d.ts +6 -4
  12. package/dist/datasource/skills/discrawl/client.d.ts +23 -0
  13. package/dist/datasource/skills/discrawl/config.d.ts +9 -0
  14. package/dist/datasource/skills/discrawl/index.d.ts +5 -0
  15. package/dist/datasource/skills/discrawl/methods.d.ts +55 -0
  16. package/dist/datasource/skills/discrawl/paths.d.ts +30 -0
  17. package/dist/datasource/skills/discrawl/skill.d.ts +58 -0
  18. package/dist/datasource/skills/discrawl/types.d.ts +198 -0
  19. package/dist/datasource/skills/notion/index.d.ts +15 -2
  20. package/dist/datasource/skills/obsidian/client.d.ts +15 -0
  21. package/dist/datasource/skills/obsidian/index.d.ts +6 -2
  22. package/dist/datasource/skills/obsidian/methods.d.ts +26 -0
  23. package/dist/datasource/skills/obsidian/paths.d.ts +27 -0
  24. package/dist/datasource/skills/obsidian/skill.d.ts +40 -17
  25. package/dist/datasource/skills/obsidian/types.d.ts +90 -0
  26. package/dist/datasource/skills/slack/index.d.ts +15 -2
  27. package/dist/datasource/skills/telecrawl/index.d.ts +15 -0
  28. package/dist/datasource/skills/wacrawl/index.d.ts +15 -0
  29. package/dist/index.js +4231 -2048
  30. package/dist/retrieval/merger.d.ts +1 -0
  31. package/dist/retrieval/scope.d.ts +10 -0
  32. package/package.json +18 -18
  33. package/skills/autorag-setup/SKILL.md +29 -7
  34. package/dist/datasource/skills/discord/connector.d.ts +0 -30
  35. package/dist/datasource/skills/discord/index.d.ts +0 -2
  36. package/dist/datasource/skills/discord/skill.d.ts +0 -20
  37. package/dist/datasource/skills/notion/connector.d.ts +0 -26
  38. package/dist/datasource/skills/notion/skill.d.ts +0 -20
  39. package/dist/datasource/skills/obsidian/connector.d.ts +0 -22
  40. package/dist/datasource/skills/slack/connector.d.ts +0 -28
  41. package/dist/datasource/skills/slack/skill.d.ts +0 -20
@@ -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.1.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": {
@@ -39,29 +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.7.19",
47
+ "@rhwp/core": "0.8.4",
48
48
  "chardet": "^2.2.0",
49
- "fast-xml-parser": "^5.9.3",
50
- "iconv-lite": "^0.7.2",
49
+ "fast-xml-parser": "^5.11.0",
50
+ "iconv-lite": "^0.7.3",
51
51
  "jszip": "^3.10.1",
52
- "mailparser": "^3.9.12",
53
- "pi-subagents": "0.35.1",
54
- "slides-grab": "^1.3.1",
55
- "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",
56
56
  "tesseract.js": "^7.0.0",
57
- "typebox": "^1.1.24",
58
- "yaml": "^2.8.2"
57
+ "typebox": "^1.3.16",
58
+ "yaml": "^2.9.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@biomejs/biome": "2.3.5",
61
+ "@biomejs/biome": "2.5.9",
62
62
  "@types/mailparser": "^3.4.6",
63
- "@types/node": "^24.3.0",
64
- "typescript": "^5.7.3",
65
- "vitest": "^4.1.10"
63
+ "@types/node": "^26.2.0",
64
+ "typescript": "^7.0.2",
65
+ "vitest": "^4.1.11"
66
66
  }
67
67
  }
@@ -234,7 +234,7 @@ via the role-specific flags or:
234
234
 
235
235
  ## Configure datasource skills (optional)
236
236
 
237
- External datasources (Slack, Discord, Notion, GitHub Issues/PRs, Google
237
+ External datasources (WhatsApp, Telegram, Slack, Discord, Notion, GitHub Issues/PRs, Google
238
238
  Drive, Gmail, local mail exports, Obsidian vaults, RSS/news) are configured
239
239
  as **datasource skills** in the trusted config file — never via model/tool
240
240
  arguments. Add a `datasources` section (skill name → config) plus a trusted
@@ -243,9 +243,11 @@ arguments. Add a `datasources` section (skill name → config) plus a trusted
243
243
  ```jsonc
244
244
  {
245
245
  "datasources": {
246
- "slack": { "connector": { "tokenEnv": "SLACK_BOT_TOKEN", "channels": ["eng"] } },
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" } },
247
249
  "discord": { "connector": { "tokenEnv": "DISCORD_BOT_TOKEN", "guildId": "..." } },
248
- "notion": { "connector": { "tokenEnv": "NOTION_TOKEN" } },
250
+ "notion": { "connector": { "binaryPath": "notcrawl", "configPath": "/path/to/notcrawl.yaml" } },
249
251
  "github": { "connector": { "repos": ["owner/repo"], "tokenEnv": "GITHUB_TOKEN" } },
250
252
  "gdrive": { "connector": { "backend": "rclone", "remote": "gdrive:" } },
251
253
  "gmail": { "connector": { "backend": "himalaya", "account": "gmail", "folder": "INBOX" } },
@@ -254,17 +256,17 @@ arguments. Add a `datasources` section (skill name → config) plus a trusted
254
256
  "rss": { "connector": { "feeds": [{ "url": "https://example.com/feed.xml" }] } }
255
257
  },
256
258
  "datasourceAccess": {
257
- "allowedTags": ["slack", "github", "rss"],
258
- "allowedScopes": ["/slack/**", "/github/**", "/rss/**"]
259
+ "allowedTags": ["whatsapp", "telegram", "slack", "github", "rss"],
260
+ "allowedScopes": ["/whatsapp/**", "/telegram/**", "/slack/**", "/github/**", "/rss/**"]
259
261
  }
260
262
  }
261
263
  ```
262
264
 
263
265
  Rules:
264
266
 
265
- - Tokens are configured as **environment variable names** (`tokenEnv`), never
267
+ - REST connector tokens are configured as **environment variable names** (`tokenEnv`), never
266
268
  raw secrets in the file. Each skill has a default env var
267
- (`SLACK_BOT_TOKEN`, `DISCORD_BOT_TOKEN`, `NOTION_TOKEN`, `GITHUB_TOKEN`,
269
+ (`DISCORD_BOT_TOKEN`, `GITHUB_TOKEN`,
268
270
  `GDRIVE_ACCESS_TOKEN`, `GMAIL_ACCESS_TOKEN`).
269
271
  - **CLI-bridge backends** (recommended where available): `gmail` accepts
270
272
  `"backend": "himalaya"` to index any IMAP/Maildir account the external
@@ -273,6 +275,26 @@ Rules:
273
275
  any of rclone's 70+ backends) configured via `rclone config` — Docs/Sheets
274
276
  are exported as text through `--drive-export-formats`. Auth lives entirely
275
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.
276
298
  - Access is **default-deny**: without `datasourceAccess.allowedTags`, no
277
299
  datasource skill is announced or searchable, even when configured.
278
300
  `allowedScopes` are opaque slash-hierarchical roots like `/slack/<instance>/**`.
@@ -1,30 +0,0 @@
1
- /**
2
- * Discord guild connector (issue #1305).
3
- *
4
- * Fetches text/announcement channel history through the Discord REST API
5
- * using a trusted, server-configured bot token. Per-channel permission
6
- * failures degrade to warnings; a guild-level 429 fails the whole fetch as
7
- * rate-limited. Never throws; all messages stay path/PII-opaque.
8
- */
9
- import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
- export interface DiscordConnectorOptions {
11
- /** Discord REST base; override to point at a mock server in tests. */
12
- readonly baseUrl?: string;
13
- /** Bot token; explicit value wins over {@link tokenEnv}. */
14
- readonly token?: string;
15
- /** Env var name holding the bot token. Default `DISCORD_BOT_TOKEN`. */
16
- readonly tokenEnv?: string;
17
- /** Guild (server) id to index. Required trusted configuration. */
18
- readonly guildId?: string;
19
- /** Restrict indexing to these channel names or ids. */
20
- readonly channels?: readonly string[];
21
- readonly timeoutMs?: number;
22
- readonly fetchImpl?: typeof fetch;
23
- readonly maxPages?: number;
24
- readonly maxDocuments?: number;
25
- }
26
- export declare class DiscordConnector implements DatasourceConnector {
27
- private readonly options;
28
- constructor(options?: DiscordConnectorOptions);
29
- fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
30
- }
@@ -1,2 +0,0 @@
1
- export { DiscordConnector, type DiscordConnectorOptions } from "./connector.js";
2
- export { DISCORD_SKILL_DEFINITION, DiscordSkill, type DiscordSkillOptions } from "./skill.js";
@@ -1,20 +0,0 @@
1
- /**
2
- * Discord guild datasource skill (issue #1305).
3
- *
4
- * Thin composition of DiscordConnector with the shared
5
- * {@link ConnectorDatasourceSkill} base: descriptor, polling metadata,
6
- * ok/fail indexing with path/PII-opaque diagnostics, lexical retrieval via
7
- * the shared pipeline, opaque `/discord/<instance>/…` sources, and a
8
- * progressive-disclosure agent-skill manifest.
9
- */
10
- import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
11
- import { DiscordConnector, type DiscordConnectorOptions } from "./connector.js";
12
- export declare const DISCORD_SKILL_DEFINITION: ConnectorSkillDefinition;
13
- export interface DiscordSkillOptions extends Omit<ConnectorSkillOptions, "connector"> {
14
- /** Trusted connector configuration; a pre-built connector wins. */
15
- readonly connector?: DiscordConnector;
16
- readonly connectorOptions?: DiscordConnectorOptions;
17
- }
18
- export declare class DiscordSkill extends ConnectorDatasourceSkill {
19
- constructor(options?: DiscordSkillOptions);
20
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Notion workspace connector (issue #1302).
3
- *
4
- * Enumerates pages/databases via the Notion search API using a trusted,
5
- * server-configured integration token, then pulls one page of block children
6
- * per page for text content. Per-page block failures degrade to warnings.
7
- * Never throws; messages stay path/PII-opaque.
8
- */
9
- import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
- export interface NotionConnectorOptions {
11
- /** Notion REST base; override to point at a mock server in tests. */
12
- readonly baseUrl?: string;
13
- /** Integration token; explicit value wins over {@link tokenEnv}. */
14
- readonly token?: string;
15
- /** Env var name holding the integration token. Default `NOTION_TOKEN`. */
16
- readonly tokenEnv?: string;
17
- readonly timeoutMs?: number;
18
- readonly fetchImpl?: typeof fetch;
19
- readonly maxPages?: number;
20
- readonly maxDocuments?: number;
21
- }
22
- export declare class NotionConnector implements DatasourceConnector {
23
- private readonly options;
24
- constructor(options?: NotionConnectorOptions);
25
- fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
26
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Notion workspace datasource skill (issue #1302).
3
- *
4
- * Thin composition of NotionConnector with the shared
5
- * {@link ConnectorDatasourceSkill} base: descriptor, polling metadata,
6
- * ok/fail indexing with path/PII-opaque diagnostics, lexical retrieval via
7
- * the shared pipeline, opaque `/notion/<instance>/…` sources, and a
8
- * progressive-disclosure agent-skill manifest.
9
- */
10
- import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
11
- import { NotionConnector, type NotionConnectorOptions } from "./connector.js";
12
- export declare const NOTION_SKILL_DEFINITION: ConnectorSkillDefinition;
13
- export interface NotionSkillOptions extends Omit<ConnectorSkillOptions, "connector"> {
14
- /** Trusted connector configuration; a pre-built connector wins. */
15
- readonly connector?: NotionConnector;
16
- readonly connectorOptions?: NotionConnectorOptions;
17
- }
18
- export declare class NotionSkill extends ConnectorDatasourceSkill {
19
- constructor(options?: NotionSkillOptions);
20
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Obsidian vault connector (issue #1314).
3
- *
4
- * Walks a trusted, server-configured vault directory for markdown notes,
5
- * extracting frontmatter/inline tags, wiki links, and embeds. No network
6
- * access. Per-file read failures aggregate into a count-only warning;
7
- * absolute paths never appear in warnings (vault-relative segments are the
8
- * vault's own logical hierarchy and are allowed in doc ids).
9
- */
10
- import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
11
- export interface ObsidianConnectorOptions {
12
- /** Absolute path to the vault root. Required trusted configuration. */
13
- readonly vaultPath?: string;
14
- readonly maxDocuments?: number;
15
- /** Files larger than this are skipped. Default 2 MiB. */
16
- readonly maxBytesPerFile?: number;
17
- }
18
- export declare class ObsidianConnector implements DatasourceConnector {
19
- private readonly options;
20
- constructor(options?: ObsidianConnectorOptions);
21
- fetch(): Promise<ConnectorFetchResult>;
22
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Slack workspace connector (issue #1300).
3
- *
4
- * Fetches channel history through the Slack Web API using a trusted,
5
- * server-configured bot token. Never throws; failures map onto the coarse
6
- * connector failure union with path/PII-opaque messages. Per-channel
7
- * failures degrade to warnings so one denied channel cannot fail the fetch.
8
- */
9
- import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
- export interface SlackConnectorOptions {
11
- /** Slack Web API base; override to point at a mock server in tests. */
12
- readonly baseUrl?: string;
13
- /** Bot token; explicit value wins over {@link tokenEnv}. */
14
- readonly token?: string;
15
- /** Env var name holding the bot token. Default `SLACK_BOT_TOKEN`. */
16
- readonly tokenEnv?: string;
17
- /** Restrict indexing to these channel names or ids. */
18
- readonly channels?: readonly string[];
19
- readonly timeoutMs?: number;
20
- readonly fetchImpl?: typeof fetch;
21
- readonly maxPages?: number;
22
- readonly maxDocuments?: number;
23
- }
24
- export declare class SlackConnector implements DatasourceConnector {
25
- private readonly options;
26
- constructor(options?: SlackConnectorOptions);
27
- fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
28
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Slack workspace datasource skill (issue #1300).
3
- *
4
- * Thin composition of SlackConnector with the shared
5
- * {@link ConnectorDatasourceSkill} base: descriptor, polling metadata,
6
- * ok/fail indexing with path/PII-opaque diagnostics, lexical retrieval via
7
- * the shared pipeline, opaque `/slack/<instance>/…` sources, and a
8
- * progressive-disclosure agent-skill manifest.
9
- */
10
- import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
11
- import { SlackConnector, type SlackConnectorOptions } from "./connector.js";
12
- export declare const SLACK_SKILL_DEFINITION: ConnectorSkillDefinition;
13
- export interface SlackSkillOptions extends Omit<ConnectorSkillOptions, "connector"> {
14
- /** Trusted connector configuration; a pre-built connector wins. */
15
- readonly connector?: SlackConnector;
16
- readonly connectorOptions?: SlackConnectorOptions;
17
- }
18
- export declare class SlackSkill extends ConnectorDatasourceSkill {
19
- constructor(options?: SlackSkillOptions);
20
- }