@autorag/librarian 2.4.2 → 2.5.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.
- package/NOTICE +68 -0
- package/README.md +77 -32
- package/dist/agent/agent.d.ts +73 -1
- package/dist/agent/fast-answer-tool.d.ts +46 -0
- package/dist/agent/peer-target-tool.d.ts +19 -0
- package/dist/agent/search-all-tool.d.ts +3 -0
- package/dist/agent/search-datasource-tool.d.ts +3 -0
- package/dist/agent/search-documents.d.ts +50 -5
- package/dist/agent/search-minsync-tool.d.ts +3 -0
- package/dist/agent/system-prompt.d.ts +1 -0
- package/dist/cli/command-help.d.ts +1 -0
- package/dist/cli/commands/gateway.d.ts +7 -0
- package/dist/cli/commands/lite-retrieve.d.ts +9 -0
- package/dist/cli/commands/models.d.ts +18 -0
- package/dist/cli/commands/p2p-policy.d.ts +2 -0
- package/dist/cli/commands/p2p.d.ts +7 -0
- package/dist/cli/commands/serve.d.ts +18 -0
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/commands/tui.d.ts +1 -1
- package/dist/cli/config.d.ts +20 -0
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +13892 -8650
- package/dist/cli/output.d.ts +6 -0
- package/dist/cli/setup.d.ts +61 -0
- package/dist/core.js +4965 -1385
- package/dist/datasource/connector-skill.d.ts +1 -1
- package/dist/datasource/connector.d.ts +1 -1
- package/dist/datasource/index.d.ts +1 -2
- package/dist/datasource/skills/discrawl/client.d.ts +12 -2
- package/dist/datasource/skills/discrawl/index.d.ts +1 -1
- package/dist/datasource/skills/discrawl/skill.d.ts +2 -1
- package/dist/datasource/skills/discrawl/types.d.ts +29 -21
- package/dist/datasource/skills/factory.d.ts +2 -1
- package/dist/datasource/skills/katok/client.d.ts +4 -7
- package/dist/datasource/skills/katok/types.d.ts +1 -6
- package/dist/embedding-runtime/cache.d.ts +21 -0
- package/dist/embedding-runtime/gateway.d.ts +27 -0
- package/dist/embedding-runtime/index.d.ts +120 -0
- package/dist/embedding-runtime/manifest.d.ts +24 -0
- package/dist/embedding-runtime/supervisor.d.ts +74 -0
- package/dist/embedding-runtime/types.d.ts +66 -0
- package/dist/filesystem/source-paths.d.ts +33 -2
- package/dist/index.js +4974 -1389
- package/dist/minsync/client.d.ts +25 -1
- package/dist/minsync/embedder-config.d.ts +15 -0
- package/dist/minsync/index.d.ts +4 -3
- package/dist/minsync/installer.d.ts +1 -1
- package/dist/minsync/local-embedder.d.ts +16 -0
- package/dist/minsync/method.d.ts +5 -0
- package/dist/minsync/types.d.ts +15 -0
- package/dist/minsync/workspace.d.ts +6 -0
- package/dist/mirror/index-store.d.ts +17 -0
- package/dist/mirror/sync.d.ts +8 -4
- package/dist/observability/run-log.d.ts +2 -0
- package/dist/p2p/approval-store.d.ts +31 -0
- package/dist/p2p/egress-gate.d.ts +22 -0
- package/dist/p2p/file-sharing.d.ts +33 -0
- package/dist/p2p/injection-classifier.d.ts +33 -0
- package/dist/p2p/injection-gate.d.ts +37 -0
- package/dist/p2p/pii-gate.d.ts +47 -0
- package/dist/p2p/policy-filter.d.ts +15 -0
- package/dist/p2p/policy.d.ts +77 -0
- package/dist/p2p/simplex-server.d.ts +95 -0
- package/dist/p2p/simplex-transport.d.ts +38 -0
- package/dist/p2p/wire.d.ts +39 -0
- package/dist/process/terminate-tree.d.ts +20 -0
- package/licenses/apache-2.0.txt +202 -0
- package/licenses/embedding-assets.json +104 -0
- package/licenses/gemma-notice.txt +24 -0
- package/licenses/gemma-section-3.2-flow-down.txt +9 -0
- package/licenses/gemma-terms-of-use.html +4750 -0
- package/licenses/gemma-terms-of-use.txt +158 -0
- package/licenses/llama.cpp-MIT.txt +21 -0
- package/licenses/qwen3-embedding-notice.txt +13 -0
- package/package.json +15 -10
- package/skills/autorag/SKILL.md +18 -6
- package/skills/autorag-lite-search/SKILL.md +24 -6
- package/skills/autorag-lite-setup/SKILL.md +10 -2
- package/skills/autorag-setup/SKILL.md +7 -9
- package/dist/datasource/skills/gmail/connector.d.ts +0 -30
- package/dist/datasource/skills/gmail/index.d.ts +0 -2
- package/dist/datasource/skills/gmail/skill.d.ts +0 -24
package/NOTICE
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
AutoRAG
|
|
2
|
+
Copyright (c) 2025 NomaDamas / Marker Inc.
|
|
3
|
+
|
|
4
|
+
Root package license: MIT
|
|
5
|
+
legacy/ package license: Apache-2.0
|
|
6
|
+
|
|
7
|
+
Third-party production dependencies:
|
|
8
|
+
|
|
9
|
+
@earendil-works/pi-agent-core@0.85.1
|
|
10
|
+
License: MIT
|
|
11
|
+
|
|
12
|
+
@earendil-works/pi-ai@0.85.1
|
|
13
|
+
License: MIT
|
|
14
|
+
|
|
15
|
+
@earendil-works/pi-coding-agent@0.85.1
|
|
16
|
+
License: MIT
|
|
17
|
+
|
|
18
|
+
@earendil-works/pi-tui@0.85.1
|
|
19
|
+
License: MIT
|
|
20
|
+
|
|
21
|
+
@opendataloader/pdf@2.5.7
|
|
22
|
+
License: Apache-2.0
|
|
23
|
+
|
|
24
|
+
@rhwp/core@0.8.6
|
|
25
|
+
License: MIT
|
|
26
|
+
|
|
27
|
+
chardet@2.2.0
|
|
28
|
+
License: MIT
|
|
29
|
+
|
|
30
|
+
fast-xml-parser@5.11.1
|
|
31
|
+
License: MIT
|
|
32
|
+
|
|
33
|
+
iconv-lite@0.7.3
|
|
34
|
+
License: MIT
|
|
35
|
+
|
|
36
|
+
jszip@3.10.1
|
|
37
|
+
License: (MIT OR GPL-3.0-or-later)
|
|
38
|
+
|
|
39
|
+
mailparser@3.9.20
|
|
40
|
+
License: MIT
|
|
41
|
+
|
|
42
|
+
slides-grab@1.5.1
|
|
43
|
+
License: MIT
|
|
44
|
+
|
|
45
|
+
smol-toml@1.8.0
|
|
46
|
+
License: BSD-3-Clause
|
|
47
|
+
|
|
48
|
+
tesseract.js@7.0.0
|
|
49
|
+
License: Apache-2.0
|
|
50
|
+
|
|
51
|
+
typebox@1.3.25
|
|
52
|
+
License: MIT
|
|
53
|
+
|
|
54
|
+
xlsx@0.18.5
|
|
55
|
+
License: Apache-2.0
|
|
56
|
+
|
|
57
|
+
yaml@2.9.0
|
|
58
|
+
License: ISC
|
|
59
|
+
|
|
60
|
+
Embedding runtime and model notices:
|
|
61
|
+
licenses/llama.cpp-MIT.txt
|
|
62
|
+
licenses/qwen3-embedding-notice.txt
|
|
63
|
+
licenses/apache-2.0.txt
|
|
64
|
+
licenses/gemma-notice.txt
|
|
65
|
+
licenses/gemma-section-3.2-flow-down.txt
|
|
66
|
+
licenses/gemma-terms-of-use.txt
|
|
67
|
+
licenses/gemma-terms-of-use.html
|
|
68
|
+
licenses/embedding-assets.json
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Three principles drive every design decision:
|
|
|
24
24
|
stores (katok, discrawl, qmd, msgvault, rclone, …) in place. No forced
|
|
25
25
|
ingestion into a central index, no third-party server holding a copy of
|
|
26
26
|
your corpus. Results carry source-native identities
|
|
27
|
-
(
|
|
27
|
+
(`/kakao/<instance>/chunks/<chunk>`) with scope-checked access — see the
|
|
28
28
|
[competitive landscape study](docs/competitive-landscape-2026-09.md) for
|
|
29
29
|
why this is the durable differentiator.
|
|
30
30
|
2. **Just works — no RAG degree required.** Install it and it works: minimal
|
|
@@ -200,7 +200,7 @@ Datasource skills let AutoRAG search external, server-configured data sources th
|
|
|
200
200
|
|
|
201
201
|
Every datasource can be registered multiple times through a connection alias:
|
|
202
202
|
use the config key as the unique name and set `type` to the reusable backend
|
|
203
|
-
(`
|
|
203
|
+
(`mailcrawl`, `github`, `slack`, `discord`, `kakao`, `cloud-drive`, and so on).
|
|
204
204
|
Each alias becomes an independently loadable agent skill with its own source
|
|
205
205
|
scope and workspace namespace. Chat aliases search all channels by default;
|
|
206
206
|
trusted `channels.ids` / `channels.names` allowlists can expose a particular
|
|
@@ -224,11 +224,12 @@ Security defaults are intentionally strict:
|
|
|
224
224
|
| Notion | `notion` | external [`notcrawl`](https://github.com/openclaw/notcrawl) CLI | local-first page/database/block archive + FTS5 search |
|
|
225
225
|
| GitHub Issues/PRs | `github` | GitHub REST (token optional) | issues + PR bodies per `owner/repo`; public repos work unauthenticated |
|
|
226
226
|
| Cloud drives | `cloud-drive` | **[`rclone`](https://rclone.org) CLI** | Incremental Google Drive Tier-1; OneDrive/network remotes; iCloud experimental |
|
|
227
|
-
| Gmail | `gmail` | Gmail REST v1 | OAuth access token is referenced by environment variable name |
|
|
228
227
|
| Local mail exports | `mail-export` | filesystem (`.mbox` / `.eml`) | classic `From_` splitting, mailparser-based; count-only warnings |
|
|
229
228
|
| Mail archives | `mailcrawl` | external [`mailcrawl`](https://github.com/NomaDamas/mailcrawl) CLI | local email sync plus BM25, semantic, and hybrid retrieval |
|
|
230
229
|
| Obsidian vault | `obsidian` | external [`qmd`](https://github.com/tobi/qmd) CLI | incremental `qmd update`, BM25 `qmd search`, semantic `qmd vsearch`; vault path via `connector.vaultPath` |
|
|
231
230
|
| RSS / news | `rss` | HTTP feed polling | RSS 2.0 + Atom, feed/category hierarchy, 24h dedupe window |
|
|
231
|
+
| ClawGallery | `clawgallery` | external `clawgallery` CLI (`cargo install clawgallery`) | local screenshots and photos; incremental bootstrap + hybrid search |
|
|
232
|
+
| macOS Spotlight | `spotlight` | built-in `mdfind` | macOS only; no extra install; Full Disk Access for protected files |
|
|
232
233
|
|
|
233
234
|
Connector-backed skills fetch documents into AutoRAG's local chunk store. External-crawler skills such as KakaoTalk, WhatsApp, Telegram, Slack, and Notion leave incremental archive and FTS ownership with their CLI and map query results into the same retrieval pipeline. Obsidian uses the external `qmd` CLI (incremental update + BM25 + semantic). Tokens are referenced by environment variable name only, never stored in config. Process/API failures surface as path/PII-opaque diagnostics. See [docs/manual-qa-datasources.md](docs/manual-qa-datasources.md) for the QA harnesses.
|
|
234
235
|
|
|
@@ -242,7 +243,6 @@ Configure them in `config.json` (CLI) or pass `datasourceSkills` programmaticall
|
|
|
242
243
|
"slack": { "connector": { "binaryPath": "slacrawl", "configPath": "/path/to/slacrawl.yaml", "syncSource": "primary" } },
|
|
243
244
|
"notion": { "connector": { "binaryPath": "notcrawl", "configPath": "/path/to/notcrawl.yaml" } },
|
|
244
245
|
"github": { "connector": { "repos": ["owner/repo"] } },
|
|
245
|
-
"gmail": { "connector": { "tokenEnv": "GMAIL_ACCESS_TOKEN", "labelIds": ["INBOX"] } },
|
|
246
246
|
"mailcrawl": { "instanceId": "personal", "connector": { "account": "personal", "mailbox": "INBOX", "binaryPath": "mailcrawl" } },
|
|
247
247
|
"personal-google-drive": { "type": "cloud-drive", "instanceId": "personal", "connector": { "provider": "google-drive", "remote": "personal-gdrive:", "include": ["**/*.md"] } },
|
|
248
248
|
"company-onedrive": { "type": "cloud-drive", "instanceId": "work", "connector": { "provider": "onedrive", "remote": "company-onedrive:Documents" } },
|
|
@@ -250,8 +250,8 @@ Configure them in `config.json` (CLI) or pass `datasourceSkills` programmaticall
|
|
|
250
250
|
"rss": { "connector": { "feeds": [{ "url": "https://example.com/feed.xml" }] } }
|
|
251
251
|
},
|
|
252
252
|
"datasourceAccess": {
|
|
253
|
-
"allowedTags": ["whatsapp", "telegram", "slack", "notion", "github", "
|
|
254
|
-
"allowedScopes": ["/whatsapp/**", "/telegram/**", "/slack/**", "/notion/**", "/github/**", "/
|
|
253
|
+
"allowedTags": ["whatsapp", "telegram", "slack", "notion", "github", "mailcrawl", "cloud-drive", "obsidian", "rss"],
|
|
254
|
+
"allowedScopes": ["/whatsapp/**", "/telegram/**", "/slack/**", "/notion/**", "/github/**", "/mailcrawl/**", "/personal-google-drive/**", "/company-onedrive/**", "/obsidian/**", "/rss/**"]
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
```
|
|
@@ -262,19 +262,18 @@ Install telecrawl with `brew install openclaw/tap/telecrawl`. AutoRAG invokes `t
|
|
|
262
262
|
|
|
263
263
|
Install slacrawl with `brew install openclaw/tap/slacrawl`. AutoRAG invokes `slacrawl sync` during datasource refresh and `slacrawl --json search` during retrieval. Optional trusted connector fields are `binaryPath`, `configPath`, and `syncSource`. Slack credentials and source definitions remain in slacrawl's own configuration rather than AutoRAG.
|
|
264
264
|
|
|
265
|
-
Install notcrawl with `brew install openclaw/tap/notcrawl`. AutoRAG invokes `notcrawl sync` during datasource refresh and `notcrawl search
|
|
265
|
+
Install notcrawl with `brew install openclaw/tap/notcrawl`. AutoRAG invokes `notcrawl sync` during datasource refresh and `notcrawl search` during retrieval (notcrawl has no `--json` flag through v0.6.2; AutoRAG parses its tab-separated hits). Optional trusted connector fields are `binaryPath` and `configPath`. Notion credentials and workspace definitions remain in notcrawl's own configuration rather than AutoRAG.
|
|
266
266
|
|
|
267
267
|
Install and configure [`mailcrawl`](https://github.com/NomaDamas/mailcrawl)
|
|
268
|
-
`@nomadamas/mailcrawl@0.1.
|
|
268
|
+
`@nomadamas/mailcrawl@0.1.6` or newer separately (0.1.4 is the minimum). AutoRAG invokes
|
|
269
269
|
`mailcrawl sync` followed by `mailcrawl index` during datasource refresh, then
|
|
270
270
|
calls `mailcrawl search` in BM25, semantic, or hybrid mode. The archive remains
|
|
271
271
|
in mailcrawl's native store unless the operator explicitly sets
|
|
272
272
|
`connector.dataDir`; Himalaya credentials and provider configuration remain
|
|
273
273
|
owned by mailcrawl. 0.1.3 and earlier fail a repeated
|
|
274
274
|
`index` after a no-op sync.
|
|
275
|
-
Use `mailcrawl` for
|
|
276
|
-
`gmail`
|
|
277
|
-
that configuration to an explicit `mailcrawl` datasource.
|
|
275
|
+
Use `mailcrawl` for Gmail, IMAP, and Maildir retrieval. The former Gmail REST
|
|
276
|
+
datasource and `gmail` + `backend: "himalaya"` connector are removed.
|
|
278
277
|
|
|
279
278
|
Install and authenticate rclone separately (`brew install rclone && rclone
|
|
280
279
|
config` on macOS), then configure the provider-neutral `cloud-drive` skill.
|
|
@@ -324,13 +323,13 @@ Discord uses the external [`discrawl`](https://github.com/openclaw/discrawl) CLI
|
|
|
324
323
|
brew install openclaw/tap/discrawl
|
|
325
324
|
```
|
|
326
325
|
|
|
327
|
-
|
|
326
|
+
AutoRAG reads discrawl's own local archive: `discrawl wiretap` imports the Discord Desktop cache and needs **no token at all**, and every search, embed, and sync step runs against that native store. AutoRAG carries no Discord credential — no bot token, no credential env var, no credential check in `autorag setup` — and it refuses to spawn the CLI when a Discord *user* token is present in the environment, because automating a user account violates Discord's Community Guidelines and can get the account terminated. A bot-backed archive is the CLI's own concern: configure and sync it with `discrawl` itself.
|
|
328
327
|
|
|
329
328
|
```typescript
|
|
330
329
|
import { AutoRAGAgent, DiscrawlClient, DiscrawlSkill } from "@autorag/librarian";
|
|
331
330
|
|
|
332
331
|
const discord = new DiscrawlSkill({
|
|
333
|
-
client: new DiscrawlClient({
|
|
332
|
+
client: new DiscrawlClient({ root: process.cwd() }),
|
|
334
333
|
instanceId: "community",
|
|
335
334
|
});
|
|
336
335
|
|
|
@@ -351,7 +350,6 @@ Or through the trusted config factory:
|
|
|
351
350
|
"discord": {
|
|
352
351
|
"instanceId": "community",
|
|
353
352
|
"connector": {
|
|
354
|
-
"source": "wiretap",
|
|
355
353
|
"embeddingProvider": "ollama",
|
|
356
354
|
"embeddingModel": "embeddinggemma",
|
|
357
355
|
"defaultMode": "hybrid"
|
|
@@ -412,7 +410,9 @@ Config path precedence is `--config` > `AUTORAG_CONFIG` > `~/.autorag/config.jso
|
|
|
412
410
|
|
|
413
411
|
`memory.json` stores retrieval memory and `logs/runs.jsonl` records run events. Model authentication remains with the user's configured provider or authenticated local runtime. Corpus indexes remain workspace-local: refresh keeps parsed mirrors and BM25/MinSync indexes under `<workspace>/.autorag`.
|
|
414
412
|
|
|
415
|
-
`autorag refresh` and `autorag index reset|rebuild` accept `--method <csv>` (e.g. `--method
|
|
413
|
+
`autorag refresh` and `autorag index reset|rebuild` accept `--method <csv>` (e.g. `--method minsync,parsed` or `--method datasources,jikji`) to scope which indexing methods run or which index directories are removed. Valid values are `parsed`, `minsync`, `datasources`, `jikji`, and `all`. BM25 is a MinSync retrieval mode, not a `--method` name. When omitted, all methods run. `autorag init` accepts `--embedder-*` flags to configure the MinSync embedder endpoint in the config file.
|
|
414
|
+
|
|
415
|
+
`autorag refresh --json` reports the MinSync outcome in a `minsync` block (`ok`, `synced`, and a `reason`/`diagnostics` on failure), and the envelope's `ok` is `false` whenever MinSync, a datasource index, or any error-severity diagnostic failed — a green envelope never hides a semantic index that did not update.
|
|
416
416
|
|
|
417
417
|
`autorag health` checks model/provider auth before a search — it resolves the model, verifies credential presence, and optionally probes one completion call. Use it to diagnose model, provider, auth, or timeout failures. `autorag status` remains the model-free index-health command (corpus freshness and BM25/MinSync readiness). When `autorag search` fails for a model/provider reason, the error output includes a hint pointing to `autorag health`.
|
|
418
418
|
|
|
@@ -440,6 +440,61 @@ characters. Local use remains the safe default: omit `ui` (or leave
|
|
|
440
440
|
`allowRemote` false) and AutoRAG binds to loopback, including a working
|
|
441
441
|
`localhost` URL on systems that resolve it to IPv6.
|
|
442
442
|
|
|
443
|
+
### CLI commands
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
autorag init # write ~/.autorag/config.json
|
|
447
|
+
autorag refresh # parsed + MinSync + datasources + Jikji
|
|
448
|
+
autorag watch [--once] # filesystem watch, or one cron/poll tick
|
|
449
|
+
autorag status # corpus freshness (model-free)
|
|
450
|
+
autorag search "your question" # curated answer (requires a configured model)
|
|
451
|
+
autorag feedback <session> # numbered useful / not-useful feedback
|
|
452
|
+
autorag evidence <session> # persisted source/chunk evidence
|
|
453
|
+
autorag memory inspect # retrieval memory snapshot
|
|
454
|
+
autorag index reset|rebuild # remove or rebuild workspace indexes
|
|
455
|
+
autorag health # model/provider auth (no index check)
|
|
456
|
+
autorag duplicates [DIR] # read-only duplicate families; never deletes
|
|
457
|
+
autorag tui # interactive librarian terminal UI (beta)
|
|
458
|
+
autorag ui # loopback page to connect datasources
|
|
459
|
+
autorag lite … # model-free setup, retrieve, report, status
|
|
460
|
+
autorag setup # install and configure local runtime assets
|
|
461
|
+
autorag models prefetch|import|verify
|
|
462
|
+
# manage local embedding model profiles
|
|
463
|
+
autorag gateway status|stop # inspect or stop the local embedding gateway
|
|
464
|
+
autorag serve # P2P peer query server over SimpleX (opt-in)
|
|
465
|
+
autorag p2p # peer trust, approvals, and sharing policy
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
`autorag --help` is the command list of record; `autorag <command> --help`
|
|
469
|
+
prints that command's flags and subcommands, and `autorag --version` prints the
|
|
470
|
+
installed version. See
|
|
471
|
+
[docs/embedding-runtime.md](docs/embedding-runtime.md) for the local embedding
|
|
472
|
+
runtime and gateway setup.
|
|
473
|
+
|
|
474
|
+
### P2P sharing (SimpleX)
|
|
475
|
+
|
|
476
|
+
Peer query sharing is **disabled by default**. Set `p2p.enabled` to `true` in
|
|
477
|
+
`config.json`, or pass `--force` to start the server once. Peers reach this
|
|
478
|
+
installation through SimpleX; the local control socket binds to loopback
|
|
479
|
+
(default port 5225).
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
autorag serve # start the peer query server
|
|
483
|
+
autorag p2p peers # list trusted peers
|
|
484
|
+
autorag p2p peers --add alice --contact-id 1
|
|
485
|
+
autorag p2p requests # pending responses held for approval
|
|
486
|
+
autorag p2p requests approve <id>
|
|
487
|
+
autorag p2p policy list # merged sharing rules (virtual-path keys)
|
|
488
|
+
autorag p2p policy set '/docs/**' peers
|
|
489
|
+
autorag p2p policy unset '/docs/**'
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Inbound queries are screened for injection. Outbound answers are filtered by
|
|
493
|
+
sharing policy (`private` / `never` / `always` / `peers`) and PII redaction,
|
|
494
|
+
and held until the operator approves them. The librarian can call
|
|
495
|
+
`recommend_peer_targets` to suggest local peer personas without contacting
|
|
496
|
+
them.
|
|
497
|
+
|
|
443
498
|
## Installation
|
|
444
499
|
|
|
445
500
|
Published as `@autorag/librarian` (dist bundled with Bun, runtime Node ≥ 24 or Bun):
|
|
@@ -448,7 +503,7 @@ Published as `@autorag/librarian` (dist bundled with Bun, runtime Node ≥ 24 or
|
|
|
448
503
|
bun add @autorag/librarian # library
|
|
449
504
|
bun install -g @autorag/librarian # autorag CLI
|
|
450
505
|
# or run directly from the repo:
|
|
451
|
-
bun add github:
|
|
506
|
+
bun add github:Marker-Inc-Korea/AutoRAG
|
|
452
507
|
```
|
|
453
508
|
|
|
454
509
|
PDF parsing requires **Java 11 or newer** because the bundled
|
|
@@ -467,28 +522,18 @@ start a new shell). Java 8 is not supported by the PDF parser.
|
|
|
467
522
|
Git-based installs build `dist/` via the `prepare` script and require Bun on the installing machine.
|
|
468
523
|
External tool binaries auto-install on first use into `<workspace>/.autorag/bin`: **MinSync** installs from crates.io via `cargo install minsync` first (on by default; verified GitHub release assets are the fallback when cargo is unavailable; `minSync.autoInstall: false` to opt out), and **Jikji** compiles the [`jikji-cli`](https://crates.io/crates/jikji-cli) crate via cargo (requires the [Rust toolchain](https://rustup.rs); `jikji.autoInstall: false` to opt out). New `autorag init` configs enable Jikji find-first discovery by default. KakaoTalk (`katok`) and Discord (`discrawl`) stay manual, optional installs. All of them degrade gracefully when missing — core BM25 search works without any of them.
|
|
469
524
|
|
|
470
|
-
###
|
|
525
|
+
### TUI (beta)
|
|
471
526
|
|
|
472
|
-
|
|
473
|
-
|
|
527
|
+
`autorag tui` opens an interactive Pi-powered librarian terminal UI using the
|
|
528
|
+
same config as `autorag search`:
|
|
474
529
|
|
|
475
530
|
```bash
|
|
476
|
-
|
|
477
|
-
cd AutoRAG
|
|
478
|
-
bun install
|
|
479
|
-
bun run build
|
|
480
|
-
|
|
481
|
-
# Configure your document roots and model once:
|
|
482
|
-
node dist/cli/index.js init --search-paths /path/to/documents
|
|
483
|
-
|
|
484
|
-
# Start the beta TUI:
|
|
485
|
-
node dist/cli/index.js tui
|
|
531
|
+
autorag tui
|
|
486
532
|
```
|
|
487
533
|
|
|
488
534
|
Inside the TUI, use `/resume` to browse saved sessions. Selecting a session
|
|
489
535
|
replaces the current view with that session instead of mixing the two
|
|
490
|
-
conversation histories.
|
|
491
|
-
feature is included in a published release.
|
|
536
|
+
conversation histories. The TUI is beta and may still change.
|
|
492
537
|
|
|
493
538
|
## Quick Start
|
|
494
539
|
|
|
@@ -543,4 +588,4 @@ agent.recordFeedbackByNumbers(response.sessionId, [1, 3], [2]);
|
|
|
543
588
|
|
|
544
589
|
## License
|
|
545
590
|
|
|
546
|
-
MIT
|
|
591
|
+
MIT for AutoRAG 2.0 (`LICENSE`). The legacy Python package in `legacy/` is Apache-2.0 (`legacy/LICENSE`). Production third-party licenses are listed in `NOTICE`. Supply-chain gates are documented in `docs/supply-chain.md`.
|
package/dist/agent/agent.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { type JikjiFailureReason, type JikjiOptions } from "../jikji/index.js";
|
|
|
7
7
|
import type { ResultFeedback } from "../memory/memory.js";
|
|
8
8
|
import { type MinSyncSyncResult, type MinSyncVectorMethodOptions } from "../minsync/index.js";
|
|
9
9
|
import { type ParsedMirrorSyncResult } from "../mirror/sync.js";
|
|
10
|
+
import type { PolicyResolver } from "../p2p/policy-filter.js";
|
|
10
11
|
import type { DefaultParserRegistryOptions } from "../parser/index.js";
|
|
11
12
|
import { RetrievalEngine } from "../retrieval/engine.js";
|
|
12
13
|
import { RetrievalMethodRegistry } from "../retrieval/registry.js";
|
|
@@ -29,6 +30,9 @@ export interface AutoRAGMinSyncRefreshResult {
|
|
|
29
30
|
readonly ok: boolean;
|
|
30
31
|
readonly synced: number;
|
|
31
32
|
readonly reason?: string;
|
|
33
|
+
/** Count of parsed documents excluded from the MinSync index by file name. */
|
|
34
|
+
readonly stagingExcludedCount?: number;
|
|
35
|
+
readonly diagnostics?: readonly SearchDocumentDiagnostic[];
|
|
32
36
|
}
|
|
33
37
|
export interface AutoRAGRefreshResult extends Omit<ParsedMirrorSyncResult, "diagnostics"> {
|
|
34
38
|
readonly diagnostics: readonly SearchDocumentDiagnostic[];
|
|
@@ -66,6 +70,39 @@ export interface AutoRAGWatchRefreshOptions {
|
|
|
66
70
|
readonly watcherFactory?: WatcherFactory;
|
|
67
71
|
}
|
|
68
72
|
export type AutoRAGWatchRefreshHandle = WatchRefreshHandle;
|
|
73
|
+
declare module "../retrieval/types.js" {
|
|
74
|
+
interface RetrievalOptions {
|
|
75
|
+
/** Server-only P2P policy identity; never included in model tool schemas. */
|
|
76
|
+
peerFingerprint?: string;
|
|
77
|
+
/** Server-only P2P policy resolver. */
|
|
78
|
+
resolvePolicy?: PolicyResolver;
|
|
79
|
+
/** Server-only run registry populated from observed retrieval output. */
|
|
80
|
+
observedSources?: Set<string>;
|
|
81
|
+
/** Server-only datasource source globs derived from the loaded policy. */
|
|
82
|
+
policyDatasourceScopes?: readonly string[];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export type RemoteSessionRejectionCode = "injection-detected" | "outbound-leak-detected";
|
|
86
|
+
export declare class RemoteSessionRejectedError extends Error {
|
|
87
|
+
readonly code: RemoteSessionRejectionCode;
|
|
88
|
+
constructor(code: RemoteSessionRejectionCode);
|
|
89
|
+
}
|
|
90
|
+
/** Thinking level applied per search phase. "off" requests no reasoning. */
|
|
91
|
+
export type AutoRAGThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
92
|
+
/**
|
|
93
|
+
* Two-phase progressive answers: the fast phase delivers an immediate first
|
|
94
|
+
* answer with {@link AutoRAGThinkingOptions.fast} thinking (default "off"),
|
|
95
|
+
* then the verification phase re-checks and finalizes with
|
|
96
|
+
* {@link AutoRAGThinkingOptions.final} thinking (default "high"). Pass
|
|
97
|
+
* `false` on {@link AutoRAGAgentOptions.thinking} to keep the legacy
|
|
98
|
+
* single-phase flow.
|
|
99
|
+
*/
|
|
100
|
+
export interface AutoRAGThinkingOptions {
|
|
101
|
+
/** Thinking level for the immediate first answer. Default "off". */
|
|
102
|
+
readonly fast?: AutoRAGThinkingLevel;
|
|
103
|
+
/** Thinking level for the verification/finalization phase. Default "high". */
|
|
104
|
+
readonly final?: AutoRAGThinkingLevel;
|
|
105
|
+
}
|
|
69
106
|
export interface AutoRAGAgentOptions {
|
|
70
107
|
model?: Model<Api>;
|
|
71
108
|
apiKey?: string;
|
|
@@ -89,6 +126,10 @@ export interface AutoRAGAgentOptions {
|
|
|
89
126
|
searchTimeoutMs?: number;
|
|
90
127
|
/** Maximum number of retrieval/tool executions allowed in one search. */
|
|
91
128
|
maxSearchToolCalls?: number;
|
|
129
|
+
/** Restrict the agent to retrieval and result-emission tools for remote runs. */
|
|
130
|
+
remoteSession?: boolean;
|
|
131
|
+
/** Two-phase progressive answers with per-phase thinking control. Default enabled. */
|
|
132
|
+
thinking?: AutoRAGThinkingOptions | false;
|
|
92
133
|
}
|
|
93
134
|
export interface AutoRAGSearchSession {
|
|
94
135
|
readonly agent: Agent;
|
|
@@ -121,6 +162,11 @@ export declare class AutoRAGAgent {
|
|
|
121
162
|
private readonly sessions;
|
|
122
163
|
private activeRun;
|
|
123
164
|
private resultCapture;
|
|
165
|
+
private retrievalTrace;
|
|
166
|
+
private preliminaryCallback;
|
|
167
|
+
/** Per-phase thinking levels; undefined marks the legacy single-phase flow. */
|
|
168
|
+
private readonly fastThinkingLevel;
|
|
169
|
+
private readonly finalThinkingLevel;
|
|
124
170
|
private autoRefreshTimer;
|
|
125
171
|
private refreshing;
|
|
126
172
|
private jikjiPrepareInFlight;
|
|
@@ -150,6 +196,9 @@ export declare class AutoRAGAgent {
|
|
|
150
196
|
private readonly droppedCallerToolNames;
|
|
151
197
|
private readonly searchTimeoutMs;
|
|
152
198
|
private readonly maxSearchToolCalls;
|
|
199
|
+
/** True when this agent was constructed for an untrusted remote peer. */
|
|
200
|
+
readonly remoteSession: boolean;
|
|
201
|
+
private activeRetrievalOptions;
|
|
153
202
|
private searchToolCallCount;
|
|
154
203
|
private readonly sourceSearchCallCounts;
|
|
155
204
|
constructor(options: AutoRAGAgentOptions);
|
|
@@ -210,14 +259,36 @@ export declare class AutoRAGAgent {
|
|
|
210
259
|
/** Prepare MinSync in the background; the returned promise is for tests. */
|
|
211
260
|
scheduleMinSyncPrepareForTest(): Promise<MinSyncSyncResult | undefined> | undefined;
|
|
212
261
|
private scheduleMinSyncPrepare;
|
|
262
|
+
/**
|
|
263
|
+
* Fast-phase prompt for two-phase searches. The baseline retrieval context
|
|
264
|
+
* is already gathered, so the model answers immediately with thinking off
|
|
265
|
+
* via emit_fast_answer, without any further tool calls.
|
|
266
|
+
*/
|
|
267
|
+
buildFastAnswerPrompt(query: string, options: RetrievalOptions, baseline: string): string;
|
|
268
|
+
/**
|
|
269
|
+
* Verification-phase prompt for two-phase searches. The user already saw
|
|
270
|
+
* the fast answer; the model now verifies it against sources with thinking
|
|
271
|
+
* on and finalizes with emit_autorag_results exactly once.
|
|
272
|
+
*/
|
|
273
|
+
buildRefinementPrompt(query: string, options: RetrievalOptions, fastAnswer: string | undefined): string;
|
|
213
274
|
buildSearchPrompt(query: string, options: RetrievalOptions, initialRetrievalContext?: string): string;
|
|
214
275
|
refresh(force?: boolean, opts?: AutoRAGRefreshOptions): Promise<AutoRAGRefreshResult>;
|
|
215
276
|
/**
|
|
216
277
|
* Path-opaque snapshot of corpus freshness and the last refresh outcome. Runs
|
|
217
278
|
* a cheap parse-free staleness scan (stat only); never parses in this path.
|
|
279
|
+
*
|
|
280
|
+
* Freshness is read from disk, not from this instance's history: a separate CLI
|
|
281
|
+
* process (for example `autorag status` or `autorag lite status`) reports the
|
|
282
|
+
* corpus as current when the last refresh left parsed mirrors behind and no
|
|
283
|
+
* source has changed since.
|
|
218
284
|
*/
|
|
219
285
|
getRefreshStatus(): Promise<AutoRAGRefreshStatus>;
|
|
220
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Synchronous per-component readiness snapshot (minsync/jikji/datasources).
|
|
288
|
+
* `minsync` is "ready" only after a successful sync wrote its cursor;
|
|
289
|
+
* "configured" means the binary resolved but no index exists yet.
|
|
290
|
+
*/
|
|
291
|
+
refreshComponentStatus(): AutoRAGRefreshComponentStatus;
|
|
221
292
|
/**
|
|
222
293
|
* Opt-in filesystem watch that keeps parsed mirrors and configured indexes
|
|
223
294
|
* current. Debounced, backpressure-limited (one in-flight refresh plus one
|
|
@@ -315,6 +386,7 @@ export declare class AutoRAGAgent {
|
|
|
315
386
|
getRetrievalEngine(): RetrievalEngine;
|
|
316
387
|
getSystemPrompt(): string;
|
|
317
388
|
private rerankWithMemory;
|
|
389
|
+
private remoteFilteredRetrievalMethod;
|
|
318
390
|
private normalizeRetrievalOptions;
|
|
319
391
|
private resolveRetrievalScope;
|
|
320
392
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
export declare const EMIT_FAST_ANSWER_TOOL_NAME = "emit_fast_answer";
|
|
4
|
+
declare const fastAnswerSchema: Type.TObject<{
|
|
5
|
+
answer: Type.TString;
|
|
6
|
+
results: Type.TArray<Type.TObject<{
|
|
7
|
+
number: Type.TInteger;
|
|
8
|
+
title: Type.TString;
|
|
9
|
+
summary: Type.TString;
|
|
10
|
+
evidence: Type.TOptional<Type.TArray<Type.TObject<{
|
|
11
|
+
excerpt: Type.TString;
|
|
12
|
+
lineNumber: Type.TOptional<Type.TInteger>;
|
|
13
|
+
}>>>;
|
|
14
|
+
confidence: Type.TOptional<Type.TNumber>;
|
|
15
|
+
}>>;
|
|
16
|
+
sources: Type.TOptional<Type.TArray<Type.TObject<{
|
|
17
|
+
number: Type.TInteger;
|
|
18
|
+
source: Type.TString;
|
|
19
|
+
}>>>;
|
|
20
|
+
}>;
|
|
21
|
+
export interface AutoRAGFastAnswerResult {
|
|
22
|
+
readonly number: number;
|
|
23
|
+
readonly title: string;
|
|
24
|
+
readonly summary: string;
|
|
25
|
+
readonly evidence: readonly {
|
|
26
|
+
readonly excerpt: string;
|
|
27
|
+
readonly lineNumber?: number;
|
|
28
|
+
}[];
|
|
29
|
+
readonly confidence?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface AutoRAGFastAnswerDetails {
|
|
32
|
+
readonly answer: string;
|
|
33
|
+
readonly results: readonly AutoRAGFastAnswerResult[];
|
|
34
|
+
readonly sources: readonly {
|
|
35
|
+
readonly number: number;
|
|
36
|
+
readonly source: string;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Builds the non-terminating fast-answer tool used by the two-phase search
|
|
41
|
+
* flow. The model calls this exactly once during the thinking-off fast phase
|
|
42
|
+
* to deliver an immediate, complete first answer; the run then continues into
|
|
43
|
+
* the verification phase, which ends with emit_autorag_results.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createEmitFastAnswerTool(capture: (details: AutoRAGFastAnswerDetails) => void): AgentTool<typeof fastAnswerSchema, AutoRAGFastAnswerDetails>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
export declare const RECOMMEND_PEER_TARGETS_TOOL_NAME = "recommend_peer_targets";
|
|
4
|
+
declare const recommendPeerTargetsSchema: Type.TObject<{
|
|
5
|
+
query: Type.TString;
|
|
6
|
+
}>;
|
|
7
|
+
export interface PeerTargetRecommendation {
|
|
8
|
+
readonly alias: string;
|
|
9
|
+
readonly matchedTerms: readonly string[];
|
|
10
|
+
readonly displayName?: string;
|
|
11
|
+
readonly description?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RecommendPeerTargetsDetails {
|
|
14
|
+
readonly method: "recommend_peer_targets";
|
|
15
|
+
readonly resultCount: number;
|
|
16
|
+
readonly matches: readonly PeerTargetRecommendation[];
|
|
17
|
+
}
|
|
18
|
+
export declare function createRecommendPeerTargetsTool(workspacePath: string): AgentTool<typeof recommendPeerTargetsSchema, RecommendPeerTargetsDetails>;
|
|
19
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { RetrievalDiagnostic, RetrievalResult } from "../retrieval/types.js";
|
|
4
|
+
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
4
5
|
export declare const SEARCH_ALL_DOCUMENTS_TOOL_NAME = "search_all_documents";
|
|
5
6
|
declare const searchAllSchema: Type.TObject<{
|
|
6
7
|
query: Type.TString;
|
|
@@ -24,6 +25,8 @@ export interface SearchAllDocumentsDetails {
|
|
|
24
25
|
readonly sources: readonly string[];
|
|
25
26
|
readonly diagnostics: readonly RetrievalDiagnostic[];
|
|
26
27
|
readonly perMethodCounts?: Readonly<Record<string, number>>;
|
|
28
|
+
/** Top candidates in traceable shape (additive; used for the run's retrieval trace). */
|
|
29
|
+
readonly results?: readonly SearchDocumentRetrievalTraceResult[];
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* LLM-facing wrapper around multi-method merged retrieval. The
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { RetrievalDiagnostic, RetrievalResult } from "../retrieval/types.js";
|
|
4
|
+
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
4
5
|
export declare const SEARCH_DATASOURCE_DOCUMENTS_TOOL_NAME = "search_datasource_documents";
|
|
5
6
|
declare const searchDatasourceSchema: Type.TObject<{
|
|
6
7
|
query: Type.TString;
|
|
@@ -12,6 +13,8 @@ export interface SearchDatasourceDocumentsDetails {
|
|
|
12
13
|
readonly resultCount: number;
|
|
13
14
|
readonly sources: readonly string[];
|
|
14
15
|
readonly diagnostics: readonly RetrievalDiagnostic[];
|
|
16
|
+
/** Top candidates in traceable shape (additive; used for the run's retrieval trace). */
|
|
17
|
+
readonly results?: readonly SearchDocumentRetrievalTraceResult[];
|
|
15
18
|
}
|
|
16
19
|
export interface DatasourceSearchProvider {
|
|
17
20
|
searchDatasourceDocuments(query: string, options?: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type RetrievalMemory } from "../memory/memory.js";
|
|
2
|
-
import type { CuratedResult } from "../retrieval/types.js";
|
|
2
|
+
import type { CuratedResult, RetrievalResult } from "../retrieval/types.js";
|
|
3
3
|
import type { AutoRAGResultsDetails } from "./emit-results-tool.js";
|
|
4
|
+
import type { AutoRAGFastAnswerDetails } from "./fast-answer-tool.js";
|
|
4
5
|
export type SearchDocumentWarning = "empty-query";
|
|
5
6
|
export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
|
|
6
7
|
/**
|
|
@@ -9,7 +10,7 @@ export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
|
|
|
9
10
|
* (#21/#22) does not require another source-breaking type change; codes not yet
|
|
10
11
|
* emitted are still valid members.
|
|
11
12
|
*/
|
|
12
|
-
export type SearchDocumentDiagnosticCode = "empty-query" | "unknown-warning" | "caller-tool-dropped" | "minsync-unavailable" | "parser-skipped" | "parser-failed" | "pdf-java-version" | "duplicate-excluded" | "unsupported-file" | "stale-index" | "deleted-mirror" | "pdf-extract-thin" | "pdf-hybrid-unavailable" | "retrieval-method-failed" | "jikji-unavailable" | "jikji-prepare-failed" | "jikji-find-failed" | "refresh-failed" | "watch-failed" | "watch-limited" | "unknown-datasource-skill";
|
|
13
|
+
export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "minsync-unavailable" | "minsync-staging-excluded" | "minsync-sync-failed" | "embedder-unavailable" | "embedding-identity-mismatch" | "parser-skipped" | "parser-failed" | "pdf-java-version" | "duplicate-excluded" | "unsupported-file" | "stale-index" | "deleted-mirror" | "pdf-extract-thin" | "pdf-hybrid-unavailable" | "retrieval-method-failed" | "jikji-unavailable" | "jikji-prepare-failed" | "jikji-find-failed" | "refresh-failed" | "watch-failed" | "watch-limited" | "unknown-datasource-skill" | "missing-final-emit";
|
|
13
14
|
export interface SearchDocumentDiagnostic {
|
|
14
15
|
readonly code: SearchDocumentDiagnosticCode;
|
|
15
16
|
readonly severity: SearchDocumentDiagnosticSeverity;
|
|
@@ -30,6 +31,23 @@ export interface SearchDocumentResult {
|
|
|
30
31
|
readonly feedbackId: string;
|
|
31
32
|
readonly source?: string;
|
|
32
33
|
}
|
|
34
|
+
/** One retrieval candidate captured in a run's retrieval trace. */
|
|
35
|
+
export interface SearchDocumentRetrievalTraceResult {
|
|
36
|
+
readonly source?: string;
|
|
37
|
+
readonly excerpt: string;
|
|
38
|
+
readonly score?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* What one retrieval tool execution found during a search run. Attached to the
|
|
42
|
+
* degraded fallback response when the agent never called emit_autorag_results,
|
|
43
|
+
* so an upstream agent can still inspect the raw candidates.
|
|
44
|
+
*/
|
|
45
|
+
export interface SearchDocumentRetrievalTraceEntry {
|
|
46
|
+
readonly tool: string;
|
|
47
|
+
readonly query?: string;
|
|
48
|
+
readonly resultCount: number;
|
|
49
|
+
readonly results: readonly SearchDocumentRetrievalTraceResult[];
|
|
50
|
+
}
|
|
33
51
|
export interface SearchDocumentsResponse {
|
|
34
52
|
readonly sessionId: string;
|
|
35
53
|
readonly query: string;
|
|
@@ -42,25 +60,52 @@ export interface SearchDocumentsResponse {
|
|
|
42
60
|
* window, but ALWAYS populated at runtime (defaults to an empty array).
|
|
43
61
|
*/
|
|
44
62
|
readonly diagnostics?: readonly SearchDocumentDiagnostic[];
|
|
63
|
+
/**
|
|
64
|
+
* Retrieval candidates gathered during the run. Populated on the degraded
|
|
65
|
+
* fallback path (missing final emit); absent or empty otherwise.
|
|
66
|
+
*/
|
|
67
|
+
readonly retrievalTrace?: readonly SearchDocumentRetrievalTraceEntry[];
|
|
45
68
|
}
|
|
69
|
+
/** Cap and shape retrieval results for the run trace (additive tool details). */
|
|
70
|
+
export declare function toRetrievalTraceResults(results: readonly RetrievalResult[], limit?: number, excerptChars?: number): readonly SearchDocumentRetrievalTraceResult[];
|
|
46
71
|
export type SearchDocumentsStreamEvent = {
|
|
47
72
|
readonly type: "progress";
|
|
48
73
|
readonly sessionId: string;
|
|
49
74
|
readonly query: string;
|
|
50
75
|
readonly text: string;
|
|
76
|
+
} | {
|
|
77
|
+
/**
|
|
78
|
+
* Immediate first answer from the thinking-off fast phase. Always
|
|
79
|
+
* yielded before `complete` when the two-phase flow produced one; the
|
|
80
|
+
* `complete` event's response remains the verified final answer.
|
|
81
|
+
*/
|
|
82
|
+
readonly type: "preliminary";
|
|
83
|
+
readonly response: SearchDocumentsResponse;
|
|
51
84
|
} | {
|
|
52
85
|
readonly type: "complete";
|
|
53
86
|
readonly response: SearchDocumentsResponse;
|
|
54
87
|
};
|
|
55
|
-
type
|
|
88
|
+
type SearchSession = {
|
|
56
89
|
query: string;
|
|
57
90
|
registry: Map<number, CuratedResult>;
|
|
58
|
-
|
|
91
|
+
transient?: boolean;
|
|
92
|
+
};
|
|
93
|
+
type SearchSessions = Map<string, SearchSession>;
|
|
59
94
|
type ReadonlySearchSessions = ReadonlyMap<string, {
|
|
60
95
|
query: string;
|
|
61
96
|
registry: ReadonlyMap<number, CuratedResult>;
|
|
97
|
+
transient?: boolean;
|
|
62
98
|
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Build the preliminary (fast-phase) search response. Unlike
|
|
101
|
+
* {@link recordStructuredResultsSession} this NEVER touches memory or the
|
|
102
|
+
* feedback session registry — the final response owns those. Feedback ids are
|
|
103
|
+
* namespaced with `:preliminary:` so they can never collide with final ids.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createPreliminarySearchDocumentsResponse(sessionId: string, query: string, details: AutoRAGFastAnswerDetails, diagnostics?: readonly SearchDocumentDiagnostic[]): SearchDocumentsResponse;
|
|
63
106
|
export declare function createEmptySearchDocumentsResponse(sessionId: string, query: string, sessions: SearchSessions, diagnostics?: readonly SearchDocumentDiagnostic[]): SearchDocumentsResponse;
|
|
64
|
-
export declare function recordStructuredResultsSession(sessionId: string, query: string, details: AutoRAGResultsDetails, sessions: SearchSessions, memory: RetrievalMemory, componentDiagnostics?: readonly SearchDocumentDiagnostic[]
|
|
107
|
+
export declare function recordStructuredResultsSession(sessionId: string, query: string, details: AutoRAGResultsDetails, sessions: SearchSessions, memory: RetrievalMemory, componentDiagnostics?: readonly SearchDocumentDiagnostic[], options?: {
|
|
108
|
+
readonly isolateMemory?: boolean;
|
|
109
|
+
}): SearchDocumentsResponse;
|
|
65
110
|
export declare function recordNumberedFeedback(sessions: ReadonlySearchSessions, memory: RetrievalMemory, sessionId: string, usefulNumbers: readonly number[], notUsefulNumbers: readonly number[]): void;
|
|
66
111
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { MinSyncVectorMethod } from "../minsync/method.js";
|
|
4
|
+
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
4
5
|
export declare const SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME = "semantic_search_local_docs";
|
|
5
6
|
declare const searchMinSyncSchema: Type.TObject<{
|
|
6
7
|
query: Type.TString;
|
|
@@ -12,6 +13,8 @@ export interface SearchMinSyncDocumentsDetails {
|
|
|
12
13
|
readonly resultCount: number;
|
|
13
14
|
readonly sources: readonly string[];
|
|
14
15
|
readonly available: boolean;
|
|
16
|
+
/** Top candidates in traceable shape (additive; used for the run's retrieval trace). */
|
|
17
|
+
readonly results?: readonly SearchDocumentRetrievalTraceResult[];
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* LLM-facing wrapper around the {@link MinSyncVectorMethod} vector
|