@autorag/librarian 2.2.0 → 2.4.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 (106) hide show
  1. package/README.md +194 -47
  2. package/dist/agent/agent.d.ts +34 -47
  3. package/dist/agent/bash-tool.d.ts +2 -11
  4. package/dist/agent/dupey-tool.d.ts +15 -0
  5. package/dist/agent/emit-results-tool.d.ts +14 -0
  6. package/dist/agent/index.d.ts +1 -0
  7. package/dist/agent/local-model.d.ts +12 -0
  8. package/dist/agent/search-bm25-tool.d.ts +11 -3
  9. package/dist/agent/search-documents.d.ts +2 -2
  10. package/dist/agent/search-minsync-tool.d.ts +2 -2
  11. package/dist/agent/system-prompt.d.ts +1 -2
  12. package/dist/cli/commands/duplicates.d.ts +4 -0
  13. package/dist/cli/commands/health.d.ts +9 -65
  14. package/dist/cli/commands/index.d.ts +3 -3
  15. package/dist/cli/commands/init.d.ts +1 -1
  16. package/dist/cli/commands/search.d.ts +2 -2
  17. package/dist/cli/commands/tui.d.ts +36 -0
  18. package/dist/cli/commands/ui.d.ts +13 -0
  19. package/dist/cli/config.d.ts +27 -22
  20. package/dist/cli/index.js +14965 -12563
  21. package/dist/cli/tui-commands.d.ts +16 -0
  22. package/dist/cli/tui-session-store.d.ts +16 -0
  23. package/dist/datasource/access-context.d.ts +6 -12
  24. package/dist/datasource/aliased-skill.d.ts +28 -0
  25. package/dist/datasource/chunk-store.d.ts +2 -0
  26. package/dist/datasource/connector-skill.d.ts +3 -0
  27. package/dist/datasource/connector.d.ts +4 -0
  28. package/dist/datasource/crawler-skill.d.ts +6 -0
  29. package/dist/datasource/crawler-types.d.ts +2 -0
  30. package/dist/datasource/described-skill.d.ts +17 -0
  31. package/dist/datasource/index.d.ts +4 -2
  32. package/dist/datasource/result-filter.d.ts +2 -1
  33. package/dist/datasource/skills/clawgallery/client.d.ts +9 -0
  34. package/dist/datasource/skills/clawgallery/index.d.ts +5 -0
  35. package/dist/datasource/skills/clawgallery/methods.d.ts +19 -0
  36. package/dist/datasource/skills/clawgallery/paths.d.ts +7 -0
  37. package/dist/datasource/skills/clawgallery/skill.d.ts +35 -0
  38. package/dist/datasource/skills/clawgallery/types.d.ts +58 -0
  39. package/dist/datasource/skills/cloud-drive/index.d.ts +2 -0
  40. package/dist/datasource/skills/cloud-drive/rclone-connector.d.ts +47 -0
  41. package/dist/datasource/skills/cloud-drive/skill.d.ts +14 -0
  42. package/dist/datasource/skills/discrawl/skill.d.ts +3 -0
  43. package/dist/datasource/skills/discrawl/types.d.ts +4 -8
  44. package/dist/datasource/skills/factory.d.ts +9 -0
  45. package/dist/datasource/skills/gmail/himalaya-connector.d.ts +12 -1
  46. package/dist/datasource/skills/katok/methods.d.ts +6 -4
  47. package/dist/datasource/skills/katok/types.d.ts +8 -26
  48. package/dist/datasource/skills/mailcrawl/client.d.ts +15 -0
  49. package/dist/datasource/skills/mailcrawl/config.d.ts +2 -0
  50. package/dist/datasource/skills/mailcrawl/index.d.ts +4 -0
  51. package/dist/datasource/skills/mailcrawl/methods.d.ts +15 -0
  52. package/dist/datasource/skills/mailcrawl/skill.d.ts +34 -0
  53. package/dist/datasource/skills/mailcrawl/types.d.ts +71 -0
  54. package/dist/datasource/skills/obsidian/skill.d.ts +2 -0
  55. package/dist/datasource/skills/obsidian/types.d.ts +2 -0
  56. package/dist/datasource/types.d.ts +5 -2
  57. package/dist/dupey/cli.d.ts +40 -0
  58. package/dist/dupey/filter.d.ts +8 -0
  59. package/dist/dupey/index.d.ts +2 -0
  60. package/dist/filesystem/cloud-placeholder.d.ts +26 -0
  61. package/dist/index.d.ts +1 -0
  62. package/dist/index.js +8889 -9292
  63. package/dist/jikji/client.d.ts +1 -0
  64. package/dist/memory/check-memory-tool.d.ts +1 -0
  65. package/dist/memory/index.d.ts +2 -2
  66. package/dist/memory/memory.d.ts +33 -3
  67. package/dist/memory/renderer.d.ts +2 -1
  68. package/dist/minsync/client.d.ts +5 -1
  69. package/dist/minsync/embedder-config.d.ts +4 -1
  70. package/dist/minsync/index.d.ts +4 -4
  71. package/dist/minsync/installer.d.ts +1 -0
  72. package/dist/minsync/method.d.ts +22 -1
  73. package/dist/minsync/types.d.ts +5 -0
  74. package/dist/mirror/sync.d.ts +3 -1
  75. package/dist/observability/run-log.d.ts +1 -26
  76. package/dist/parser/defaults.d.ts +2 -0
  77. package/dist/parser/index.d.ts +2 -2
  78. package/dist/parser/opendataloader-pdf.d.ts +10 -0
  79. package/dist/parser/types.d.ts +7 -0
  80. package/dist/process/portable-spawn.d.ts +10 -0
  81. package/dist/retrieval/index.d.ts +2 -2
  82. package/dist/retrieval/methods/bm25.d.ts +7 -36
  83. package/dist/ui/browse.d.ts +11 -0
  84. package/dist/ui/catalog.d.ts +59 -0
  85. package/dist/ui/config-store.d.ts +43 -0
  86. package/dist/ui/discover.d.ts +19 -0
  87. package/dist/ui/html.d.ts +2 -0
  88. package/dist/ui/probe.d.ts +24 -0
  89. package/dist/ui/prompt.d.ts +21 -0
  90. package/dist/ui/server.d.ts +28 -0
  91. package/package.json +17 -15
  92. package/skills/autorag/SKILL.md +79 -108
  93. package/skills/autorag-setup/SKILL.md +170 -395
  94. package/dist/datasource/skills/discrawl/config.d.ts +0 -9
  95. package/dist/datasource/skills/gdrive/connector.d.ts +0 -30
  96. package/dist/datasource/skills/gdrive/index.d.ts +0 -3
  97. package/dist/datasource/skills/gdrive/rclone-connector.d.ts +0 -51
  98. package/dist/datasource/skills/gdrive/skill.d.ts +0 -24
  99. package/dist/subagents/contracts.d.ts +0 -90
  100. package/dist/subagents/dispatch-templates.d.ts +0 -104
  101. package/dist/subagents/dispatch-validation.d.ts +0 -169
  102. package/dist/subagents/explorer-tools-extension.d.ts +0 -4
  103. package/dist/subagents/explorer-tools-extension.js +0 -130
  104. package/dist/subagents/local-models.d.ts +0 -14
  105. package/dist/subagents/model-policy.d.ts +0 -31
  106. package/dist/subagents/runtime.d.ts +0 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorag/librarian",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Self-evolving librarian agent on Pi framework with pluggable retrieval methods",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,39 +28,41 @@
