@autorag/librarian 2.4.1 → 2.5.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.
- package/NOTICE +68 -0
- package/README.md +72 -30
- package/dist/agent/agent.d.ts +74 -2
- package/dist/agent/emit-results-tool.d.ts +1 -2
- package/dist/agent/fast-answer-tool.d.ts +46 -0
- package/dist/agent/index.d.ts +1 -1
- 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/commands/duplicates.d.ts +6 -0
- package/dist/cli/commands/gateway.d.ts +7 -0
- package/dist/cli/commands/lite-refresh.d.ts +10 -0
- package/dist/cli/commands/lite-retrieve.d.ts +33 -0
- package/dist/cli/commands/lite.d.ts +3 -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/report.d.ts +3 -0
- package/dist/cli/commands/serve.d.ts +18 -0
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/tui.d.ts +1 -1
- package/dist/cli/commands/watch.d.ts +2 -0
- package/dist/cli/config.d.ts +20 -0
- package/dist/cli/index.js +7911 -2518
- package/dist/cli/output.d.ts +6 -0
- package/dist/cli/setup.d.ts +59 -0
- package/dist/core.d.ts +67 -0
- package/dist/core.js +18172 -0
- package/dist/datasource/access-context.d.ts +1 -1
- package/dist/datasource/connector-skill.d.ts +1 -1
- package/dist/datasource/connector.d.ts +1 -1
- package/dist/datasource/index.d.ts +0 -1
- package/dist/datasource/result-filter.d.ts +1 -1
- package/dist/datasource/skills/discrawl/client.d.ts +6 -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 +22 -0
- 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 +27 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13214 -8659
- package/dist/minsync/client.d.ts +26 -1
- package/dist/minsync/embedder-config.d.ts +12 -0
- package/dist/minsync/index.d.ts +4 -3
- package/dist/minsync/installer.d.ts +7 -1
- package/dist/minsync/local-embedder.d.ts +16 -0
- package/dist/minsync/method.d.ts +8 -2
- package/dist/minsync/types.d.ts +9 -0
- package/dist/mirror/index.d.ts +1 -1
- package/dist/mirror/paths.d.ts +2 -0
- package/dist/mirror/sync.d.ts +1 -0
- 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/dist/retrieval/engine.d.ts +123 -0
- package/dist/retrieval/index.d.ts +1 -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 +19 -10
- package/skills/autorag/SKILL.md +16 -6
- package/skills/autorag-lite-search/SKILL.md +155 -0
- package/skills/autorag-lite-setup/SKILL.md +182 -0
- package/skills/autorag-setup/SKILL.md +58 -27
- 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.
|
|
@@ -412,7 +411,7 @@ Config path precedence is `--config` > `AUTORAG_CONFIG` > `~/.autorag/config.jso
|
|
|
412
411
|
|
|
413
412
|
`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
413
|
|
|
415
|
-
`autorag refresh` and `autorag index reset|rebuild` accept `--method <csv>` (e.g. `--method
|
|
414
|
+
`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.
|
|
416
415
|
|
|
417
416
|
`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
417
|
|
|
@@ -440,6 +439,59 @@ characters. Local use remains the safe default: omit `ui` (or leave
|
|
|
440
439
|
`allowRemote` false) and AutoRAG binds to loopback, including a working
|
|
441
440
|
`localhost` URL on systems that resolve it to IPv6.
|
|
442
441
|
|
|
442
|
+
### CLI commands
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
autorag init # write ~/.autorag/config.json
|
|
446
|
+
autorag refresh # parsed + MinSync + datasources + Jikji
|
|
447
|
+
autorag watch [--once] # filesystem watch, or one cron/poll tick
|
|
448
|
+
autorag status # corpus freshness (model-free)
|
|
449
|
+
autorag search "your question" # curated answer (requires a configured model)
|
|
450
|
+
autorag feedback <session> # numbered useful / not-useful feedback
|
|
451
|
+
autorag evidence <session> # persisted source/chunk evidence
|
|
452
|
+
autorag memory inspect # retrieval memory snapshot
|
|
453
|
+
autorag index reset|rebuild # remove or rebuild workspace indexes
|
|
454
|
+
autorag health # model/provider auth (no index check)
|
|
455
|
+
autorag duplicates [DIR] # read-only duplicate families; never deletes
|
|
456
|
+
autorag tui # interactive librarian terminal UI (beta)
|
|
457
|
+
autorag ui # loopback page to connect datasources
|
|
458
|
+
autorag lite … # model-free setup, retrieve, report, status
|
|
459
|
+
autorag setup # install and configure local runtime assets
|
|
460
|
+
autorag models prefetch|import|verify
|
|
461
|
+
# manage local embedding model profiles
|
|
462
|
+
autorag gateway status|stop # inspect or stop the local embedding gateway
|
|
463
|
+
autorag serve # P2P peer query server over SimpleX (opt-in)
|
|
464
|
+
autorag p2p # peer trust, approvals, and sharing policy
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
`autorag --help` is the command list of record. See
|
|
468
|
+
[docs/embedding-runtime.md](docs/embedding-runtime.md) for the local embedding
|
|
469
|
+
runtime and gateway setup.
|
|
470
|
+
|
|
471
|
+
### P2P sharing (SimpleX)
|
|
472
|
+
|
|
473
|
+
Peer query sharing is **disabled by default**. Set `p2p.enabled` to `true` in
|
|
474
|
+
`config.json`, or pass `--force` to start the server once. Peers reach this
|
|
475
|
+
installation through SimpleX; the local control socket binds to loopback
|
|
476
|
+
(default port 5225).
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
autorag serve # start the peer query server
|
|
480
|
+
autorag p2p peers # list trusted peers
|
|
481
|
+
autorag p2p peers --add alice --contact-id 1
|
|
482
|
+
autorag p2p requests # pending responses held for approval
|
|
483
|
+
autorag p2p requests approve <id>
|
|
484
|
+
autorag p2p policy list # merged sharing rules (virtual-path keys)
|
|
485
|
+
autorag p2p policy set '/docs/**' peers
|
|
486
|
+
autorag p2p policy unset '/docs/**'
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
Inbound queries are screened for injection. Outbound answers are filtered by
|
|
490
|
+
sharing policy (`private` / `never` / `always` / `peers`) and PII redaction,
|
|
491
|
+
and held until the operator approves them. The librarian can call
|
|
492
|
+
`recommend_peer_targets` to suggest local peer personas without contacting
|
|
493
|
+
them.
|
|
494
|
+
|
|
443
495
|
## Installation
|
|
444
496
|
|
|
445
497
|
Published as `@autorag/librarian` (dist bundled with Bun, runtime Node ≥ 24 or Bun):
|
|
@@ -448,7 +500,7 @@ Published as `@autorag/librarian` (dist bundled with Bun, runtime Node ≥ 24 or
|
|
|
448
500
|
bun add @autorag/librarian # library
|
|
449
501
|
bun install -g @autorag/librarian # autorag CLI
|
|
450
502
|
# or run directly from the repo:
|
|
451
|
-
bun add github:
|
|
503
|
+
bun add github:Marker-Inc-Korea/AutoRAG
|
|
452
504
|
```
|
|
453
505
|
|
|
454
506
|
PDF parsing requires **Java 11 or newer** because the bundled
|
|
@@ -465,30 +517,20 @@ installations in `PATH` (or set `JAVA_HOME` to the Java 11+ installation and
|
|
|
465
517
|
start a new shell). Java 8 is not supported by the PDF parser.
|
|
466
518
|
|
|
467
519
|
Git-based installs build `dist/` via the `prepare` script and require Bun on the installing machine.
|
|
468
|
-
External tool binaries auto-install on first use into `<workspace>/.autorag/bin`: **MinSync**
|
|
520
|
+
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
521
|
|
|
470
|
-
###
|
|
522
|
+
### TUI (beta)
|
|
471
523
|
|
|
472
|
-
|
|
473
|
-
|
|
524
|
+
`autorag tui` opens an interactive Pi-powered librarian terminal UI using the
|
|
525
|
+
same config as `autorag search`:
|
|
474
526
|
|
|
475
527
|
```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
|
|
528
|
+
autorag tui
|
|
486
529
|
```
|
|
487
530
|
|
|
488
531
|
Inside the TUI, use `/resume` to browse saved sessions. Selecting a session
|
|
489
532
|
replaces the current view with that session instead of mixing the two
|
|
490
|
-
conversation histories.
|
|
491
|
-
feature is included in a published release.
|
|
533
|
+
conversation histories. The TUI is beta and may still change.
|
|
492
534
|
|
|
493
535
|
## Quick Start
|
|
494
536
|
|
|
@@ -543,4 +585,4 @@ agent.recordFeedbackByNumbers(response.sessionId, [1, 3], [2]);
|
|
|
543
585
|
|
|
544
586
|
## License
|
|
545
587
|
|
|
546
|
-
MIT
|
|
588
|
+
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,7 +7,9 @@ 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";
|
|
12
|
+
import { RetrievalEngine } from "../retrieval/engine.js";
|
|
11
13
|
import { RetrievalMethodRegistry } from "../retrieval/registry.js";
|
|
12
14
|
import type { CuratedResult, RetrievalDiagnostic, RetrievalOptions, RetrievalResult } from "../retrieval/types.js";
|
|
13
15
|
import { type ScanDuplicateDocumentsDetails } from "./dupey-tool.js";
|
|
@@ -65,6 +67,39 @@ export interface AutoRAGWatchRefreshOptions {
|
|
|
65
67
|
readonly watcherFactory?: WatcherFactory;
|
|
66
68
|
}
|
|
67
69
|
export type AutoRAGWatchRefreshHandle = WatchRefreshHandle;
|
|
70
|
+
declare module "../retrieval/types.js" {
|
|
71
|
+
interface RetrievalOptions {
|
|
72
|
+
/** Server-only P2P policy identity; never included in model tool schemas. */
|
|
73
|
+
peerFingerprint?: string;
|
|
74
|
+
/** Server-only P2P policy resolver. */
|
|
75
|
+
resolvePolicy?: PolicyResolver;
|
|
76
|
+
/** Server-only run registry populated from observed retrieval output. */
|
|
77
|
+
observedSources?: Set<string>;
|
|
78
|
+
/** Server-only datasource source globs derived from the loaded policy. */
|
|
79
|
+
policyDatasourceScopes?: readonly string[];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export type RemoteSessionRejectionCode = "injection-detected" | "outbound-leak-detected";
|
|
83
|
+
export declare class RemoteSessionRejectedError extends Error {
|
|
84
|
+
readonly code: RemoteSessionRejectionCode;
|
|
85
|
+
constructor(code: RemoteSessionRejectionCode);
|
|
86
|
+
}
|
|
87
|
+
/** Thinking level applied per search phase. "off" requests no reasoning. */
|
|
88
|
+
export type AutoRAGThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
89
|
+
/**
|
|
90
|
+
* Two-phase progressive answers: the fast phase delivers an immediate first
|
|
91
|
+
* answer with {@link AutoRAGThinkingOptions.fast} thinking (default "off"),
|
|
92
|
+
* then the verification phase re-checks and finalizes with
|
|
93
|
+
* {@link AutoRAGThinkingOptions.final} thinking (default "high"). Pass
|
|
94
|
+
* `false` on {@link AutoRAGAgentOptions.thinking} to keep the legacy
|
|
95
|
+
* single-phase flow.
|
|
96
|
+
*/
|
|
97
|
+
export interface AutoRAGThinkingOptions {
|
|
98
|
+
/** Thinking level for the immediate first answer. Default "off". */
|
|
99
|
+
readonly fast?: AutoRAGThinkingLevel;
|
|
100
|
+
/** Thinking level for the verification/finalization phase. Default "high". */
|
|
101
|
+
readonly final?: AutoRAGThinkingLevel;
|
|
102
|
+
}
|
|
68
103
|
export interface AutoRAGAgentOptions {
|
|
69
104
|
model?: Model<Api>;
|
|
70
105
|
apiKey?: string;
|
|
@@ -88,6 +123,10 @@ export interface AutoRAGAgentOptions {
|
|
|
88
123
|
searchTimeoutMs?: number;
|
|
89
124
|
/** Maximum number of retrieval/tool executions allowed in one search. */
|
|
90
125
|
maxSearchToolCalls?: number;
|
|
126
|
+
/** Restrict the agent to retrieval and result-emission tools for remote runs. */
|
|
127
|
+
remoteSession?: boolean;
|
|
128
|
+
/** Two-phase progressive answers with per-phase thinking control. Default enabled. */
|
|
129
|
+
thinking?: AutoRAGThinkingOptions | false;
|
|
91
130
|
}
|
|
92
131
|
export interface AutoRAGSearchSession {
|
|
93
132
|
readonly agent: Agent;
|
|
@@ -120,6 +159,11 @@ export declare class AutoRAGAgent {
|
|
|
120
159
|
private readonly sessions;
|
|
121
160
|
private activeRun;
|
|
122
161
|
private resultCapture;
|
|
162
|
+
private retrievalTrace;
|
|
163
|
+
private preliminaryCallback;
|
|
164
|
+
/** Per-phase thinking levels; undefined marks the legacy single-phase flow. */
|
|
165
|
+
private readonly fastThinkingLevel;
|
|
166
|
+
private readonly finalThinkingLevel;
|
|
123
167
|
private autoRefreshTimer;
|
|
124
168
|
private refreshing;
|
|
125
169
|
private jikjiPrepareInFlight;
|
|
@@ -149,6 +193,9 @@ export declare class AutoRAGAgent {
|
|
|
149
193
|
private readonly droppedCallerToolNames;
|
|
150
194
|
private readonly searchTimeoutMs;
|
|
151
195
|
private readonly maxSearchToolCalls;
|
|
196
|
+
/** True when this agent was constructed for an untrusted remote peer. */
|
|
197
|
+
readonly remoteSession: boolean;
|
|
198
|
+
private activeRetrievalOptions;
|
|
152
199
|
private searchToolCallCount;
|
|
153
200
|
private readonly sourceSearchCallCounts;
|
|
154
201
|
constructor(options: AutoRAGAgentOptions);
|
|
@@ -209,6 +256,18 @@ export declare class AutoRAGAgent {
|
|
|
209
256
|
/** Prepare MinSync in the background; the returned promise is for tests. */
|
|
210
257
|
scheduleMinSyncPrepareForTest(): Promise<MinSyncSyncResult | undefined> | undefined;
|
|
211
258
|
private scheduleMinSyncPrepare;
|
|
259
|
+
/**
|
|
260
|
+
* Fast-phase prompt for two-phase searches. The baseline retrieval context
|
|
261
|
+
* is already gathered, so the model answers immediately with thinking off
|
|
262
|
+
* via emit_fast_answer, without any further tool calls.
|
|
263
|
+
*/
|
|
264
|
+
buildFastAnswerPrompt(query: string, options: RetrievalOptions, baseline: string): string;
|
|
265
|
+
/**
|
|
266
|
+
* Verification-phase prompt for two-phase searches. The user already saw
|
|
267
|
+
* the fast answer; the model now verifies it against sources with thinking
|
|
268
|
+
* on and finalizes with emit_autorag_results exactly once.
|
|
269
|
+
*/
|
|
270
|
+
buildRefinementPrompt(query: string, options: RetrievalOptions, fastAnswer: string | undefined): string;
|
|
212
271
|
buildSearchPrompt(query: string, options: RetrievalOptions, initialRetrievalContext?: string): string;
|
|
213
272
|
refresh(force?: boolean, opts?: AutoRAGRefreshOptions): Promise<AutoRAGRefreshResult>;
|
|
214
273
|
/**
|
|
@@ -216,7 +275,12 @@ export declare class AutoRAGAgent {
|
|
|
216
275
|
* a cheap parse-free staleness scan (stat only); never parses in this path.
|
|
217
276
|
*/
|
|
218
277
|
getRefreshStatus(): Promise<AutoRAGRefreshStatus>;
|
|
219
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Synchronous per-component readiness snapshot (minsync/jikji/datasources).
|
|
280
|
+
* `minsync` is "ready" only after a successful sync wrote its cursor;
|
|
281
|
+
* "configured" means the binary resolved but no index exists yet.
|
|
282
|
+
*/
|
|
283
|
+
refreshComponentStatus(): AutoRAGRefreshComponentStatus;
|
|
220
284
|
/**
|
|
221
285
|
* Opt-in filesystem watch that keeps parsed mirrors and configured indexes
|
|
222
286
|
* current. Debounced, backpressure-limited (one in-flight refresh plus one
|
|
@@ -236,7 +300,7 @@ export declare class AutoRAGAgent {
|
|
|
236
300
|
*/
|
|
237
301
|
private scanMirrorStaleness;
|
|
238
302
|
private exactDuplicateExclusions;
|
|
239
|
-
syncMinSync(): Promise<MinSyncSyncResult | undefined>;
|
|
303
|
+
syncMinSync(force?: boolean): Promise<MinSyncSyncResult | undefined>;
|
|
240
304
|
prepareJikji(): Promise<readonly AutoRAGJikjiPrepareResult[] | undefined>;
|
|
241
305
|
private executeJikjiPrepare;
|
|
242
306
|
/**
|
|
@@ -305,8 +369,16 @@ export declare class AutoRAGAgent {
|
|
|
305
369
|
}>;
|
|
306
370
|
/** The retrieval method registry (posix, MinSync, and datasource methods). */
|
|
307
371
|
getMethodRegistry(): RetrievalMethodRegistry;
|
|
372
|
+
/**
|
|
373
|
+
* The standalone retrieval engine for this agent's method pipeline.
|
|
374
|
+
* Built on first access using the agent's registered methods and configured
|
|
375
|
+
* datasource access context. Model-free — no agent state required.
|
|
376
|
+
*/
|
|
377
|
+
private retrievalEngine;
|
|
378
|
+
getRetrievalEngine(): RetrievalEngine;
|
|
308
379
|
getSystemPrompt(): string;
|
|
309
380
|
private rerankWithMemory;
|
|
381
|
+
private remoteFilteredRetrievalMethod;
|
|
310
382
|
private normalizeRetrievalOptions;
|
|
311
383
|
private resolveRetrievalScope;
|
|
312
384
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
export declare const EMIT_AUTORAG_RESULTS_TOOL_NAME = "emit_autorag_results";
|
|
4
|
-
declare const emitResultsSchema: Type.TObject<{
|
|
4
|
+
export declare const emitResultsSchema: Type.TObject<{
|
|
5
5
|
answer: Type.TString;
|
|
6
6
|
results: Type.TArray<Type.TObject<{
|
|
7
7
|
number: Type.TInteger;
|
|
@@ -86,4 +86,3 @@ export interface AutoRAGResultsDetails {
|
|
|
86
86
|
* assistant-text parsing involved.
|
|
87
87
|
*/
|
|
88
88
|
export declare function createEmitResultsTool(capture: (details: AutoRAGResultsDetails) => void): AgentTool<typeof emitResultsSchema, AutoRAGResultsDetails>;
|
|
89
|
-
export {};
|
|
@@ -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 {};
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { AutoRAGAgent } from "./agent.js";
|
|
|
3
3
|
export { buildDatasourceSkillsPrompt, createLoadDatasourceSkillTool, type DatasourceSkillProvider, datasourceSkillLocation, formatDatasourceSkillInvocation, LOAD_DATASOURCE_SKILL_TOOL_NAME, type LoadDatasourceSkillDetails, toDatasourceAgentSkill, } from "./datasource-skill.js";
|
|
4
4
|
export { createScanDuplicateDocumentsTool, SCAN_DUPLICATE_DOCUMENTS_TOOL_NAME, type ScanDuplicateDocumentsDetails, type ScanDuplicateDocumentsProvider, } from "./dupey-tool.js";
|
|
5
5
|
export type { AutoRAGEmittedResult, AutoRAGMappingEntry, AutoRAGResultsDetails, } from "./emit-results-tool.js";
|
|
6
|
-
export { createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME } from "./emit-results-tool.js";
|
|
6
|
+
export { createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME, emitResultsSchema, } from "./emit-results-tool.js";
|
|
7
7
|
export { createJikjiFindTool, JIKJI_FIND_TOOL_NAME, type JikjiFindDetails, type JikjiFindPerRootPolicy, type JikjiFindProvider, type JikjiFindProviderResult, type MergedJikjiPolicy, } from "./jikji-find-tool.js";
|
|
8
8
|
export { createSearchAllDocumentsTool, SEARCH_ALL_DOCUMENTS_TOOL_NAME, type SearchAllDocumentsDetails, type SearchAllDocumentsProvider, type SearchAllDocumentsResult, } from "./search-all-tool.js";
|
|
9
9
|
export { createSearchDatasourceDocumentsTool, type DatasourceSearchProvider, SEARCH_DATASOURCE_DOCUMENTS_TOOL_NAME, type SearchDatasourceDocumentsDetails, } from "./search-datasource-tool.js";
|
|
@@ -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" | "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
|