@autorag/librarian 2.0.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/LICENSE +27 -0
- package/README.md +275 -0
- package/dist/agent/agent.d.ts +294 -0
- package/dist/agent/bash-tool.d.ts +41 -0
- package/dist/agent/datasource-skill.d.ts +45 -0
- package/dist/agent/emit-results-tool.d.ts +75 -0
- package/dist/agent/index.d.ts +11 -0
- package/dist/agent/jikji-find-tool.d.ts +73 -0
- package/dist/agent/search-all-tool.d.ts +36 -0
- package/dist/agent/search-bm25-tool.d.ts +18 -0
- package/dist/agent/search-datasource-tool.d.ts +26 -0
- package/dist/agent/search-documents.d.ts +56 -0
- package/dist/agent/search-minsync-tool.d.ts +24 -0
- package/dist/agent/system-prompt.d.ts +13 -0
- package/dist/agent/watch-refresh.d.ts +29 -0
- package/dist/cli/commands/feedback.d.ts +8 -0
- package/dist/cli/commands/health.d.ts +146 -0
- package/dist/cli/commands/index.d.ts +9 -0
- package/dist/cli/commands/init.d.ts +9 -0
- package/dist/cli/commands/memory.d.ts +8 -0
- package/dist/cli/commands/refresh.d.ts +19 -0
- package/dist/cli/commands/search.d.ts +34 -0
- package/dist/cli/commands/status.d.ts +7 -0
- package/dist/cli/commands/types.d.ts +10 -0
- package/dist/cli/commands/watch.d.ts +8 -0
- package/dist/cli/config.d.ts +172 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.js +10845 -0
- package/dist/cli/output.d.ts +32 -0
- package/dist/config/home.d.ts +2 -0
- package/dist/datasource/access-context.d.ts +49 -0
- package/dist/datasource/diagnostics.d.ts +20 -0
- package/dist/datasource/index.d.ts +9 -0
- package/dist/datasource/polling.d.ts +51 -0
- package/dist/datasource/registry.d.ts +52 -0
- package/dist/datasource/result-filter.d.ts +63 -0
- package/dist/datasource/scope.d.ts +38 -0
- package/dist/datasource/skills/katok/client.d.ts +24 -0
- package/dist/datasource/skills/katok/index.d.ts +12 -0
- package/dist/datasource/skills/katok/methods.d.ts +40 -0
- package/dist/datasource/skills/katok/paths.d.ts +40 -0
- package/dist/datasource/skills/katok/skill.d.ts +33 -0
- package/dist/datasource/skills/katok/types.d.ts +146 -0
- package/dist/datasource/types.d.ts +183 -0
- package/dist/filesystem/file-lock.d.ts +16 -0
- package/dist/filesystem/source-paths.d.ts +38 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9361 -0
- package/dist/jikji/answer-pack.d.ts +31 -0
- package/dist/jikji/client.d.ts +18 -0
- package/dist/jikji/diagnostics.d.ts +26 -0
- package/dist/jikji/index.d.ts +10 -0
- package/dist/jikji/installer.d.ts +46 -0
- package/dist/jikji/path-map.d.ts +8 -0
- package/dist/jikji/types.d.ts +112 -0
- package/dist/manifest/index.d.ts +2 -0
- package/dist/manifest/loader.d.ts +3 -0
- package/dist/manifest/types.d.ts +8 -0
- package/dist/memory/check-memory-tool.d.ts +13 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/memory.d.ts +179 -0
- package/dist/memory/renderer.d.ts +6 -0
- package/dist/minsync/client.d.ts +14 -0
- package/dist/minsync/embedder-config.d.ts +22 -0
- package/dist/minsync/index.d.ts +7 -0
- package/dist/minsync/installer.d.ts +27 -0
- package/dist/minsync/method.d.ts +37 -0
- package/dist/minsync/paths.d.ts +4 -0
- package/dist/minsync/process.d.ts +10 -0
- package/dist/minsync/types.d.ts +33 -0
- package/dist/minsync/workspace.d.ts +14 -0
- package/dist/mirror/index-store.d.ts +16 -0
- package/dist/mirror/index.d.ts +5 -0
- package/dist/mirror/paths.d.ts +6 -0
- package/dist/mirror/sync.d.ts +38 -0
- package/dist/observability/run-log.d.ts +53 -0
- package/dist/parser/defaults.d.ts +6 -0
- package/dist/parser/eml.d.ts +6 -0
- package/dist/parser/errors.d.ts +5 -0
- package/dist/parser/hwp.d.ts +6 -0
- package/dist/parser/index.d.ts +10 -0
- package/dist/parser/ocr.d.ts +25 -0
- package/dist/parser/office.d.ts +16 -0
- package/dist/parser/opendataloader-pdf.d.ts +21 -0
- package/dist/parser/plain-text.d.ts +6 -0
- package/dist/parser/registry.d.ts +8 -0
- package/dist/parser/text.d.ts +2 -0
- package/dist/parser/types.d.ts +14 -0
- package/dist/parser/xml-text.d.ts +2 -0
- package/dist/retrieval/evidence-id.d.ts +16 -0
- package/dist/retrieval/index.d.ts +7 -0
- package/dist/retrieval/merger.d.ts +18 -0
- package/dist/retrieval/methods/bm25.d.ts +52 -0
- package/dist/retrieval/registry.d.ts +8 -0
- package/dist/retrieval/scope.d.ts +4 -0
- package/dist/retrieval/types.d.ts +64 -0
- package/dist/subagents/contracts.d.ts +90 -0
- package/dist/subagents/dispatch-templates.d.ts +104 -0
- package/dist/subagents/dispatch-validation.d.ts +169 -0
- package/dist/subagents/explorer-tools-extension.d.ts +4 -0
- package/dist/subagents/explorer-tools-extension.js +130 -0
- package/dist/subagents/local-models.d.ts +14 -0
- package/dist/subagents/model-policy.d.ts +31 -0
- package/dist/subagents/runtime.d.ts +52 -0
- package/dist/tool/index.d.ts +1 -0
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +66 -0
- package/skills/autorag/SKILL.md +149 -0
- package/skills/autorag-setup/SKILL.md +396 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NomaDamas / Marker Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Note: The legacy AutoRAG (Python) package located in the `legacy/` directory
|
|
26
|
+
of this repository is licensed separately under the Apache License 2.0.
|
|
27
|
+
See `legacy/LICENSE`.
|
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# AutoRAG
|
|
2
|
+
|
|
3
|
+
**A self-evolving librarian agent for document collections.**
|
|
4
|
+
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> **Looking for the original AutoRAG (RAG AutoML / pipeline optimization tool)?**
|
|
7
|
+
> This repository now hosts **AutoRAG 2.0**, a complete reimagining of AutoRAG as a self-evolving librarian agent. The original Python-based AutoRAG — the RAG AutoML tool for automatically finding an optimal RAG pipeline for your data — now lives in the [`legacy/`](legacy/) directory of this repository.
|
|
8
|
+
>
|
|
9
|
+
> **The legacy AutoRAG is NOT abandoned.** It continues to be maintained (bug fixes, dependency updates, and PyPI releases via `pip install AutoRAG`) in maintenance mode. Existing users can keep using it exactly as before — see the [legacy README](legacy/README.md) for its documentation, and file issues in this repository as usual. New feature development is focused on AutoRAG 2.0.
|
|
10
|
+
|
|
11
|
+
AutoRAG searches your PDFs, wikis, notes, research papers, and knowledge bases — then curates the results into clean, numbered knowledge units. No raw grep dumps. Just answers.
|
|
12
|
+
|
|
13
|
+
AutoRAG is a customized [Pi](https://github.com/earendil-works/pi-mono) agent — the Pi agent loop configured into a librarian. Searches use a two-tier workflow: a parent orchestrator delegates exploration to explorer agents. The roles and providers are independently configured from the models available in the user's authenticated runtime; AutoRAG does not ship a private provider default.
|
|
14
|
+
|
|
15
|
+
## Why AutoRAG
|
|
16
|
+
|
|
17
|
+
### The problem with search tools
|
|
18
|
+
|
|
19
|
+
Every search tool gives you the same thing: a list of file paths and matching lines. Then *you* have to:
|
|
20
|
+
- Open each file
|
|
21
|
+
- Read the surrounding context
|
|
22
|
+
- Decide what's relevant
|
|
23
|
+
- Synthesize an answer
|
|
24
|
+
- Remember what worked for next time
|
|
25
|
+
|
|
26
|
+
That's the human doing all the hard work. The tool just points.
|
|
27
|
+
|
|
28
|
+
### AutoRAG does the hard work
|
|
29
|
+
|
|
30
|
+
AutoRAG is not a search tool. It's a **librarian** — it searches, reads, thinks, and reports back:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
You ask: "What were the key findings in the Q3 report?"
|
|
34
|
+
|
|
35
|
+
AutoRAG:
|
|
36
|
+
[1] Revenue grew 23% YoY to $4.2M, driven by enterprise contracts. (pages 3-5)
|
|
37
|
+
[2] Three new risk factors: supply chain, regulatory, talent retention. (pages 12-14)
|
|
38
|
+
[3] Headcount target missed by 12 — engineering hiring bottleneck. (page 8)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
No file paths. No line numbers. Just curated knowledge you can act on.
|
|
42
|
+
|
|
43
|
+
### It gets smarter over time
|
|
44
|
+
|
|
45
|
+
AutoRAG has a **self-evolving memory system**. Every search teaches it something:
|
|
46
|
+
|
|
47
|
+
- Which retrieval methods work for which types of queries
|
|
48
|
+
- Which document areas are most productive
|
|
49
|
+
- What the caller found useful (via explicit feedback)
|
|
50
|
+
|
|
51
|
+
A fresh AutoRAG tries everything. A seasoned one knows exactly where to look. This is not a static configuration — it's learned behavior from real usage.
|
|
52
|
+
|
|
53
|
+
### Multiple retrieval methods, one interface
|
|
54
|
+
|
|
55
|
+
Different documents need different search strategies:
|
|
56
|
+
|
|
57
|
+
| Your documents | Best method | Why |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| Plain text, config files | grep (pattern matching) | Fast, precise, literal |
|
|
60
|
+
| Research papers, dense prose | Vector search (semantic) | Understands meaning, not just keywords |
|
|
61
|
+
| Legal documents, specifications | BM25 (keyword ranking) | Handles domain terminology well |
|
|
62
|
+
| Mixed collections | Hybrid (vector + BM25) | Combines precision and recall |
|
|
63
|
+
|
|
64
|
+
AutoRAG supports **pluggable retrieval methods**. It ships with lexical **BM25** and semantic **MinSync** methods wired through the `RetrievalMethodRegistry`, and the architecture is ready for additional vector and hybrid backends. The parent orchestrator owns process-bound retrieval tools and gives bounded seed packs to explorers; explorers use read-only `read`/`grep`/`find`/`ls` tools to inspect the underlying documents. The `ResultMerger` handles cross-method score normalization and deduplication — you get one unified result set regardless of how many methods contributed.
|
|
65
|
+
|
|
66
|
+
BM25 and MinSync are **enabled by default** — no explicit configuration is needed for standard lexical + semantic retrieval. Both can be disabled by setting `"bm25": false` or `"minSync": false` in the config file. MinSync uses a pre-installed binary (`autoInstall: false`); configure `minSync.embedder` via `autorag init --embedder-*` flags for remote embedding endpoints. AutoRAG never forces TEI or any external embedding service.
|
|
67
|
+
|
|
68
|
+
### Real directory access
|
|
69
|
+
|
|
70
|
+
AutoRAG reads configured source directories through delegated explorer tasks. Each explorer is assigned exactly one normalized configured search root as its `cwd`; the top-level `subagent` invocation sets `agentScope: "user"` and `artifacts: false` exactly once for single, `tasks`, `chain`, or `parallel` dispatch, and nested explorer task items omit both fields. Project-local `.pi-subagents` debug artifacts are disabled. Explorers use read-only `read`/`grep`/`find`/`ls`; the parent orchestrator owns retrieval seed tools and must delegate document reading before curating. Curated answers are returned as a structured `SearchDocumentsResponse`; results carry their real source (file path or datasource id) in the internal mapping for feedback and curation. BM25 and MinSync index parsed markdown mirrors under `.autorag`.
|
|
71
|
+
|
|
72
|
+
Each explorer `task` contains an Assignment V1 block — a sentinel-wrapped JSON body with `originalQuery` (the caller query verbatim), `method` (the selected retrieval path), and `queryVariants` (a nonempty array), followed by canonical role lines requiring `retrievedAt` and temporal metadata:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
<<<AUTORAG_ASSIGNMENT_V1>>>
|
|
76
|
+
{"originalQuery":"<caller query verbatim>","method":"<selected retrieval method>","queryVariants":["<variant 1>","<variant 2>"]}
|
|
77
|
+
<<<END_AUTORAG_ASSIGNMENT_V1>>>
|
|
78
|
+
Required handoff: include retrievedAt.
|
|
79
|
+
Required handoff: include temporal metadata.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A legacy labeled format (`Original query:`, `Selected retrieval method:`, `Query variants:`) is accepted for compatibility. Missing or null top-level `artifacts`, `agentScope`, and leaf `model` fields are safely autofilled before validation; explicit wrong values (`artifacts: true`, `agentScope: "project"`, a non-configured model) remain rejected. There is no single-agent fallback. See [docs/subagent-orchestration.md](docs/subagent-orchestration.md) for the full dispatch contract, templates, anti-examples, and stable coded dispatch errors.
|
|
83
|
+
|
|
84
|
+
### Optional Jikji discovery and indexing
|
|
85
|
+
|
|
86
|
+
AutoRAG can opt into [Jikji](https://github.com/NomaDamas/jikji) as a local CLI-backed **find-first discovery and indexing** layer. Jikji is optional: AutoRAG does not vendor it, install it, or register it as a retrieval backend when enabled.
|
|
87
|
+
|
|
88
|
+
When Jikji is configured, AutoRAG calls `jikji find ROOT "query" --json` via a policy-aware `jikji_find` tool as the first local-discovery action. The tool parses and validates the upstream answer-pack and honors its `handoff_action` (`direct_use` / `jikji_retry` / `raw_fallback_after_retry`), `tool_call_policy` (`stop_after_find`, `forbidden_tools`, `allowed_followups`), and `agent_should_not_rerank`. Explorer `read`/`grep`/`find`/`ls` discovery is the fallback only when the answer-pack permits raw fallback (`raw_fallback_after_retry`, after the required retry) or when Jikji is unavailable/unconfigured. `prepare`/`refresh` remain for indexing only and do not answer queries directly.
|
|
89
|
+
|
|
90
|
+
Programmatic use:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const agent = new AutoRAGAgent({
|
|
94
|
+
searchPaths: ["/path/to/documents"],
|
|
95
|
+
jikji: { binaryPath: "jikji" },
|
|
96
|
+
});
|
|
97
|
+
await agent.prepareJikji();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The same `.autorag/jikji.json` shape configures Jikji when present:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"enabled": true,
|
|
105
|
+
"binaryPath": "jikji",
|
|
106
|
+
"timeoutMs": 10000,
|
|
107
|
+
"maxBufferBytes": 1048576,
|
|
108
|
+
"includeHidden": false,
|
|
109
|
+
"includeSensitive": false,
|
|
110
|
+
"maxFiles": 0,
|
|
111
|
+
"writeAgentRules": false,
|
|
112
|
+
"enableMediaIndex": false,
|
|
113
|
+
"exclude": []
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Call `agent.prepareJikji()` (or `agent.refresh()`) to prepare configured source roots. Hidden files, sensitive files, and media indexing are disabled by default; AutoRAG does not pass `--include-hidden`, `--include-sensitive`, or `--enable-media-index` unless the corresponding option is `true`. AutoRAG-managed prepare runs with `--no-agent-rules` by default, so it never rewrites the consumer repo's `AGENTS.md`/`CLAUDE.md`/`.cursorrules`; an explicit `writeAgentRules: true` opt-in re-enables upstream routing-block injection. AutoRAG passes `--enable-media-index` only when `enableMediaIndex: true`.
|
|
118
|
+
|
|
119
|
+
The upstream Rust `PrepareArgs` defines reference defaults that AutoRAG does not override unless explicitly configured: parse timeout `5.0`, max hash bytes `512 MiB`, doc text max chars `2,000,000`, doc text chunk chars `1,000,000`, and media index max MB `25.0`. AutoRAG emits `--parse-timeout`, `--max-hash-bytes`, `--doc-text-max-chars`, `--doc-text-chunk-chars`, and `--media-index-max-mb` only when the matching option is set, so the upstream defaults apply otherwise. AutoRAG answers queries through `jikji find` (find-first) plus the Pi agent loop and its registered retrieval methods; `prepare`/`refresh` are indexing-only.
|
|
120
|
+
|
|
121
|
+
### Datasource skills
|
|
122
|
+
|
|
123
|
+
Datasource skills let AutoRAG search external, server-configured data sources through the same retrieval pipeline as local documents. A skill describes what it indexes, how it should be refreshed, what source instances exist, and which permission tags/scopes bound access. Retrieval still flows through `RetrievalMethodRegistry` → `ParallelRetriever` → datasource result filtering → `ResultMerger`; datasource skills do not create a parallel search path.
|
|
124
|
+
|
|
125
|
+
Security defaults are intentionally strict:
|
|
126
|
+
|
|
127
|
+
- datasource access is default-deny unless trusted server/API configuration supplies `datasourceAccess.allowedTags` and `datasourceAccess.allowedScopes`;
|
|
128
|
+
- model/tool arguments never grant datasource tags or scopes;
|
|
129
|
+
- `search_datasource_documents` accepts only `{ query, topK?, scope? }`, and `scope` can only narrow trusted access.
|
|
130
|
+
|
|
131
|
+
KakaoTalk is the first datasource skill. It uses the external [`katok`](https://github.com/NomaDamas/katok) CLI only — AutoRAG never reads KakaoTalk databases directly. `katok` failures return diagnostics instead of throwing, and remote embedding egress configuration is rejected before the CLI is spawned.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { AutoRAGAgent, KatokSkill } from "@autorag/librarian";
|
|
135
|
+
|
|
136
|
+
const kakao = new KatokSkill({
|
|
137
|
+
instanceId: "personal",
|
|
138
|
+
tags: ["kakaotalk", "personal", "pii"],
|
|
139
|
+
// Optional: client: new KatokClient({ binaryPath: "katok" })
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const agent = new AutoRAGAgent({
|
|
143
|
+
searchPaths: ["/path/to/documents"],
|
|
144
|
+
datasourceSkills: [kakao],
|
|
145
|
+
datasourceAccess: {
|
|
146
|
+
allowedTags: ["kakaotalk"],
|
|
147
|
+
allowedScopes: ["/kakao/personal/**"],
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
await agent.refresh(); // refreshes parsed mirrors, BM25/MinSync, and datasource indexes
|
|
152
|
+
const results = await agent.searchDatasourceDocuments("meeting with Mina", { topK: 5 });
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
A datasource skill should provide polling/cron metadata for routine indexing, source descriptions for the agent prompt, slash-hierarchical opaque source paths such as `/kakao/personal/chunks/<chunk-id>`, and permission tags that match your server-side access policy.
|
|
156
|
+
|
|
157
|
+
### Primary target: document collections
|
|
158
|
+
|
|
159
|
+
AutoRAG is built for **non-code document retrieval**: manuals, legal docs, internal wikis, meeting notes, research literature, knowledge bases, PDFs.
|
|
160
|
+
|
|
161
|
+
Code repositories work too (the explorer's `grep` is useful), but AutoRAG's real value shows on unstructured text where simple pattern matching isn't enough.
|
|
162
|
+
|
|
163
|
+
## Configuration and state
|
|
164
|
+
|
|
165
|
+
The default home state is kept outside the workspace:
|
|
166
|
+
|
|
167
|
+
```text
|
|
168
|
+
~/.autorag/
|
|
169
|
+
├── config.json
|
|
170
|
+
├── memory.json
|
|
171
|
+
├── logs/
|
|
172
|
+
│ └── runs.jsonl
|
|
173
|
+
└── pi-agent/
|
|
174
|
+
├── auth.json
|
|
175
|
+
├── models.json
|
|
176
|
+
├── settings.json
|
|
177
|
+
└── sessions/
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`config.json` selects sources, the workspace, memory path, retrieval settings, and the two agent models. Configure the roles independently with `agents.orchestrator` and `agents.explorer`. Provider and model IDs must refer to models available in the user's authenticated runtime:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"searchPaths": ["/path/to/documents"],
|
|
185
|
+
"workspacePath": "/path/to/workspace",
|
|
186
|
+
"memoryPath": "/Users/you/.autorag/memory.json",
|
|
187
|
+
"agents": {
|
|
188
|
+
"orchestrator": { "provider": "provider-name", "id": "reasoning-model" },
|
|
189
|
+
"explorer": { "provider": "provider-name", "id": "exploration-model" }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`autorag init` leaves `agents` unset when no role-model flags are supplied. At search time AutoRAG resolves an authenticated local provider when possible; otherwise configure both roles explicitly.
|
|
195
|
+
|
|
196
|
+
Config path precedence is `--config` > `AUTORAG_CONFIG` > `~/.autorag/config.json`. When the home config is absent and `<cwd>/autorag.config.json` exists, AutoRAG copies the legacy file to `~/.autorag/config.json` without deleting or modifying the legacy file. The legacy cwd file is a migration source, not the default location.
|
|
197
|
+
|
|
198
|
+
`memory.json` stores retrieval memory, `logs/runs.jsonl` records run events, and durable Pi models, settings, and sessions stay under `~/.autorag/pi-agent`. Corpus indexes remain workspace-local: refresh keeps parsed mirrors and BM25/MinSync indexes under `<workspace>/.autorag`.
|
|
199
|
+
|
|
200
|
+
`autorag refresh` and `autorag index reset|rebuild` accept `--method <csv>` (e.g. `--method bm25,minsync,parsed`) to scope which indexing methods run or which index directories are removed. When omitted, all methods run. `autorag init` accepts `--embedder-*` flags to configure the MinSync embedder endpoint in the config file.
|
|
201
|
+
|
|
202
|
+
`autorag health` checks model/provider auth and explorer subagent setup before a search — it resolves both role models, verifies credential presence, and optionally probes a completion call per role. Use it to diagnose model, provider, auth, timeout, or subagent dispatch failures. `autorag status` remains the model-free index-health command (corpus freshness and BM25/MinSync readiness); it does not check models or subagent dispatch. When `autorag search` fails for a model/provider/subagent reason, the error output includes a hint pointing to `autorag health`.
|
|
203
|
+
|
|
204
|
+
## Installation
|
|
205
|
+
|
|
206
|
+
Published as `@autorag/librarian` (dist bundled with Bun, runtime Node ≥ 24 or Bun):
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
bun add @autorag/librarian # library
|
|
210
|
+
bun install -g @autorag/librarian # autorag CLI
|
|
211
|
+
# or run directly from the repo:
|
|
212
|
+
bun add github:NomaDamas/AutoRAG-2.0
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Git-based installs build `dist/` via the `prepare` script and require Bun on the installing machine.
|
|
216
|
+
External tool binaries auto-install on first use into `<workspace>/.autorag/bin`: **MinSync** downloads a verified GitHub release asset (on by default; `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`) stays a manual, optional install. All of them degrade gracefully when missing — core BM25 search works without any of them.
|
|
217
|
+
|
|
218
|
+
## Quick Start
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import { AutoRAGAgent } from "@autorag/librarian";
|
|
222
|
+
|
|
223
|
+
const agent = new AutoRAGAgent({
|
|
224
|
+
searchPaths: ["/path/to/documents"],
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const response = await agent.searchDocuments("summarize the compliance requirements");
|
|
228
|
+
console.log(response.answer);
|
|
229
|
+
for (const result of response.results) {
|
|
230
|
+
console.log(`[${result.number}] ${result.title} — ${result.summary}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Mark which results were useful — AutoRAG remembers for next time
|
|
234
|
+
agent.recordFeedbackByNumbers(response.sessionId, [1, 3], [2]);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`searchDocuments()` runs the Pi agent loop — it searches, reads, consults memory, curates, and finalizes through the `emit_autorag_results` structured tool — then returns a typed `SearchDocumentsResponse`. The caller consumes the structured payload directly; no assistant text parsing.
|
|
238
|
+
|
|
239
|
+
## How It Works
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
You ask a question
|
|
243
|
+
│
|
|
244
|
+
▼
|
|
245
|
+
┌──────────────┐
|
|
246
|
+
│ Plan + seed │ ← parent check_memory, Jikji, and retrieval tools
|
|
247
|
+
└──────┬───────┘
|
|
248
|
+
▼
|
|
249
|
+
┌──────────────┐
|
|
250
|
+
│ Delegate │ ← pi-subagents → gpt-5.6-luna explorer
|
|
251
|
+
└──────┬───────┘
|
|
252
|
+
▼
|
|
253
|
+
┌──────────────┐
|
|
254
|
+
│ Search + read│ ← explorer read/grep/find/ls
|
|
255
|
+
└──────┬──────┘
|
|
256
|
+
▼
|
|
257
|
+
┌─────────────┐
|
|
258
|
+
│ Curate │ ← Extract key insights, not raw lines
|
|
259
|
+
└──────┬──────┘
|
|
260
|
+
▼
|
|
261
|
+
[1] Finding A — summary (location)
|
|
262
|
+
[2] Finding B — summary (location)
|
|
263
|
+
|
|
264
|
+
│
|
|
265
|
+
Caller says "1 was useful, 2 wasn't"
|
|
266
|
+
│
|
|
267
|
+
▼
|
|
268
|
+
┌─────────────┐
|
|
269
|
+
│ Memory │ ← Remembers what worked, adapts next time
|
|
270
|
+
└─────────────┘
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
MIT
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { Agent, type AgentTool, type Skill } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
3
|
+
import { type DatasourceAccessContextOptions } from "../datasource/access-context.js";
|
|
4
|
+
import type { DatasourceIndexResult, DatasourceSkill } from "../datasource/types.js";
|
|
5
|
+
import { type JikjiFailureReason, type JikjiOptions } from "../jikji/index.js";
|
|
6
|
+
import type { ResultFeedback } from "../memory/memory.js";
|
|
7
|
+
import { type MinSyncSyncResult, type MinSyncVectorMethodOptions } from "../minsync/index.js";
|
|
8
|
+
import { type ParsedMirrorSyncResult } from "../mirror/sync.js";
|
|
9
|
+
import type { DefaultParserRegistryOptions } from "../parser/index.js";
|
|
10
|
+
import { type BM25MethodOptions, type BM25SyncResult } from "../retrieval/methods/bm25.js";
|
|
11
|
+
import { RetrievalMethodRegistry } from "../retrieval/registry.js";
|
|
12
|
+
import type { CuratedResult, RetrievalDiagnostic, RetrievalOptions, RetrievalResult } from "../retrieval/types.js";
|
|
13
|
+
import { type MandatorySubagentSessionOptions } from "../subagents/runtime.js";
|
|
14
|
+
import { type JikjiFindProviderResult } from "./jikji-find-tool.js";
|
|
15
|
+
import { type SearchDocumentDiagnostic, type SearchDocumentsResponse } from "./search-documents.js";
|
|
16
|
+
import { type WatcherFactory, type WatchRefreshHandle } from "./watch-refresh.js";
|
|
17
|
+
export interface AutoRefreshOptions {
|
|
18
|
+
readonly intervalMs: number;
|
|
19
|
+
readonly immediate?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Methods that `refresh` can selectively run. Defaults to all when omitted. */
|
|
22
|
+
export type RefreshMethod = "parsed" | "bm25" | "minsync" | "datasources" | "jikji";
|
|
23
|
+
export interface AutoRAGRefreshOptions {
|
|
24
|
+
/** Restrict refresh to specific methods. Defaults to all when undefined. */
|
|
25
|
+
readonly methods?: readonly RefreshMethod[];
|
|
26
|
+
}
|
|
27
|
+
export interface AutoRAGRefreshResult extends ParsedMirrorSyncResult {
|
|
28
|
+
readonly bm25?: BM25SyncResult;
|
|
29
|
+
readonly datasources?: readonly DatasourceIndexResult[];
|
|
30
|
+
}
|
|
31
|
+
export interface AutoRAGRefreshComponentStatus {
|
|
32
|
+
readonly bm25?: string;
|
|
33
|
+
readonly minsync?: string;
|
|
34
|
+
readonly jikji?: string;
|
|
35
|
+
readonly datasources?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Path-opaque snapshot of corpus freshness and the last refresh outcome. */
|
|
38
|
+
export interface AutoRAGRefreshStatus {
|
|
39
|
+
readonly state: "idle" | "indexing" | "success" | "failed";
|
|
40
|
+
readonly inFlight: boolean;
|
|
41
|
+
readonly lastStartedAt?: string;
|
|
42
|
+
readonly lastFinishedAt?: string;
|
|
43
|
+
readonly counts?: {
|
|
44
|
+
readonly scanned: number;
|
|
45
|
+
readonly written: number;
|
|
46
|
+
readonly deleted: number;
|
|
47
|
+
readonly skipped: number;
|
|
48
|
+
};
|
|
49
|
+
readonly stale: boolean;
|
|
50
|
+
readonly diagnostics: readonly SearchDocumentDiagnostic[];
|
|
51
|
+
readonly components: AutoRAGRefreshComponentStatus;
|
|
52
|
+
/** Path-free failure summary of the last refresh, if it failed. */
|
|
53
|
+
readonly lastError?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface AutoRAGWatchRefreshOptions {
|
|
56
|
+
readonly debounceMs?: number;
|
|
57
|
+
readonly force?: boolean;
|
|
58
|
+
readonly maxWatchers?: number;
|
|
59
|
+
/** Injectable watcher factory (defaults to a recursive fs.watch). Primarily for tests. */
|
|
60
|
+
readonly watcherFactory?: WatcherFactory;
|
|
61
|
+
}
|
|
62
|
+
export type AutoRAGWatchRefreshHandle = WatchRefreshHandle;
|
|
63
|
+
export interface AutoRAGAgentOptions {
|
|
64
|
+
model?: Model<Api>;
|
|
65
|
+
explorerModel?: Model<Api>;
|
|
66
|
+
apiKey?: string;
|
|
67
|
+
providerApiKeys?: Readonly<Record<string, string>>;
|
|
68
|
+
searchPaths: string[];
|
|
69
|
+
manifestDir?: string;
|
|
70
|
+
memoryPath?: string;
|
|
71
|
+
workspacePath?: string;
|
|
72
|
+
tools?: AgentTool[];
|
|
73
|
+
minSync?: Omit<MinSyncVectorMethodOptions, "root"> | false;
|
|
74
|
+
bm25?: Omit<BM25MethodOptions, "root"> | false;
|
|
75
|
+
jikji?: JikjiOptions;
|
|
76
|
+
autoRefresh?: AutoRefreshOptions;
|
|
77
|
+
parserOptions?: DefaultParserRegistryOptions;
|
|
78
|
+
datasourceSkills?: readonly DatasourceSkill[];
|
|
79
|
+
datasourceAccess?: DatasourceAccessContextOptions;
|
|
80
|
+
sessionFactory?: AutoRAGSessionFactory;
|
|
81
|
+
}
|
|
82
|
+
export interface AutoRAGSearchSession {
|
|
83
|
+
readonly agent: Agent;
|
|
84
|
+
prompt(text: string): Promise<void>;
|
|
85
|
+
abort(): Promise<void> | void;
|
|
86
|
+
dispose(): void;
|
|
87
|
+
}
|
|
88
|
+
export type AutoRAGSessionFactory = (options: MandatorySubagentSessionOptions) => Promise<AutoRAGSearchSession>;
|
|
89
|
+
export type AutoRAGJikjiPrepareResult = {
|
|
90
|
+
readonly ok: true;
|
|
91
|
+
readonly code: number;
|
|
92
|
+
readonly diagnostics: readonly string[];
|
|
93
|
+
} | {
|
|
94
|
+
readonly ok: false;
|
|
95
|
+
readonly reason: JikjiFailureReason;
|
|
96
|
+
readonly code: number | null;
|
|
97
|
+
readonly diagnostics: readonly string[];
|
|
98
|
+
};
|
|
99
|
+
export declare class AutoRAGAgent {
|
|
100
|
+
private readonly innerAgent;
|
|
101
|
+
private readonly tools;
|
|
102
|
+
private readonly configuredModel;
|
|
103
|
+
private readonly configuredExplorerModel;
|
|
104
|
+
private readonly apiKey;
|
|
105
|
+
private readonly providerApiKeys;
|
|
106
|
+
private readonly sessionFactory;
|
|
107
|
+
private readonly listeners;
|
|
108
|
+
private activeSession;
|
|
109
|
+
private readonly pendingSubagentCalls;
|
|
110
|
+
private readonly dispatchSequenceBySession;
|
|
111
|
+
private readonly dispatchArgsTracker;
|
|
112
|
+
private dispatchSyntheticCounter;
|
|
113
|
+
private successfulExplorerCalls;
|
|
114
|
+
private readonly memory;
|
|
115
|
+
private readonly runLogger;
|
|
116
|
+
private lastQuery;
|
|
117
|
+
private lastSessionId;
|
|
118
|
+
private readonly sessions;
|
|
119
|
+
private activeRun;
|
|
120
|
+
private resultCapture;
|
|
121
|
+
private autoRefreshTimer;
|
|
122
|
+
private refreshing;
|
|
123
|
+
private refreshState;
|
|
124
|
+
private readonly searchPaths;
|
|
125
|
+
private readonly allowedExplorerRoots;
|
|
126
|
+
private readonly workspaceProjectRoot;
|
|
127
|
+
private readonly methodRegistry;
|
|
128
|
+
private readonly retriever;
|
|
129
|
+
private readonly merger;
|
|
130
|
+
private readonly datasourceFilter;
|
|
131
|
+
private readonly minSyncMethod;
|
|
132
|
+
private readonly bm25Method;
|
|
133
|
+
private readonly jikjiClient;
|
|
134
|
+
private readonly datasourceSkills;
|
|
135
|
+
private readonly datasourceAccessOptions;
|
|
136
|
+
private readonly datasourceAgentSkills;
|
|
137
|
+
private readonly parserOptions;
|
|
138
|
+
private readonly baseSystemPromptConfig;
|
|
139
|
+
/** Run-scoped merged Jikji policy, set during searchDocuments; cleared after. */
|
|
140
|
+
private activeJikjiPolicy;
|
|
141
|
+
private activeExplorerModel;
|
|
142
|
+
/** Run-scoped jikji_find call count for the two-phase raw-fallback gate. */
|
|
143
|
+
private jikjiFindCallCount;
|
|
144
|
+
private readonly droppedCallerToolNames;
|
|
145
|
+
constructor(options: AutoRAGAgentOptions);
|
|
146
|
+
private withMemoryContext;
|
|
147
|
+
private resolveSessionModel;
|
|
148
|
+
private configureSearchSession;
|
|
149
|
+
private recordSearchToolEvent;
|
|
150
|
+
private nextDispatchSequence;
|
|
151
|
+
private resolveToolCallId;
|
|
152
|
+
private emitDispatchAutofilled;
|
|
153
|
+
private emitDispatchRejected;
|
|
154
|
+
private emitDispatchRejectedFromRejection;
|
|
155
|
+
private currentSystemPromptConfig;
|
|
156
|
+
subscribe(listener: Parameters<Agent["subscribe"]>[0]): () => void;
|
|
157
|
+
abort(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Periodically re-runs the incremental {@link refresh} so parsed mirrors and
|
|
160
|
+
* indexes stay current. Re-parsing is incremental (mtime/size) via the
|
|
161
|
+
* existing mirror sync; this only schedules it. Opt-in and stoppable.
|
|
162
|
+
*/
|
|
163
|
+
startAutoRefresh(intervalMs: number, options?: {
|
|
164
|
+
immediate?: boolean;
|
|
165
|
+
}): void;
|
|
166
|
+
stopAutoRefresh(): void;
|
|
167
|
+
private runAutoRefreshTick;
|
|
168
|
+
submitFeedback(sessionId: string | undefined, satisfied: boolean): void;
|
|
169
|
+
recordResultFeedback(feedback: ResultFeedback[]): void;
|
|
170
|
+
recordFeedbackByNumbers(sessionId: string, usefulNumbers: number[], notUsefulNumbers?: number[]): void;
|
|
171
|
+
getResultRegistry(sessionId?: string): ReadonlyMap<number, CuratedResult>;
|
|
172
|
+
searchDocuments(query: string, options?: RetrievalOptions): Promise<SearchDocumentsResponse>;
|
|
173
|
+
private datasourceAccessContext;
|
|
174
|
+
/**
|
|
175
|
+
* Build the Pi agent-skill list for datasource skills authorized by the
|
|
176
|
+
* trusted, server-bound access context. Only authorized skills become
|
|
177
|
+
* model-visible; unauthorized skills are omitted entirely (default-deny).
|
|
178
|
+
*/
|
|
179
|
+
private buildAuthorizedDatasourceSkills;
|
|
180
|
+
/**
|
|
181
|
+
* Resolve an authorized datasource agent skill by model-visible name for the
|
|
182
|
+
* `load_datasource_skill` tool. Returns `undefined` for unknown or
|
|
183
|
+
* unauthorized names — model/tool input can never widen authorization.
|
|
184
|
+
*/
|
|
185
|
+
loadDatasourceSkill(name: string): Skill | undefined;
|
|
186
|
+
private indexDatasources;
|
|
187
|
+
/** Path-opaque component diagnostics (e.g. BM25 readiness) for the search response. */
|
|
188
|
+
private collectComponentDiagnostics;
|
|
189
|
+
buildSearchPrompt(query: string, options: RetrievalOptions, explorerModel?: string): string;
|
|
190
|
+
refresh(force?: boolean, opts?: AutoRAGRefreshOptions): Promise<AutoRAGRefreshResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Path-opaque snapshot of corpus freshness and the last refresh outcome. Runs
|
|
193
|
+
* a cheap parse-free staleness scan (stat only); never parses in this path.
|
|
194
|
+
*/
|
|
195
|
+
getRefreshStatus(): Promise<AutoRAGRefreshStatus>;
|
|
196
|
+
private refreshComponentStatus;
|
|
197
|
+
/**
|
|
198
|
+
* Opt-in filesystem watch that keeps parsed mirrors and configured indexes
|
|
199
|
+
* current. Debounced, backpressure-limited (one in-flight refresh plus one
|
|
200
|
+
* coalesced rerun), stoppable, and safe under rapid change bursts. Excludes
|
|
201
|
+
* `.autorag`/`.git`/`node_modules` and does not follow symlinks. Coexists with
|
|
202
|
+
* the polling {@link startAutoRefresh}. Returns a handle whose stop() closes
|
|
203
|
+
* every watcher and prevents any further scheduled refresh.
|
|
204
|
+
*/
|
|
205
|
+
startWatchRefresh(options?: AutoRAGWatchRefreshOptions): AutoRAGWatchRefreshHandle;
|
|
206
|
+
private defaultWatcherFactory;
|
|
207
|
+
syncParsedMirrors(force?: boolean): Promise<ParsedMirrorSyncResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Lightweight stat-only staleness scan used when `refresh` is called with
|
|
210
|
+
* methods that exclude parsed mirrors (e.g. only `datasources` or `jikji`).
|
|
211
|
+
* Returns a zero-count `ParsedMirrorSyncResult` carrying fresh diagnostics
|
|
212
|
+
* so the refresh result and status remain consistent.
|
|
213
|
+
*/
|
|
214
|
+
private scanMirrorStaleness;
|
|
215
|
+
syncBM25(): Promise<BM25SyncResult | undefined>;
|
|
216
|
+
syncMinSync(): Promise<MinSyncSyncResult | undefined>;
|
|
217
|
+
prepareJikji(): Promise<readonly AutoRAGJikjiPrepareResult[] | undefined>;
|
|
218
|
+
private executeJikjiPrepare;
|
|
219
|
+
private sanitizeJikjiPrepareResult;
|
|
220
|
+
/**
|
|
221
|
+
* Provider method for the jikji_find tool. Runs JikjiClient.find over all
|
|
222
|
+
* configured search roots, normalizes answer paths against planned source
|
|
223
|
+
* roots, merges per-root answer packs using least-privilege (restrictive-
|
|
224
|
+
* wins) semantics, and sets the run-scoped activeJikjiPolicy. Only mutates
|
|
225
|
+
* run state (activeJikjiPolicy / jikjiFindCallCount) when a searchDocuments
|
|
226
|
+
* run is active; direct out-of-run calls compute and return the result
|
|
227
|
+
* without persisting. When jikji is unavailable or all roots fail, returns
|
|
228
|
+
* an unavailable result and leaves the policy undefined (bash is allowed).
|
|
229
|
+
*/
|
|
230
|
+
findJikji(query: string, opts?: {
|
|
231
|
+
readonly topK?: number;
|
|
232
|
+
readonly first?: boolean;
|
|
233
|
+
}): Promise<JikjiFindProviderResult>;
|
|
234
|
+
/**
|
|
235
|
+
* Merge per-root answer packs into one. Concatenates answer_paths/candidates
|
|
236
|
+
* preserving per-root order; dedupes by normalized path. Does NOT cross-root
|
|
237
|
+
* rerank when any root has agentShouldNotRerank=true.
|
|
238
|
+
*/
|
|
239
|
+
private mergeAnswerPacks;
|
|
240
|
+
/**
|
|
241
|
+
* Least-privilege (restrictive-wins) merge of per-root policies.
|
|
242
|
+
* - forbiddenTools: UNION
|
|
243
|
+
* - allowedFollowups: INTERSECTION
|
|
244
|
+
* - stopAfterFind: OR
|
|
245
|
+
* - agentShouldNotRerank: OR
|
|
246
|
+
* - handoffAction: MOST RESTRICTIVE (direct_use < jikji_retry < raw_fallback_after_retry)
|
|
247
|
+
* - rawFallbackAllowed: handoffAction===raw_fallback_after_retry AND callCount>=2
|
|
248
|
+
*/
|
|
249
|
+
private mergePolicy;
|
|
250
|
+
/**
|
|
251
|
+
* Deny-by-default bash gate. When jikji is configured but no jikji_find has
|
|
252
|
+
* run yet this run (count===0), bash is blocked so the agent discovers local
|
|
253
|
+
* files via jikji_find first. After a find, the run-scoped activeJikjiPolicy
|
|
254
|
+
* applies: when no policy is active, bash behaves exactly as before
|
|
255
|
+
* (allowed). Under an active policy, bash is denied unless handoffAction is
|
|
256
|
+
* raw_fallback_after_retry AND rawFallbackAllowed is true (after a second
|
|
257
|
+
* jikji_find). When jikji is not configured, the find-first branch is
|
|
258
|
+
* skipped entirely (bash unchanged).
|
|
259
|
+
*/
|
|
260
|
+
private bashGate;
|
|
261
|
+
/**
|
|
262
|
+
* Programmatic retrieval across all registered methods, merged via min-max
|
|
263
|
+
* normalization + source dedup. Activates the RetrievalMethodRegistry /
|
|
264
|
+
* ParallelRetriever / ResultMerger pipeline. Returns opaque root-relative
|
|
265
|
+
* sourced results.
|
|
266
|
+
*/
|
|
267
|
+
retrieve(query: string, options?: RetrievalOptions): Promise<RetrievalResult[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Programmatic retrieval that also returns diagnostics for any
|
|
270
|
+
* retrieval method that failed (e.g. MinSync binary missing). Healthy method
|
|
271
|
+
* results are preserved. The legacy {@link retrieve} return shape is unchanged.
|
|
272
|
+
*/
|
|
273
|
+
retrieveWithDiagnostics(query: string, options?: RetrievalOptions): Promise<{
|
|
274
|
+
results: RetrievalResult[];
|
|
275
|
+
diagnostics: RetrievalDiagnostic[];
|
|
276
|
+
}>;
|
|
277
|
+
searchAllDocuments(query: string, options?: {
|
|
278
|
+
readonly topK?: number;
|
|
279
|
+
readonly scope?: string;
|
|
280
|
+
}): Promise<{
|
|
281
|
+
results: RetrievalResult[];
|
|
282
|
+
diagnostics: RetrievalDiagnostic[];
|
|
283
|
+
}>;
|
|
284
|
+
searchDatasourceDocuments(query: string, options?: {
|
|
285
|
+
readonly topK?: number;
|
|
286
|
+
readonly scope?: string;
|
|
287
|
+
}): Promise<{
|
|
288
|
+
results: RetrievalResult[];
|
|
289
|
+
diagnostics: RetrievalDiagnostic[];
|
|
290
|
+
}>;
|
|
291
|
+
/** The retrieval method registry (posix active; vector/bm25/hybrid pluggable). */
|
|
292
|
+
getMethodRegistry(): RetrievalMethodRegistry;
|
|
293
|
+
getSystemPrompt(): string;
|
|
294
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
export declare const BASH_TOOL_NAME = "bash";
|
|
4
|
+
declare const bashSchema: Type.TObject<{
|
|
5
|
+
command: Type.TString;
|
|
6
|
+
cwd: Type.TOptional<Type.TString>;
|
|
7
|
+
timeoutMs: Type.TOptional<Type.TInteger>;
|
|
8
|
+
}>;
|
|
9
|
+
export interface BashToolOptions {
|
|
10
|
+
/** Default working directory for spawned commands. */
|
|
11
|
+
readonly cwd: string;
|
|
12
|
+
/** Maximum wall-clock time per command before it is killed. */
|
|
13
|
+
readonly timeoutMs?: number;
|
|
14
|
+
/** Maximum captured output bytes before truncation. */
|
|
15
|
+
readonly maxOutputBytes?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Optional deny-by-default gate. When present and returns
|
|
18
|
+
* `{ allowed: false }`, the command is NOT spawned; the tool returns the
|
|
19
|
+
* gate message with `blockedByJikjiPolicy: true`. Used by the Jikji policy
|
|
20
|
+
* to enforce stop_after_find / direct_use / forbidden bash restrictions.
|
|
21
|
+
*/
|
|
22
|
+
readonly gate?: () => {
|
|
23
|
+
allowed: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface BashToolDetails {
|
|
28
|
+
readonly method: "bash";
|
|
29
|
+
readonly command: string;
|
|
30
|
+
readonly exitCode: number | undefined;
|
|
31
|
+
readonly timedOut: boolean;
|
|
32
|
+
readonly truncated: boolean;
|
|
33
|
+
readonly blockedByJikjiPolicy?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Real shell access for the librarian agent. AutoRAG navigates and reads the
|
|
37
|
+
* configured collection directly through this tool (ls, find, grep, cat, …).
|
|
38
|
+
* Output — including real filesystem paths — is returned to the model verbatim.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createBashTool(options: BashToolOptions): AgentTool<typeof bashSchema, BashToolDetails>;
|
|
41
|
+
export {};
|