28
28
  "access": "public"
29
29
  },
30
30
  "scripts": {
31
- "build": "bun build src/index.ts src/cli/index.ts src/subagents/explorer-tools-extension.ts --outdir dist --target node --packages external && tsc -p tsconfig.build.json && node scripts/fixup-dts.mjs",
31
+ "build": "bun build src/index.ts src/cli/index.ts --outdir dist --target node --packages external && tsc -p tsconfig.build.json && node scripts/fixup-dts.mjs",
32
32
  "prepublishOnly": "bun run typecheck && bun run build",
33
33
  "prepare": "bun run build",
34
- "test": "vitest run",
34
+ "test": "node scripts/run-test-files.mjs",
35
+ "test:windows": "node scripts/run-test-files.mjs",
35
36
  "check": "biome check --write .",
37
+ "lint": "biome check .",
36
38
  "typecheck": "tsc --noEmit"
37
39
  },
38
40
  "engines": {
39
41
  "node": ">=24.0.0"
40
42
  },
41
43
  "dependencies": {
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
- "@pngwasi/node-tantivy-binding": "^0.3.4",
44
+ "@earendil-works/pi-agent-core": "^0.84.4",
45
+ "@earendil-works/pi-ai": "^0.84.4",
46
+ "@earendil-works/pi-coding-agent": "0.84.4",
47
+ "@earendil-works/pi-tui": "0.84.4",
48
+ "@opendataloader/pdf": "^2.5.7",
47
49
  "@rhwp/core": "0.8.4",
48
50
  "chardet": "^2.2.0",
49
- "fast-xml-parser": "^5.11.0",
51
+ "fast-xml-parser": "^5.11.1",
50
52
  "iconv-lite": "^0.7.3",
51
53
  "jszip": "^3.10.1",
52
- "mailparser": "^3.9.15",
53
- "pi-subagents": "0.53.0",
54
- "slides-grab": "^1.5.0",
54
+ "mailparser": "^3.9.20",
55
+ "slides-grab": "^1.5.1",
55
56
  "smol-toml": "1.8.0",
56
57
  "tesseract.js": "^7.0.0",
57
- "typebox": "^1.3.16",
58
+ "typebox": "^1.3.25",
59
+ "xlsx": "^0.18.5",
58
60
  "yaml": "^2.9.0"
59
61
  },
