pi-knowledge 0.4.7 → 0.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/CHANGELOG.md +25 -0
- package/README.md +19 -12
- package/dist/index.js +186 -42
- package/dist/src/diagnostics/health.d.ts +1 -1
- package/dist/src/diagnostics/health.js +13 -12
- package/dist/src/embedding/provider.d.ts +1 -1
- package/dist/src/embedding/provider.js +12 -4
- package/dist/src/engine.d.ts +61 -10
- package/dist/src/engine.js +591 -186
- package/dist/src/indexer/chunker.d.ts +3 -1
- package/dist/src/indexer/chunker.js +57 -48
- package/dist/src/indexer/symbols.d.ts +2 -0
- package/dist/src/indexer/symbols.js +175 -0
- package/dist/src/model-worker-client.d.ts +1 -1
- package/dist/src/model-worker-client.js +7 -7
- package/dist/src/search/reranker.d.ts +1 -1
- package/dist/src/search/reranker.js +2 -2
- package/dist/src/search/vector.d.ts +1 -1
- package/dist/src/search/vector.js +5 -1
- package/dist/src/storage/sqlite.d.ts +36 -1
- package/dist/src/storage/sqlite.js +159 -2
- package/dist/src/watcher/file-watcher.d.ts +2 -1
- package/dist/src/watcher/file-watcher.js +20 -30
- package/docs/configuration.md +10 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.1] - 2026-07-07
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Indexed PDF/DOC/DOCX files discovered during directory add and update through the document extractors instead of treating them as binary skips.
|
|
7
|
+
- Skipped failed directory document extraction as `extraction_failed` without failing the whole knowledge base.
|
|
8
|
+
- Required explicit `confirm: true` for public destructive `knowledge_remove` and `knowledge_clear` tool calls.
|
|
9
|
+
- Aligned `path_pattern` documentation and tool guidance with the implemented substring filter behavior.
|
|
10
|
+
|
|
11
|
+
## [0.5.0] - 2026-07-07
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Added route symbol extraction and exact route lookup support through `knowledge_symbol_search`.
|
|
15
|
+
- Added structured `details` payloads for search diagnostics and doctor actions so agents can consume provenance and remediation codes without parsing text.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Deleted vector files when knowledge bases are removed or cleared, including orphan detection in diagnostics.
|
|
19
|
+
- Guarded destructive and long-running operations with stronger mutation and shutdown lifecycle checks.
|
|
20
|
+
- Preserved ready knowledge bases when update cancellation happens before mutation starts, and kept partial update state from polluting symbol search.
|
|
21
|
+
- Propagated cancellation through search, export, import, diagnostics, and external embedding API requests.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Reworked JSONL import/export around streaming I/O and bounded batches for large portable knowledge bases.
|
|
25
|
+
- Improved watcher exclusions so generated, vendor, and runtime artifacts do not trigger unnecessary scans.
|
|
26
|
+
- Expanded Pi/OMP release coverage with lifecycle, cancellation, watcher, symbol, tool-contract, and model-worker regressions.
|
|
27
|
+
|
|
3
28
|
## [0.4.7] - 2026-07-04
|
|
4
29
|
|
|
5
30
|
### Fixed
|
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Built as a native [Pi extension](https://pi.dev/docs/latest/extensions) with ver
|
|
|
11
11
|
Agents lose project context between sessions and cannot fit large repositories into one prompt. `pi-knowledge` gives Pi and OMP durable, searchable project memory:
|
|
12
12
|
|
|
13
13
|
- Search code and documentation by meaning, exact symbols, or both.
|
|
14
|
+
- Look up lightweight code symbols, Markdown headings, config keys, and environment variables before broader search.
|
|
14
15
|
- Keep private source data local by default.
|
|
15
16
|
- Re-index changed files incrementally.
|
|
16
17
|
- Diagnose stale, stuck, or low-quality indexes.
|
|
@@ -21,8 +22,9 @@ Unlike `pi-memory` (which manages the agent's own notes), `pi-knowledge` indexes
|
|
|
21
22
|
## Highlights
|
|
22
23
|
|
|
23
24
|
- **Local-first project memory**: stores indexes under `~/.pi/knowledge/`; no project files are modified.
|
|
24
|
-
- **Hybrid retrieval**:
|
|
25
|
+
- **Hybrid retrieval**: lexical-anchored BM25 + semantic vectors + normalized weighted score fusion, with semantic mode for vector-only conceptual recall.
|
|
25
26
|
- **Code-aware indexing**: AST-aware chunking for TypeScript/JavaScript, Python, Go, Rust, and Java.
|
|
27
|
+
- **Lightweight symbol lookup**: indexes functions, classes, interfaces, types, variables, route-like handlers, Markdown headings, config keys, and env vars for exact agent lookup.
|
|
26
28
|
- **Better agent answers**: adaptive context windows, diversity reranking, optional cross-encoder reranking, and diagnostics.
|
|
27
29
|
- **Large-project stability**: persisted indexing progress, capped batches, streaming vector scans, and stuck-job detection.
|
|
28
30
|
- **Private by default**: local embeddings run without an API key.
|
|
@@ -42,6 +44,7 @@ Unlike `pi-memory` (which manages the agent's own notes), `pi-knowledge` indexes
|
|
|
42
44
|
| **Incremental re-indexing** | ✅ | ❌ | ❌ |
|
|
43
45
|
| **File watcher (auto-update)** | ✅ | ❌ | ❌ |
|
|
44
46
|
| **Code-aware chunking** | ✅ (TS/JS/Py/Go/Rust/Java) | ❌ | ❌ |
|
|
47
|
+
| **Symbol/config/heading lookup** | ✅ | ❌ | ❌ |
|
|
45
48
|
| **Local embeddings (zero API)** | ✅ | ❌ | ✅ (qmd) |
|
|
46
49
|
| **Index quality diagnostics** | ✅ | ❌ | ❌ |
|
|
47
50
|
| **Metadata filters in search** | ✅ | ❌ | ❌ |
|
|
@@ -62,7 +65,7 @@ TUI rendering currently uses Pi's stable default tool rendering plus targeted re
|
|
|
62
65
|
- **RAG-native project memory**: follows the Retrieval-Augmented Generation pattern from Lewis et al. 2020: keep source truth outside the model, retrieve it at answer time, and inject only relevant context.
|
|
63
66
|
- **Dense semantic recall**: uses multilingual dense embeddings in the spirit of Dense Passage Retrieval (Karpukhin et al. 2020), so conceptual queries can find code/docs even when wording differs.
|
|
64
67
|
- **Contextual Retrieval without remote chunk rewriting**: applies Anthropic's Contextual Retrieval insight locally by embedding file path, file type, Markdown breadcrumbs, and code symbols with each chunk. This improves standalone chunk meaning without sending private source chunks to an LLM for context generation.
|
|
65
|
-
- **Hybrid retrieval with diagnosable scores**: combines BM25 and vectors with normalized weighted score fusion. RRF (Cormack et al. 2009) remains the baseline reference, but weighted fusion is used by default because project dogfood showed RRF compressed scores too much for ranking diagnostics.
|
|
68
|
+
- **Hybrid retrieval with diagnosable scores**: combines lexical BM25 anchors and vectors with normalized weighted score fusion. RRF (Cormack et al. 2009) remains the baseline reference, but weighted fusion is used by default because project dogfood showed RRF compressed scores too much for ranking diagnostics.
|
|
66
69
|
- **MMR-style diversity**: uses Maximal Marginal Relevance ideas (Goldstein and Carbonell 1998), file interleaving, vector redundancy checks, and adaptive-window overlap collapse so repeated README or same-file chunks do not dominate top results.
|
|
67
70
|
- **Intent-aware and self-correcting agent UX**: mode selection (`auto`, `fast`, `semantic`, `hybrid`, `adaptive`, `deep`), ranking diagnostics, and `knowledge_doctor` turn retrieval failures into concrete next actions instead of silent bad answers.
|
|
68
71
|
- **Confidence gating**: low-evidence hybrid matches can return zero results instead of unrelated chunks, reducing false confidence when the KB does not contain the answer.
|
|
@@ -98,15 +101,16 @@ omp install ./pi-knowledge
|
|
|
98
101
|
|
|
99
102
|
| Tool | Description |
|
|
100
103
|
|------|-------------|
|
|
101
|
-
| `knowledge_plan` | Inspect an indexing source before writing a KB; reports scannable
|
|
104
|
+
| `knowledge_plan` | Inspect an indexing source before writing a KB; reports scannable counts, suggested exclusions, and technical skips |
|
|
102
105
|
| `knowledge_add` | Index files, directories, URLs, PDFs, DOCX, or inline text |
|
|
103
|
-
| `knowledge_search` |
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
+
| `knowledge_search` | Fast, semantic, lexical-anchored hybrid, deep, or adaptive search across one or all knowledge bases; supports file-type and path filters |
|
|
107
|
+
| `knowledge_symbol_search` | Lightweight exact or substring lookup for code symbols, route-like handlers, Markdown headings, config keys, and env vars; fall back to `knowledge_search` for methods or uncommon syntax |
|
|
108
|
+
| `knowledge_remove` | Remove a knowledge base by name or ID after `confirm: true` |
|
|
109
|
+
| `knowledge_update` | Incrementally re-index changed files in a source-backed file, directory, or URL knowledge base |
|
|
106
110
|
| `knowledge_show` | List all knowledge bases with stats |
|
|
107
111
|
| `knowledge_status` | Show engine status with health diagnostics (stale, orphans, coverage) |
|
|
108
112
|
| `knowledge_doctor` | Diagnose health score, skipped files, stuck jobs, stale data, and recommended fixes |
|
|
109
|
-
| `knowledge_clear` | Remove all knowledge bases |
|
|
113
|
+
| `knowledge_clear` | Remove all knowledge bases after `confirm: true` |
|
|
110
114
|
| `knowledge_export` | Export a KB to shareable JSONL file |
|
|
111
115
|
| `knowledge_import` | Import a KB from JSONL (re-embeds content) |
|
|
112
116
|
|
|
@@ -114,23 +118,25 @@ omp install ./pi-knowledge
|
|
|
114
118
|
|
|
115
119
|
- `fast`: BM25 keyword search for exact symbols, commands, and identifiers.
|
|
116
120
|
- `semantic`: vector search for conceptual matches.
|
|
117
|
-
- `hybrid`: BM25 + vector search with normalized weighted score fusion.
|
|
121
|
+
- `hybrid`: lexical-anchored BM25 + vector search with normalized weighted score fusion. It requires keyword evidence to avoid low-confidence semantic false positives.
|
|
118
122
|
- `deep`: hybrid retrieval followed by cross-encoder reranking.
|
|
119
123
|
- `adaptive`: hybrid retrieval followed by query-time contextual window expansion around seed chunks. It keeps the matched seed, prefers nearby/query-relevant neighboring chunks, and collapses overlapping windows from the same file.
|
|
120
124
|
- `auto`: selects a primary mode from the query shape and retries alternate modes when results are empty or weak.
|
|
125
|
+
- `code`, `config`, `errors`, `docs`, `decision`: intent aliases for agents. `code`, `config`, and `errors` bias toward exact lexical/symbol evidence; `docs` and `decision` keep the intended source type explicit.
|
|
121
126
|
|
|
122
127
|
Mode selection contract:
|
|
123
128
|
|
|
124
|
-
- Start with `hybrid` for most project questions.
|
|
129
|
+
- Start with `hybrid` for most project questions that contain useful lexical anchors.
|
|
125
130
|
- Use `fast` for exact symbols, filenames, commands, error codes, API names, config keys, or quoted strings.
|
|
126
|
-
- Use `semantic` when the query is conceptual
|
|
131
|
+
- Use `semantic` when the query is conceptual, exact terms may differ from indexed wording, or hybrid returns no lexical matches.
|
|
127
132
|
- Use `adaptive` when the answer needs nearby code, neighboring documentation sections, or enough context to make a safe edit.
|
|
128
133
|
- Use `deep` for high-stakes answers, ambiguous top results, or final verification when slower reranking is acceptable.
|
|
129
134
|
- If results are empty or weak but the KB should contain the answer, retry once with a different mode before concluding no answer exists.
|
|
130
135
|
|
|
131
|
-
Search results use balanced diversity reranking by default so near-duplicate chunks from the same file do not dominate the top results. Diversity scoring considers lexical overlap, same-file line proximity, overlapping adaptive windows, available embedding-vector similarity,
|
|
136
|
+
Search results use balanced diversity reranking by default so near-duplicate chunks from the same file do not dominate the top results. Diversity scoring considers lexical overlap, same-file line proximity, overlapping adaptive windows, available embedding-vector similarity, file-level interleaving, and a small KB trust multiplier that favors ready file/directory sources over stale, URL, or imported text sources. Use `diversity: "off"` only when raw ranking order is needed for diagnostics. Agents can request search diagnostics to inspect mode fallback, ranking coverage, path/source/test boosts, adjusted scores, and provenance such as chunk id, chunk hash, match reason, stale flag, and source freshness where available.
|
|
132
137
|
|
|
133
138
|
For best search quality, rebuild or update existing knowledge bases after upgrading. New indexes use contextual retrieval units: embeddings and FTS include file path, file type, Markdown heading breadcrumbs, and code symbol names while returned results keep the original chunk text readable. This improves queries that mention project structure, filenames, sections, or functions, and reduces duplicate-looking chunk hits.
|
|
139
|
+
Symbol/config/heading metadata is also rebuilt during `knowledge_update`; older KBs created before this feature may show a doctor action recommending update.
|
|
134
140
|
|
|
135
141
|
## Embedding Configuration
|
|
136
142
|
|
|
@@ -192,7 +198,7 @@ Update and diagnostics paths are also streaming-oriented: changed chunks are emb
|
|
|
192
198
|
|
|
193
199
|
## Architecture
|
|
194
200
|
|
|
195
|
-
|
|
201
|
+
[DESIGN.md](DESIGN.md) is the historical technical design. For current behavior contracts, prefer this README, [AGENTS.md](AGENTS.md), [docs/configuration.md](docs/configuration.md), and the ADR/pitfall notes under `docs/`.
|
|
196
202
|
|
|
197
203
|
## Data Storage
|
|
198
204
|
|
|
@@ -210,6 +216,7 @@ All data is stored globally at `~/.pi/knowledge/` under Pi or `~/.omp/knowledge/
|
|
|
210
216
|
- **Override**: set `PI_KNOWLEDGE_DIR` or `OMP_KNOWLEDGE_DIR`
|
|
211
217
|
- **Project safety**: pi-knowledge is read-only on indexed directories — no files are created or modified in your project
|
|
212
218
|
- **Updates**: extension updates do not affect existing indexed data. Schema migrations run automatically if needed.
|
|
219
|
+
- **Symbol index**: `knowledge.db` also stores lightweight symbol/config/heading metadata used by `knowledge_symbol_search`; it is derived from indexed source. File, directory, and URL KBs with retained source paths can rebuild it with `knowledge_update`; imported portable KBs and inline text KBs should be re-imported or re-added because they intentionally do not store an active local source manifest.
|
|
213
220
|
|
|
214
221
|
## Development
|
|
215
222
|
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,25 @@ let runtimePromise;
|
|
|
47
47
|
let initializePromise;
|
|
48
48
|
let initialized = false;
|
|
49
49
|
let disposePromise;
|
|
50
|
+
function scanOptionsFromSourceOptions(raw) {
|
|
51
|
+
if (!raw)
|
|
52
|
+
return {};
|
|
53
|
+
try {
|
|
54
|
+
const parsed = JSON.parse(raw);
|
|
55
|
+
return {
|
|
56
|
+
includeSuggestedText: parsed.include_suggested_text === true,
|
|
57
|
+
includePaths: Array.isArray(parsed.include_paths)
|
|
58
|
+
? parsed.include_paths.filter((item) => typeof item === "string")
|
|
59
|
+
: undefined,
|
|
60
|
+
excludePaths: Array.isArray(parsed.exclude_paths)
|
|
61
|
+
? parsed.exclude_paths.filter((item) => typeof item === "string")
|
|
62
|
+
: undefined,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
50
69
|
function runtimeModule(modulePath) {
|
|
51
70
|
return `${modulePath}${RUNTIME_EXTENSION}`;
|
|
52
71
|
}
|
|
@@ -131,7 +150,7 @@ export default function (pi) {
|
|
|
131
150
|
if (kb.source_path && kb.source_type === "directory") {
|
|
132
151
|
watcher.startWatcher(kb.id, kb.source_path, (kbId) => {
|
|
133
152
|
engine.update(kbId).catch(() => { });
|
|
134
|
-
});
|
|
153
|
+
}, scanOptionsFromSourceOptions(kb.source_options));
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
}
|
|
@@ -173,7 +192,7 @@ export default function (pi) {
|
|
|
173
192
|
if (kbs.length === 0)
|
|
174
193
|
return undefined;
|
|
175
194
|
const desc = kbs.map((kb) => `"${kb.name}" (${kb.chunk_count} chunks, ${kb.file_count} files)`).join(", ");
|
|
176
|
-
const guidance = `Available knowledge bases: ${desc}. Use knowledge_search
|
|
195
|
+
const guidance = `Available knowledge bases: ${desc}. Use knowledge_symbol_search for exact symbols/config keys/env vars/routes/headings, then use knowledge_search for broader domain or implementation context.`;
|
|
177
196
|
return {
|
|
178
197
|
systemPrompt: `${event.systemPrompt}\n\n${guidance}`,
|
|
179
198
|
};
|
|
@@ -181,11 +200,11 @@ export default function (pi) {
|
|
|
181
200
|
pi.registerTool({
|
|
182
201
|
name: "knowledge_plan",
|
|
183
202
|
label: "Knowledge Plan",
|
|
184
|
-
description: "Inspect an indexing source without writing a KB, showing scannable
|
|
203
|
+
description: "Inspect an indexing source without writing a KB, showing scannable counts, suggested exclusions, and technical skips",
|
|
185
204
|
promptSnippet: "Plan a knowledge-base indexing scope before calling knowledge_add",
|
|
186
205
|
promptGuidelines: [
|
|
187
206
|
"Use knowledge_plan before knowledge_add for broad directories, large repositories, or sources that may contain private or low-signal text",
|
|
188
|
-
"Show the user suggested exclusions
|
|
207
|
+
"Show the user suggested exclusions, technical skips, and scannable file counts before asking whether to include risky or low-signal text",
|
|
189
208
|
"After the user confirms scope, call knowledge_add with matching include_suggested_text, include_paths, or exclude_paths",
|
|
190
209
|
"Do not use knowledge_plan as a substitute for knowledge_search; it only plans indexing scope",
|
|
191
210
|
],
|
|
@@ -199,7 +218,7 @@ export default function (pi) {
|
|
|
199
218
|
}))),
|
|
200
219
|
exclude_paths: Type.Optional(Type.Array(Type.String({ description: "Relative paths under a directory source to exclude from this plan" }))),
|
|
201
220
|
}),
|
|
202
|
-
async execute(_id, params) {
|
|
221
|
+
async execute(_id, params, _signal) {
|
|
203
222
|
const { engine } = await ensureInitialized();
|
|
204
223
|
const { source, include_suggested_text, include_paths, exclude_paths } = params;
|
|
205
224
|
const plan = engine.plan(source, {
|
|
@@ -210,7 +229,7 @@ export default function (pi) {
|
|
|
210
229
|
exclude_paths: Array.isArray(exclude_paths)
|
|
211
230
|
? exclude_paths.filter((item) => typeof item === "string")
|
|
212
231
|
: undefined,
|
|
213
|
-
});
|
|
232
|
+
}, _signal);
|
|
214
233
|
const samples = plan.skipped.samples
|
|
215
234
|
.map((sample) => `- ${sample.reason}: ${sample.path}${sample.size ? ` (${sample.size} bytes)` : ""}`)
|
|
216
235
|
.join("\n");
|
|
@@ -232,14 +251,16 @@ export default function (pi) {
|
|
|
232
251
|
pi.registerTool({
|
|
233
252
|
name: "knowledge_add",
|
|
234
253
|
label: "Knowledge Add",
|
|
235
|
-
description: "Index files, directories, or text into a named knowledge base for semantic search",
|
|
236
|
-
promptSnippet: "Index files/dirs/text into a searchable knowledge base",
|
|
254
|
+
description: "Index files, directories, URLs, PDFs, DOCX, or text into a named knowledge base for semantic search",
|
|
255
|
+
promptSnippet: "Index files/dirs/URLs/PDFs/DOCX/text into a searchable knowledge base",
|
|
237
256
|
promptGuidelines: [
|
|
238
257
|
"Use knowledge_plan first for broad directories, large repositories, or sources that may contain private or low-signal text",
|
|
239
|
-
"Use knowledge_add when the user asks to index, remember, or learn from files or documentation",
|
|
240
|
-
"
|
|
241
|
-
"
|
|
242
|
-
"
|
|
258
|
+
"Use knowledge_add when the user asks to index, remember, or learn from files, URLs, documents, or documentation",
|
|
259
|
+
"Pass http:// or https:// sources directly for URL indexing",
|
|
260
|
+
"Prefer one knowledge_add call for the project root or relevant directory with include_paths/exclude_paths; do not call it once per ordinary source file",
|
|
261
|
+
"If the source looks like a local path, verify it exists before calling knowledge_add; non-existing non-URL path-like sources are rejected instead of treated as inline text",
|
|
262
|
+
"If a knowledge base with the same name already exists, use knowledge_update only to refresh that KB's existing retained source; otherwise ask before removing/replacing it",
|
|
263
|
+
"Index source, documentation, supported document files, and ordinary configuration files that explain how the project works",
|
|
243
264
|
"Default directory indexing suggests excluding generated, vendor, browser runtime, obvious secret, and low-signal text artifacts; these are not permanent blocks",
|
|
244
265
|
"For ambiguous or risky text such as .env, private keys, certificates, credential-named files, settings.json, appsettings.json, cloud config, editor config, generated reports, lockfiles, or vendor text, explain the tradeoff and ask the user before including it",
|
|
245
266
|
"If the user confirms a suggested-excluded text file or directory should be indexed, call knowledge_add with include_suggested_text or a focused include_paths value so the tool follows the confirmed scope",
|
|
@@ -247,7 +268,7 @@ export default function (pi) {
|
|
|
247
268
|
"Provide a descriptive name for this single knowledge base",
|
|
248
269
|
],
|
|
249
270
|
parameters: Type.Object({
|
|
250
|
-
source: Type.String({ description: "File path, directory path, or inline text to index" }),
|
|
271
|
+
source: Type.String({ description: "File path, directory path, URL, PDF/DOCX path, or inline text to index" }),
|
|
251
272
|
name: Type.String({ description: "Display name for this knowledge base" }),
|
|
252
273
|
include_suggested_text: Type.Optional(Type.Boolean({
|
|
253
274
|
description: "Include text files that are normally suggested for exclusion, such as vendor/build/runtime/cache/secret-named text, after user confirmation",
|
|
@@ -275,6 +296,14 @@ export default function (pi) {
|
|
|
275
296
|
if (WATCH_ENABLED && kb.source_path && kb.source_type === "directory") {
|
|
276
297
|
watcher.startWatcher(kb.id, kb.source_path, (kbId) => {
|
|
277
298
|
engine.update(kbId).catch(() => { });
|
|
299
|
+
}, {
|
|
300
|
+
includeSuggestedText: include_suggested_text === true,
|
|
301
|
+
includePaths: Array.isArray(include_paths)
|
|
302
|
+
? include_paths.filter((item) => typeof item === "string")
|
|
303
|
+
: undefined,
|
|
304
|
+
excludePaths: Array.isArray(exclude_paths)
|
|
305
|
+
? exclude_paths.filter((item) => typeof item === "string")
|
|
306
|
+
: undefined,
|
|
278
307
|
});
|
|
279
308
|
}
|
|
280
309
|
return {
|
|
@@ -290,13 +319,13 @@ export default function (pi) {
|
|
|
290
319
|
pi.registerTool({
|
|
291
320
|
name: "knowledge_search",
|
|
292
321
|
label: "Knowledge Search",
|
|
293
|
-
description: "Search indexed knowledge bases using
|
|
294
|
-
promptSnippet: "Search knowledge bases (hybrid BM25 + semantic
|
|
322
|
+
description: "Search indexed knowledge bases using lexical BM25, semantic vectors, reranking, and filters",
|
|
323
|
+
promptSnippet: "Search knowledge bases (hybrid is lexical-anchored BM25 + semantic fusion)",
|
|
295
324
|
promptGuidelines: [
|
|
296
325
|
"Use knowledge_search to find relevant context before answering domain questions",
|
|
297
|
-
"Default to mode 'hybrid' for most project questions
|
|
326
|
+
"Default to mode 'hybrid' for most project questions with useful lexical anchors; it fuses BM25 and semantic vectors but still requires keyword evidence",
|
|
298
327
|
"Use mode 'fast' for exact symbols, filenames, commands, error codes, API names, config keys, or quoted strings",
|
|
299
|
-
"Use mode 'semantic' for broad conceptual questions when exact terms may differ from the indexed wording",
|
|
328
|
+
"Use mode 'semantic' for broad conceptual questions when exact terms may differ from the indexed wording or hybrid returns no lexical matches",
|
|
300
329
|
"Use mode 'adaptive' when the user needs surrounding implementation context, related nearby sections, or enough context to make a code change",
|
|
301
330
|
"Use mode 'deep' for high-stakes answers, ambiguous top results, or final verification where slower cross-encoder reranking is acceptable",
|
|
302
331
|
"If a search returns no results or obviously weak results, retry once with a different mode before concluding the KB lacks the answer",
|
|
@@ -311,19 +340,25 @@ export default function (pi) {
|
|
|
311
340
|
Type.Literal("hybrid"),
|
|
312
341
|
Type.Literal("deep"),
|
|
313
342
|
Type.Literal("adaptive"),
|
|
343
|
+
Type.Literal("code"),
|
|
344
|
+
Type.Literal("config"),
|
|
345
|
+
Type.Literal("docs"),
|
|
346
|
+
Type.Literal("errors"),
|
|
347
|
+
Type.Literal("decision"),
|
|
314
348
|
])),
|
|
315
349
|
limit: Type.Optional(Type.Number({ description: "Max results (default 10)" })),
|
|
316
350
|
kb_id: Type.Optional(Type.String({ description: "Limit search to a specific KB by ID or exact name" })),
|
|
317
351
|
offset: Type.Optional(Type.Number({ description: "Pagination offset" })),
|
|
318
352
|
file_type: Type.Optional(Type.String({ description: "Filter by file type (e.g. typescript, markdown, python)" })),
|
|
353
|
+
path_pattern: Type.Optional(Type.String({ description: "Filter by file path substring (for example src/engine.ts)" })),
|
|
319
354
|
diversity: Type.Optional(Type.Union([Type.Literal("off"), Type.Literal("balanced"), Type.Literal("strong")])),
|
|
320
355
|
diagnostics: Type.Optional(Type.Boolean({ description: "Include ranking diagnostics and mode/fallback details in the result" })),
|
|
321
356
|
}),
|
|
322
|
-
async execute(_id, params) {
|
|
357
|
+
async execute(_id, params, _signal) {
|
|
323
358
|
const { engine } = await ensureInitialized();
|
|
324
|
-
const { query, mode, limit, kb_id, offset, file_type, diversity, diagnostics } = params;
|
|
325
|
-
const filters = file_type ? { file_type } : undefined;
|
|
326
|
-
const response = await engine.search(query, { mode, limit, kb_id, offset, filters, diversity });
|
|
359
|
+
const { query, mode, limit, kb_id, offset, file_type, path_pattern, diversity, diagnostics } = params;
|
|
360
|
+
const filters = file_type || path_pattern ? { file_type, path_pattern } : undefined;
|
|
361
|
+
const response = await engine.search(query, { mode, limit, kb_id, offset, filters, diversity }, _signal);
|
|
327
362
|
if (response.results.length === 0) {
|
|
328
363
|
const details = [
|
|
329
364
|
"No results found.",
|
|
@@ -334,7 +369,7 @@ export default function (pi) {
|
|
|
334
369
|
]
|
|
335
370
|
.filter(Boolean)
|
|
336
371
|
.join("\n");
|
|
337
|
-
return { content: [{ type: "text", text: details }] };
|
|
372
|
+
return { content: [{ type: "text", text: details }], details: diagnostics ? response : undefined };
|
|
338
373
|
}
|
|
339
374
|
let output = `${response.total_count} results (showing ${response.results.length})`;
|
|
340
375
|
if (response.mode_used)
|
|
@@ -350,17 +385,89 @@ export default function (pi) {
|
|
|
350
385
|
const diag = diagnostics && r.ranking
|
|
351
386
|
? `\nDiagnostics: base=${r.ranking.base_score.toFixed(3)}, adjusted=${r.ranking.adjusted_score.toFixed(3)}, coverage=${r.ranking.coverage.toFixed(2)}, path_boost=${r.ranking.path_boost.toFixed(2)}, source_boost=${r.ranking.source_boost.toFixed(2)}, test=${r.ranking.is_test}`
|
|
352
387
|
: "";
|
|
353
|
-
|
|
388
|
+
const provenance = diagnostics && r.provenance
|
|
389
|
+
? `\nProvenance: chunk=${r.provenance.chunk_id}, hash=${r.provenance.chunk_hash.slice(0, 12)}, reason=${r.provenance.match_reason}, indexed_at=${r.provenance.indexed_at}, source_mtime=${r.provenance.source_mtime ?? "unknown"}, stale=${r.provenance.stale}`
|
|
390
|
+
: "";
|
|
391
|
+
return `[${i + 1}] ${r.file_path} (${r.kb_name}, score: ${r.score.toFixed(3)})\n${r.snippet}${diag}${provenance}`;
|
|
354
392
|
})
|
|
355
393
|
.join("\n\n");
|
|
356
|
-
return { content: [{ type: "text", text: output }] };
|
|
394
|
+
return { content: [{ type: "text", text: output }], details: diagnostics ? response : undefined };
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
pi.registerTool({
|
|
398
|
+
name: "knowledge_symbol_search",
|
|
399
|
+
label: "Knowledge Symbol Search",
|
|
400
|
+
description: "Search indexed code symbols, Markdown headings, config keys, and environment variables exactly or by substring",
|
|
401
|
+
promptSnippet: "Find exact symbols/config keys/headings before broad semantic search",
|
|
402
|
+
promptGuidelines: [
|
|
403
|
+
"Use knowledge_symbol_search before knowledge_search when looking for a function, class, env var, config key, route, or Markdown heading",
|
|
404
|
+
"Use exact=true when the user provides a precise symbol or key",
|
|
405
|
+
"This is a lightweight declaration-pattern index, not full LSP; for methods, uncommon syntax, or missing symbols, fallback to knowledge_search mode 'fast' or 'adaptive'",
|
|
406
|
+
"After finding a symbol, use knowledge_search mode 'adaptive' with the file path or symbol name when surrounding implementation context is needed",
|
|
407
|
+
],
|
|
408
|
+
parameters: Type.Object({
|
|
409
|
+
query: Type.String({ description: "Symbol, heading, config key, env var, route, or file text to find" }),
|
|
410
|
+
kind: Type.Optional(Type.Union([
|
|
411
|
+
Type.Literal("function"),
|
|
412
|
+
Type.Literal("class"),
|
|
413
|
+
Type.Literal("interface"),
|
|
414
|
+
Type.Literal("type"),
|
|
415
|
+
Type.Literal("variable"),
|
|
416
|
+
Type.Literal("heading"),
|
|
417
|
+
Type.Literal("config_key"),
|
|
418
|
+
Type.Literal("env_var"),
|
|
419
|
+
Type.Literal("route"),
|
|
420
|
+
])),
|
|
421
|
+
kb_id: Type.Optional(Type.String({ description: "Limit lookup to a specific KB by ID or exact name" })),
|
|
422
|
+
file_pattern: Type.Optional(Type.String({ description: "Limit lookup to paths containing this text" })),
|
|
423
|
+
limit: Type.Optional(Type.Number({ description: "Max results (default 20)" })),
|
|
424
|
+
offset: Type.Optional(Type.Number({ description: "Pagination offset" })),
|
|
425
|
+
exact: Type.Optional(Type.Boolean({ description: "Require exact normalized symbol/key match" })),
|
|
426
|
+
}),
|
|
427
|
+
async execute(_id, params, _signal) {
|
|
428
|
+
if (_signal?.aborted)
|
|
429
|
+
throw new Error("Cancelled");
|
|
430
|
+
const { engine } = await ensureInitialized();
|
|
431
|
+
if (_signal?.aborted)
|
|
432
|
+
throw new Error("Cancelled");
|
|
433
|
+
const response = engine.symbolSearch(params.query, {
|
|
434
|
+
kind: params.kind,
|
|
435
|
+
kb_id: params.kb_id,
|
|
436
|
+
file_pattern: params.file_pattern,
|
|
437
|
+
limit: params.limit,
|
|
438
|
+
offset: params.offset,
|
|
439
|
+
exact: params.exact === true,
|
|
440
|
+
}, _signal);
|
|
441
|
+
if (response.results.length === 0) {
|
|
442
|
+
return {
|
|
443
|
+
content: [
|
|
444
|
+
{
|
|
445
|
+
type: "text",
|
|
446
|
+
text: "No symbols found. This may mean the symbol is absent, symbol metadata is missing/stale, or the lightweight extractor does not cover this syntax. For important lookups, run knowledge_doctor or fallback to knowledge_search mode 'fast'/'adaptive'.",
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
const lines = response.results.map((result, index) => {
|
|
452
|
+
const signature = result.signature ? ` — ${result.signature}` : "";
|
|
453
|
+
return `[${index + 1}] ${result.name} (${result.kind}) ${result.file_path}:${result.start_line}-${result.end_line} [${result.kb_name}]${signature}`;
|
|
454
|
+
});
|
|
455
|
+
const suffix = response.has_more ? "\nMore results available; increase offset to continue." : "";
|
|
456
|
+
return {
|
|
457
|
+
content: [
|
|
458
|
+
{
|
|
459
|
+
type: "text",
|
|
460
|
+
text: `${response.total_count} symbol result(s):\n\n${lines.join("\n")}${suffix}`,
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
};
|
|
357
464
|
},
|
|
358
465
|
});
|
|
359
466
|
pi.registerTool({
|
|
360
467
|
name: "knowledge_update",
|
|
361
468
|
label: "Knowledge Update",
|
|
362
|
-
description: "Incrementally re-index a knowledge base
|
|
363
|
-
promptSnippet: "
|
|
469
|
+
description: "Incrementally re-index a source-backed knowledge base with a retained file, directory, or URL source",
|
|
470
|
+
promptSnippet: "Refresh an existing source-backed KB",
|
|
364
471
|
parameters: Type.Object({
|
|
365
472
|
target: Type.String({ description: "KB name or ID to update" }),
|
|
366
473
|
}),
|
|
@@ -379,11 +486,13 @@ export default function (pi) {
|
|
|
379
486
|
label: "Knowledge Status",
|
|
380
487
|
description: "Show knowledge engine status with health diagnostics: staleness, orphans, and coverage",
|
|
381
488
|
parameters: Type.Object({}),
|
|
382
|
-
async execute() {
|
|
489
|
+
async execute(_id, _params, _signal) {
|
|
490
|
+
if (_signal?.aborted)
|
|
491
|
+
throw new Error("Cancelled");
|
|
383
492
|
const { engine, storage, watcher } = await ensureInitialized();
|
|
384
493
|
const kbs = engine.list();
|
|
385
494
|
const watchCount = watcher.getActiveWatcherCount();
|
|
386
|
-
const diagnostics = engine.diagnose();
|
|
495
|
+
const diagnostics = engine.diagnose(_signal);
|
|
387
496
|
const lines = [
|
|
388
497
|
`Storage: ${storage.getDefaultKnowledgeDir()}`,
|
|
389
498
|
`Knowledge bases: ${kbs.length}`,
|
|
@@ -445,9 +554,11 @@ export default function (pi) {
|
|
|
445
554
|
description: "Diagnose knowledge base health, skipped files, stale indexes, stuck jobs, and recommended fixes",
|
|
446
555
|
promptSnippet: "Diagnose knowledge base health and recommended actions",
|
|
447
556
|
parameters: Type.Object({}),
|
|
448
|
-
async execute() {
|
|
557
|
+
async execute(_id, _params, _signal) {
|
|
558
|
+
if (_signal?.aborted)
|
|
559
|
+
throw new Error("Cancelled");
|
|
449
560
|
const { engine } = await ensureInitialized();
|
|
450
|
-
const report = engine.doctor();
|
|
561
|
+
const report = engine.doctor(_signal);
|
|
451
562
|
const lines = [`Health score: ${report.health_score}/100`, report.summary, ""];
|
|
452
563
|
if (report.issues.length === 0) {
|
|
453
564
|
lines.push("No issues found.");
|
|
@@ -456,10 +567,10 @@ export default function (pi) {
|
|
|
456
567
|
for (const issue of report.issues) {
|
|
457
568
|
const scope = issue.kb_name ? ` [${issue.kb_name}]` : "";
|
|
458
569
|
lines.push(`- ${issue.severity.toUpperCase()}${scope}: ${issue.message}`);
|
|
459
|
-
lines.push(` Action: ${issue.action}`);
|
|
570
|
+
lines.push(` Action (${issue.action_code ?? "none"}): ${issue.action}`);
|
|
460
571
|
}
|
|
461
572
|
}
|
|
462
|
-
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
573
|
+
return { content: [{ type: "text", text: lines.join("\n") }], details: report };
|
|
463
574
|
},
|
|
464
575
|
});
|
|
465
576
|
pi.registerTool({
|
|
@@ -467,9 +578,13 @@ export default function (pi) {
|
|
|
467
578
|
label: "Knowledge Show",
|
|
468
579
|
description: "List all indexed knowledge bases",
|
|
469
580
|
parameters: Type.Object({}),
|
|
470
|
-
async execute() {
|
|
581
|
+
async execute(_id, _params, _signal) {
|
|
582
|
+
if (_signal?.aborted)
|
|
583
|
+
throw new Error("Cancelled");
|
|
471
584
|
const { engine } = await ensureInitialized();
|
|
472
|
-
|
|
585
|
+
if (_signal?.aborted)
|
|
586
|
+
throw new Error("Cancelled");
|
|
587
|
+
const kbs = engine.list(_signal);
|
|
473
588
|
if (kbs.length === 0)
|
|
474
589
|
return { content: [{ type: "text", text: "No knowledge bases." }] };
|
|
475
590
|
const lines = kbs.map((kb) => `• ${kb.name} — ${kb.chunk_count} chunks, ${kb.file_count} files (${kb.status})`);
|
|
@@ -479,13 +594,26 @@ export default function (pi) {
|
|
|
479
594
|
pi.registerTool({
|
|
480
595
|
name: "knowledge_remove",
|
|
481
596
|
label: "Knowledge Remove",
|
|
482
|
-
description: "Remove a knowledge base by name or ID",
|
|
597
|
+
description: "Remove a knowledge base by name or ID after explicit confirmation",
|
|
598
|
+
promptGuidelines: [
|
|
599
|
+
"Destructive: only call after the user explicitly asks to remove knowledge data or confirms a proposed removal",
|
|
600
|
+
"Prefer knowledge_status or knowledge_doctor before removing data for troubleshooting",
|
|
601
|
+
"Use knowledge_export before removal if the user may need a backup",
|
|
602
|
+
],
|
|
483
603
|
parameters: Type.Object({
|
|
484
604
|
target: Type.String({ description: "KB name or ID to remove" }),
|
|
605
|
+
confirm: Type.Boolean({
|
|
606
|
+
description: "Must be true after explicit user confirmation for this destructive operation",
|
|
607
|
+
}),
|
|
485
608
|
}),
|
|
486
|
-
async execute(_id, params) {
|
|
609
|
+
async execute(_id, params, _signal) {
|
|
610
|
+
if (_signal?.aborted)
|
|
611
|
+
throw new Error("Cancelled");
|
|
612
|
+
const { target, confirm } = params;
|
|
613
|
+
if (confirm !== true)
|
|
614
|
+
throw new Error("Confirmation required: pass confirm=true for destructive removal");
|
|
487
615
|
const { engine } = await ensureInitialized();
|
|
488
|
-
const ok = engine.remove(
|
|
616
|
+
const ok = engine.remove(target);
|
|
489
617
|
return { content: [{ type: "text", text: ok ? "Removed." : "Not found." }] };
|
|
490
618
|
},
|
|
491
619
|
});
|
|
@@ -497,10 +625,12 @@ export default function (pi) {
|
|
|
497
625
|
target: Type.String({ description: "KB name or ID to export" }),
|
|
498
626
|
output: Type.String({ description: "Output file path (.jsonl)" }),
|
|
499
627
|
}),
|
|
500
|
-
async execute(_id, params) {
|
|
628
|
+
async execute(_id, params, _signal, onUpdate) {
|
|
501
629
|
const { engine } = await ensureInitialized();
|
|
502
630
|
const { target, output } = params;
|
|
503
|
-
const count = await engine.exportKB(target, output)
|
|
631
|
+
const count = await engine.exportKB(target, output, _signal, (msg) => {
|
|
632
|
+
onUpdate?.({ content: [{ type: "text", text: msg }] });
|
|
633
|
+
});
|
|
504
634
|
return { content: [{ type: "text", text: `Exported ${count} chunks to ${output}` }] };
|
|
505
635
|
},
|
|
506
636
|
});
|
|
@@ -522,9 +652,23 @@ export default function (pi) {
|
|
|
522
652
|
pi.registerTool({
|
|
523
653
|
name: "knowledge_clear",
|
|
524
654
|
label: "Knowledge Clear",
|
|
525
|
-
description: "Remove all knowledge bases",
|
|
526
|
-
|
|
527
|
-
|
|
655
|
+
description: "Remove all knowledge bases after explicit confirmation",
|
|
656
|
+
promptGuidelines: [
|
|
657
|
+
"Destructive: only call after the user explicitly asks to clear all knowledge data or confirms a proposed clear",
|
|
658
|
+
"Never use knowledge_clear as troubleshooting unless the user explicitly approves",
|
|
659
|
+
"Prefer knowledge_status, knowledge_doctor, or knowledge_export before clearing data",
|
|
660
|
+
],
|
|
661
|
+
parameters: Type.Object({
|
|
662
|
+
confirm: Type.Boolean({
|
|
663
|
+
description: "Must be true after explicit user confirmation for this destructive operation",
|
|
664
|
+
}),
|
|
665
|
+
}),
|
|
666
|
+
async execute(_id, params, _signal) {
|
|
667
|
+
if (_signal?.aborted)
|
|
668
|
+
throw new Error("Cancelled");
|
|
669
|
+
if (params.confirm !== true) {
|
|
670
|
+
throw new Error("Confirmation required: pass confirm=true for destructive clear");
|
|
671
|
+
}
|
|
528
672
|
const { engine } = await ensureInitialized();
|
|
529
673
|
engine.clear();
|
|
530
674
|
return { content: [{ type: "text", text: "All knowledge bases cleared." }] };
|
|
@@ -16,4 +16,4 @@ export interface DiagnosticResult {
|
|
|
16
16
|
skipped_files: ScanResult["skipped"];
|
|
17
17
|
job?: IndexingJob;
|
|
18
18
|
}
|
|
19
|
-
export declare function diagnoseKB(db: Database.Database, kb: KnowledgeBase): DiagnosticResult;
|
|
19
|
+
export declare function diagnoseKB(db: Database.Database, kb: KnowledgeBase, signal?: AbortSignal): DiagnosticResult;
|
|
@@ -26,7 +26,11 @@ function scanOptionsFromSourceOptions(raw) {
|
|
|
26
26
|
return {};
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
function throwIfAborted(signal) {
|
|
30
|
+
if (signal?.aborted)
|
|
31
|
+
throw new Error("Cancelled");
|
|
32
|
+
}
|
|
33
|
+
export function diagnoseKB(db, kb, signal) {
|
|
30
34
|
const statusAgeMs = Date.now() - kb.updated_at;
|
|
31
35
|
const job = getIndexingJob(db, kb.id);
|
|
32
36
|
const lastProgressAgeMs = job?.status === "running" ? Date.now() - job.last_progress_at : statusAgeMs;
|
|
@@ -42,19 +46,10 @@ export function diagnoseKB(db, kb) {
|
|
|
42
46
|
coverage_percent: 100,
|
|
43
47
|
total_source_files: 0,
|
|
44
48
|
indexed_files: kb.file_count,
|
|
45
|
-
skipped_files:
|
|
46
|
-
total: 0,
|
|
47
|
-
by_reason: {
|
|
48
|
-
suggested_excluded: 0,
|
|
49
|
-
oversized: 0,
|
|
50
|
-
binary: 0,
|
|
51
|
-
unreadable: 0,
|
|
52
|
-
inaccessible: 0,
|
|
53
|
-
},
|
|
54
|
-
samples: [],
|
|
55
|
-
},
|
|
49
|
+
skipped_files: createSkippedScanStats(),
|
|
56
50
|
job,
|
|
57
51
|
};
|
|
52
|
+
throwIfAborted(signal);
|
|
58
53
|
if (!kb.source_path || kb.source_type === "url" || !existsSync(kb.source_path)) {
|
|
59
54
|
return result; // text KBs or missing source — no diagnostics possible
|
|
60
55
|
}
|
|
@@ -65,6 +60,7 @@ export function diagnoseKB(db, kb) {
|
|
|
65
60
|
if (isDirectory) {
|
|
66
61
|
const skipped = createSkippedScanStats();
|
|
67
62
|
for (const file of iterateScannableFiles(kb.source_path, skipped, scanOptionsFromSourceOptions(kb.source_options))) {
|
|
63
|
+
throwIfAborted(signal);
|
|
68
64
|
currentFiles.add(file.relPath);
|
|
69
65
|
}
|
|
70
66
|
result.skipped_files = skipped;
|
|
@@ -74,6 +70,8 @@ export function diagnoseKB(db, kb) {
|
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
72
|
catch {
|
|
73
|
+
if (signal?.aborted)
|
|
74
|
+
throw new Error("Cancelled");
|
|
77
75
|
return result;
|
|
78
76
|
}
|
|
79
77
|
result.total_source_files = currentFiles.size;
|
|
@@ -81,6 +79,7 @@ export function diagnoseKB(db, kb) {
|
|
|
81
79
|
const indexedFilePaths = new Set();
|
|
82
80
|
const latestIndexedByFile = new Map();
|
|
83
81
|
for (const chunk of iterateChunksByKB(db, kb.id)) {
|
|
82
|
+
throwIfAborted(signal);
|
|
84
83
|
indexedFilePaths.add(chunk.file_path);
|
|
85
84
|
const currentLatest = latestIndexedByFile.get(chunk.file_path) ?? 0;
|
|
86
85
|
if (chunk.indexed_at > currentLatest)
|
|
@@ -88,12 +87,14 @@ export function diagnoseKB(db, kb) {
|
|
|
88
87
|
}
|
|
89
88
|
// Orphan detection: chunks referencing files no longer in source
|
|
90
89
|
for (const filePath of indexedFilePaths) {
|
|
90
|
+
throwIfAborted(signal);
|
|
91
91
|
if (!currentFiles.has(filePath)) {
|
|
92
92
|
result.orphan_files.push(filePath);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
// Staleness detection: source files modified after last indexing
|
|
96
96
|
for (const relPath of currentFiles) {
|
|
97
|
+
throwIfAborted(signal);
|
|
97
98
|
const absPath = isDirectory ? join(kb.source_path, relPath) : relPath;
|
|
98
99
|
try {
|
|
99
100
|
const mtime = statSync(absPath).mtimeMs;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function dispose(): Promise<void>;
|
|
2
2
|
export declare function prepareForShutdown(): Promise<void>;
|
|
3
3
|
export declare function embedTexts(texts: string[], prefix: "query" | "passage", signal?: AbortSignal): Promise<Float32Array[]>;
|
|
4
|
-
export declare function embedQuery(text: string): Promise<Float32Array>;
|
|
4
|
+
export declare function embedQuery(text: string, signal?: AbortSignal): Promise<Float32Array>;
|
|
5
5
|
export declare function embedDocuments(texts: string[], signal?: AbortSignal): Promise<Float32Array[]>;
|