60
62
  "devDependencies": {
61
- "@biomejs/biome": "2.5.9",
63
+ "@biomejs/biome": "2.5.12",
62
64
  "@types/mailparser": "^3.4.6",
63
- "@types/node": "^26.2.0",
65
+ "@types/node": "^26.4.1",
64
66
  "typescript": "^7.0.2",
65
67
  "vitest": "^4.1.11"
66
68
  }
@@ -1,149 +1,120 @@
1
1
  ---
2
2
  name: autorag
3
- description: Use an already configured AutoRAG librarian agent to search, summarize, compare, and answer questions from local document collections. Use autorag-setup instead for provider/model discovery, first-time configuration, or selecting folders to index.
3
+ description: Search, summarize, compare, and answer questions from an already configured AutoRAG librarian over local documents and authorized datasources. Use when the user asks AutoRAG to search PDFs, wikis, notes, or a knowledge base. Use autorag-setup for install, model, roots, indexing, or datasource changes.
4
+ license: MIT
4
5
  ---
5
6
 
6
7
  # AutoRAG Librarian Skill
7
8
 
8
9
  Use this skill when AutoRAG is already configured and the user asks to search,
9
10
  summarize, compare, or answer questions from local PDFs, wikis, notes, research
10
- papers, or knowledge bases. For first-time configuration, missing model/provider
11
- settings, subscription or API-provider detection, or changing indexed folders,
12
- use the `autorag-setup` skill instead.
11
+ papers, knowledge bases, or authorized datasources.
13
12
 
14
- AutoRAG is invoked through the `autorag` CLI. It is non-destructive: it reads
15
- source files and writes indexes under the configured workspace's `.autorag/`
16
- directory and, when enabled, Jikji's per-source `.jikji/` caches. Never move,
17
- rename, or delete source files.
13
+ AutoRAG is the specialized librarian agent. One configured model plans the
14
+ search, calls BM25, MinSync, Jikji, datasource, and filesystem tools, reads
15
+ sources, judges evidence, and curates the final answer. There is no subagent or
16
+ separate model role.
17
+
18
+ AutoRAG reads source documents and writes indexes only under the configured
19
+ workspace `.autorag/` directory and Jikji's per-source `.jikji/` caches. Never
20
+ move, rename, edit, or delete source files.
18
21
 
19
22
  ## Preflight
20
23
 
21
- Confirm that `~/.autorag/config.json` exists (or an explicit `--config` /
22
- `AUTORAG_CONFIG` path). Inspect that non-secret config for usable
23
- `searchPaths`/`agents` without printing credentials. Then run:
24
+ Confirm a config exists at `--config`, `AUTORAG_CONFIG`,
25
+ `$AUTORAG_HOME/config.json`, or `~/.autorag/config.json`. Inspect only
26
+ non-secret `searchPaths` and `model` metadata, then run:
24
27
 
25
28
  ```bash
26
- autorag status
27
- autorag health
29
+ autorag duplicates --json
30
+ autorag status --json
31
+ autorag health --json
28
32
  ```
29
33
 
30
- `status` is model-free and path-opaque: it reports corpus freshness and index
31
- health, not absolute filesystem paths or role-model auth. `health` checks
32
- model/provider auth and explorer subagent setup: it resolves both role models,
33
- verifies credential presence, and (unless `--skip-probes`) probes a completion
34
- call per role. Use `health` to diagnose model, provider, auth, timeout, or
35
- subagent dispatch failures before searching. If configuration, authentication,
36
- role models, or indexes are missing or unhealthy, stop this workflow and use
37
- `autorag-setup`; do not guess private providers or model IDs.
34
+ ### Duplicate-file review
35
+
36
+ Use `autorag duplicates` when the user asks to find duplicate files, choose
37
+ likely latest copies, or reduce corpus/index space. The command and the
38
+ `scan_duplicate_documents` Agent tool are read-only and never delete or move
39
+ source files. Exact means dupey's canonical extracted-text hash matches;
40
+ near/contains families require human review. Exact duplicate exclusion during
41
+ refresh is enabled by default and can be disabled with
42
+ `"excludeExactDuplicates": false` in `config.json`.
43
+
44
+ `status` is model-free and path-opaque. `health` resolves the single model,
45
+ checks credential presence, and normally probes one live completion. If the
46
+ model, authentication, configuration, or indexes are unhealthy, use
47
+ `autorag-setup` rather than guessing private provider details.
38
48
 
39
- ## Searching
49
+ BM25, MinSync, and Jikji should normally be healthy. MinSync and Jikji
50
+ auto-install on first use by default. If they are missing or stale, run a full
51
+ `autorag refresh` or return to setup rather than silently degrading to
52
+ lexical-only search.
53
+
54
+ ## Search
55
+
56
+ Prefer `--json --debug` when another agent will consume the result or record
57
+ feedback. `--json` alone omits `sessionId`. `--debug` adds session/diagnostics
58
+ fields and does not print filesystem paths.
40
59
 
41
60
  ```bash
42
- autorag search "what were the key findings in the Q3 report" --top-k 5
61
+ autorag search "what were the key findings in the Q3 report" --top-k 5 --json --debug
43
62
  ```
44
63
 
45
- AutoRAG returns curated, numbered knowledge units grounded in sources plus a
46
- `sessionId` needed for feedback. Use:
64
+ `--json --debug` includes `answer`, numbered `results` (`number`, `title`,
65
+ `summary`, optional `source`), and `sessionId`. Use that `sessionId` for
66
+ feedback. `--json` without `--debug` is only `answer` plus `results`.
47
67
 
48
- - `--scope` to narrow to a configured virtual sub-path
49
- - `--tags tag1,tag2` only when trusted datasource access is already configured
50
- server-side; tags narrow already-allowed results and never grant new access
51
- - `--json` for structured output (`sessionId`, numbered `results`, `answer`)
52
- - `--debug` only when diagnostics are needed
68
+ - `--scope` narrows datasource retrieval to a requested sub-path; it cannot
69
+ grant access.
70
+ - `--tags` further narrows already-authorized datasource results and never
71
+ grants new access.
72
+ - `--json` is required for programmatic consumption.
73
+ - `--debug` is required for `sessionId`, evidence, and diagnostics.
53
74
 
54
- Do not bypass AutoRAG with ad hoc raw search when the user explicitly requested
55
- the librarian agent. Search requires a resolvable orchestrator/explorer model
56
- pair from config, flags, env, or the authenticated local runtime. When `autorag
57
- search` fails for a model, provider, auth, timeout, or subagent reason, the
58
- error output includes a hint pointing to `autorag health` for diagnosis.
75
+ 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
77
+ direct source reading as appropriate. If search fails because of model,
78
+ provider, auth, or timeout problems, diagnose with `autorag health --json`.
59
79
 
60
- Record feedback so retrieval memory learns which results were useful:
80
+ Record feedback so retrieval memory can learn. Numbers refer to the returned
81
+ knowledge units. Supply at least one feedback list:
61
82
 
62
83
  ```bash
63
- autorag feedback <sessionId> --useful 1,3 --not-useful 2
84
+ autorag feedback <sessionId> --useful 1,3 --not-useful 2 --json
64
85
  ```
65
86
 
66
- Supply at least one of `--useful` or `--not-useful`. Numbers refer to the
67
- numbered knowledge units from that session's search output.
68
-
69
87
  ## Maintenance
70
88
 
71
89
  ```bash
72
- autorag status
73
- autorag health
74
- autorag refresh
75
- autorag refresh --method bm25,minsync
76
- autorag watch --once
90
+ autorag status --json
91
+ autorag health --json
92
+ autorag refresh --json
93
+ autorag refresh --method bm25,minsync,jikji --json
94
+ autorag watch --once --json
77
95
  autorag watch
78
- autorag refresh --force
79
- autorag index rebuild --yes
80
- autorag index reset --method bm25 --yes
81
- autorag memory inspect
96
+ autorag refresh --force --json
97
+ autorag index rebuild --yes --json
98
+ autorag index reset --method bm25 --yes --json
99
+ autorag memory inspect --json
82
100
  ```
83
101
 
84
- Use `refresh` after source documents change (parses sources and resyncs BM25 /
85
- MinSync / datasources / optional Jikji prepare). Prefer bounded refresh over
86
- reset. `watch --once` is the preferred single tick for scheduled jobs; long-running
87
- `watch` keeps an fs event loop open for interactive sessions.
88
- `--method <csv>` (e.g. `--method bm25,minsync,parsed`) restricts which methods
89
- refresh/index run; when omitted all methods run. BM25 and MinSync are enabled
90
- by default — no explicit configuration is needed for standard lexical + semantic
91
- retrieval. MinSync uses a pre-installed binary (`autoInstall: false`); configure
92
- `minSync.embedder` via `autorag init --embedder-*` flags for remote embedding.
93
-
94
- ### Keep indexes fresh on a schedule (agent responsibility)
95
-
96
- There is **no always-on network service** in the CLI. Agents and operators must
97
- install an OS-appropriate periodic job that runs a model-free index tick:
98
-
99
- ```bash
100
- # Preferred scheduled command (single non-daemon refresh)
101
- NODE_OPTIONS=--max-old-space-size=16384 autorag watch --once
102
- # Equivalent one-shot refresh
103
- NODE_OPTIONS=--max-old-space-size=16384 autorag refresh
104
- ```
102
+ Prefer a full refresh so parsed mirrors, BM25, MinSync, Jikji, and configured
103
+ datasources stay aligned. `--method` accepts
104
+ `parsed,bm25,minsync,datasources,jikji,all`. Use it only for deliberate
105
+ narrowing. Scheduled maintenance should use non-daemon `autorag watch --once`,
106
+ typically every 15–30 minutes, with the same config used by search and no
107
+ overlapping runs.
105
108
 
106
- Schedule guidance by OS (typical interval: every 15–30 minutes; never more often
107
- than the corpus can finish refreshing):
108
-
109
- | OS | Preferred scheduler | Pattern |
110
- |---|---|---|
111
- | macOS | `cron` or `launchd` (`~/Library/LaunchAgents`) | `*/30 * * * * ... autorag watch --once` or a KeepAlive=false StartInterval plist |
112
- | Linux | `cron` / `systemd --user` timer | crontab `*/30 * * * *` or a oneshot service + timer |
113
- | Windows | Task Scheduler | repeating task every 30 minutes running `autorag watch --once` under the user profile |
114
-
115
- Rules for scheduled watch:
116
-
117
- 1. Prefer `autorag watch --once` (or `autorag refresh`) over a permanent
118
- long-running `autorag watch` daemon in user agents — daemons die on reboot
119
- and are harder to supervise from skill workflows.
120
- 2. Use the same config the search path uses (`~/.autorag/config.json` or an
121
- explicit `--config` / `AUTORAG_CONFIG`).
122
- 3. Raise Node heap for large home trees: `NODE_OPTIONS=--max-old-space-size=16384`.
123
- 4. Redirect logs somewhere under the home/user temp tree, never into source
124
- document folders.
125
- 5. After install/setup, **create or verify** the scheduled job before claiming
126
- ongoing indexing is covered. Re-check with `crontab -l`, `systemctl --user list-timers`,
127
- or Task Scheduler inspection when the user asks about freshness.
128
- 6. Do not schedule concurrent overlapping ticks; if a prior refresh is still
129
- running, skip or wait (lock/log rather than stampeding MiniSync/BM25 writers).
130
-
131
- Destructive index commands:
132
-
133
- - `autorag index reset --yes` removes parsed, BM25, and MinSync directories under
134
- workspace `.autorag` only. Add `--method bm25|minsync|parsed` to scope which
135
- indexes are removed (e.g. `--method bm25` removes only the BM25 index).
136
- - `autorag index rebuild --yes` resets those indexes then forced-refreshes.
137
- `--method` scopes both the reset and the rebuild refresh.
138
-
139
- Never run reset/rebuild against source documents. `memory inspect` is
140
- read-only and path-opaque.
109
+ Reset and rebuild commands remove only selected workspace `.autorag` indexes.
110
+ Never target source documents. `memory inspect` is read-only and path-opaque.
141
111
 
142
112
  ## Rules
143
113
 
144
114
  - Use only configured and approved search paths.
145
115
  - Never expose provider credentials or authentication payloads.
146
- - Never invent or reveal private provider names or model IDs.
147
- - Never treat a consumer subscription as API access without runtime evidence.
116
+ - Never invent provider identities or model ids.
117
+ - A Pi-usable subscription is valid; a subscription Pi cannot invoke is not.
148
118
  - Preserve real source mapping and numbered feedback identifiers.
149
- - Prefer `--json` when another agent must consume the result programmatically.
119
+ - Prefer `--json --debug` when another agent consumes search output or will
120
+ call `autorag feedback`.