@autorag/librarian 2.10.6 → 2.11.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 +8 -0
- package/README.md +46 -7
- package/dist/agent/agent.d.ts +6 -1
- package/dist/agent/answer-guidelines.d.ts +22 -1
- package/dist/agent/mcp-client.d.ts +27 -0
- package/dist/agent/pi-session.d.ts +8 -0
- package/dist/agent/search-progress.d.ts +96 -0
- package/dist/agent/welcome-header.d.ts +35 -0
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/index.js +11740 -10176
- package/dist/cli/setup.d.ts +9 -0
- package/dist/core.js +1841 -865
- package/dist/datasource/errors.d.ts +1 -1
- package/dist/datasource/index.d.ts +2 -1
- package/dist/datasource/skills/factory.d.ts +3 -0
- package/dist/datasource/skills/hister/client.d.ts +83 -0
- package/dist/datasource/skills/hister/embedding.d.ts +64 -0
- package/dist/datasource/skills/hister/index.d.ts +2 -0
- package/dist/datasource/skills/hister/setup.d.ts +87 -0
- package/dist/datasource/skills/hister/skill.d.ts +63 -0
- package/dist/datasource/skills/obsidian/index.d.ts +4 -6
- package/dist/datasource/skills/obsidian/methods.d.ts +13 -17
- package/dist/datasource/skills/obsidian/paths.d.ts +24 -24
- package/dist/datasource/skills/obsidian/skill.d.ts +10 -15
- package/dist/datasource/skills/obsidian/staging.d.ts +50 -0
- package/dist/datasource/skills/obsidian/vault-index.d.ts +44 -0
- package/dist/index.js +1894 -915
- package/dist/mcp/index.js +1891 -915
- package/dist/minsync/workspace-lock.d.ts +7 -0
- package/dist/process/terminate-tree.d.ts +4 -5
- package/licenses/hister-AGPL-3.0-notice.txt +47 -0
- package/package.json +2 -2
- package/skills/autorag/SKILL.md +6 -3
- package/skills/autorag-doctor/SKILL.md +5 -4
- package/skills/autorag-lite-setup/SKILL.md +23 -5
- package/skills/autorag-setup/SKILL.md +60 -3
- package/dist/datasource/skills/obsidian/client.d.ts +0 -15
- package/dist/datasource/skills/obsidian/types.d.ts +0 -92
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a sync (anything that rewrites the workspace). The in-flight count is raised
|
|
3
|
+
* before this returns, so a query issued right after the call already sees the sync.
|
|
4
|
+
*/
|
|
5
|
+
export declare function runWorkspaceSync<T>(workspacePath: string, run: () => Promise<T>): Promise<T>;
|
|
6
|
+
/** Run a query. It is refused while a sync is pending, because the index is mid-rewrite. */
|
|
7
|
+
export declare function runWorkspaceQuery<T>(workspacePath: string, run: () => Promise<T>): Promise<T>;
|
|
@@ -4,11 +4,10 @@ export declare const TREE_KILL_GRACE_MS = 500;
|
|
|
4
4
|
/**
|
|
5
5
|
* Terminate a spawned external CLI together with the descendants it created.
|
|
6
6
|
*
|
|
7
|
-
* CLIs
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* for minutes — the hang reported in #1578.
|
|
7
|
+
* CLIs that are launchers (an npm shim, a wrapper script) start a runtime descendant that inherits
|
|
8
|
+
* the launcher's stdout/stderr pipes. Node emits `close` only once every holder of those pipes has
|
|
9
|
+
* exited, so signalling just the direct child leaves the caller waiting on a descendant that may
|
|
10
|
+
* live for minutes — the hang reported in #1578.
|
|
12
11
|
*
|
|
13
12
|
* Spawn the child with `detached: true` on POSIX so it leads its own process
|
|
14
13
|
* group; the group survives the direct child and stays addressable as `-pid`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Hister — license notice for AutoRAG's `hister` datasource
|
|
2
|
+
==========================================================
|
|
3
|
+
|
|
4
|
+
Program: Hister ("Your own search engine")
|
|
5
|
+
Source: https://github.com/asciimoo/hister
|
|
6
|
+
Copyright: asciimoo and Hister contributors (see the repository history)
|
|
7
|
+
License: GNU Affero General Public License, version 3 or (at your option)
|
|
8
|
+
any later version (AGPL-3.0-or-later)
|
|
9
|
+
License text: https://www.gnu.org/licenses/agpl-3.0.txt
|
|
10
|
+
(also the LICENSE file in the Hister repository)
|
|
11
|
+
|
|
12
|
+
How AutoRAG relates to Hister
|
|
13
|
+
-----------------------------
|
|
14
|
+
* AutoRAG does NOT contain, bundle, link, vendor, or redistribute any Hister
|
|
15
|
+
source code or binary. Nothing from the Hister repository is copied into
|
|
16
|
+
this package.
|
|
17
|
+
* Users install Hister themselves, unmodified, from its own releases
|
|
18
|
+
(https://github.com/asciimoo/hister/releases, `brew install hister`, Docker,
|
|
19
|
+
or Nix), and run it as a separate process (`hister listen`).
|
|
20
|
+
* AutoRAG talks to that process only over HTTP, using Hister's public JSON API
|
|
21
|
+
(`GET /search`, `GET /api/config`), the same API Hister's own `hister search`
|
|
22
|
+
command uses. Hister owns its index, its browser extension, its credentials,
|
|
23
|
+
and its optional embedding calls.
|
|
24
|
+
* AutoRAG does not modify Hister, and it never hides that Hister is the backend:
|
|
25
|
+
the datasource manifest shown to the agent names Hister, its license, and its
|
|
26
|
+
source URL.
|
|
27
|
+
* The `hister` datasource only reads web-page documents (`type:web`). It never
|
|
28
|
+
enables or uses Hister's local-directory indexing.
|
|
29
|
+
|
|
30
|
+
Combining separate programs that communicate over a network is "mere
|
|
31
|
+
aggregation" in the sense of the GNU licenses FAQ
|
|
32
|
+
(https://www.gnu.org/licenses/gpl-faq.html#MereAggregation); AutoRAG therefore
|
|
33
|
+
stays under its own license (Apache-2.0).
|
|
34
|
+
|
|
35
|
+
If you run Hister as a network service for other people, AGPL-3.0 section 13
|
|
36
|
+
applies to YOU as the operator of that Hister instance: you must offer those
|
|
37
|
+
users the Corresponding Source of the Hister version you run (and of any
|
|
38
|
+
modifications you made). Running an unmodified upstream release satisfies this
|
|
39
|
+
by pointing users at https://github.com/asciimoo/hister.
|
|
40
|
+
|
|
41
|
+
Obtaining the Hister source for a release you run
|
|
42
|
+
-------------------------------------------------
|
|
43
|
+
git clone https://github.com/asciimoo/hister
|
|
44
|
+
git checkout <the version printed by `hister --version`>
|
|
45
|
+
|
|
46
|
+
This file is a notice, not the license. The authoritative license terms are in
|
|
47
|
+
the Hister repository and at the AGPL URL above.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorag/librarian",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.11.0",
|
|
4
|
+
"description": "Personal librarian agent for office work on the Pi framework, with pluggable retrieval methods",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/skills/autorag/SKILL.md
CHANGED
|
@@ -15,10 +15,13 @@ search, calls MinSync, Jikji, datasource, and filesystem tools, reads
|
|
|
15
15
|
sources, judges evidence, and curates the final answer. There is no subagent or
|
|
16
16
|
separate model role.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Indexing and refresh read source documents and write only under the configured
|
|
19
19
|
workspace `.autorag/` directory and Jikji's central store (`<OS data dir>/jikji/`,
|
|
20
|
-
plus a `.jikji_agent_map.md` guide in each indexed root).
|
|
21
|
-
|
|
20
|
+
plus a `.jikji_agent_map.md` guide in each indexed root). The librarian may
|
|
21
|
+
organize, create, or modify the user's own files in local sessions when the
|
|
22
|
+
user asks; it never deletes permanently (OS trash only) and lists every change
|
|
23
|
+
as old path → new path. Do not move, rename, edit, or delete source files on your own
|
|
24
|
+
initiative while searching or diagnosing.
|
|
22
25
|
|
|
23
26
|
## Preflight
|
|
24
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: autorag-doctor
|
|
3
|
-
description: Diagnose and repair a broken or half-working AutoRAG install so every configured source is both indexed and searchable. Checks AutoRAG, MinSync, Jikji, the embedding backend, and every CLI-backed datasource (lazykatok, discrawl, slacrawl, wacrawl, telecrawl, notcrawl,
|
|
3
|
+
description: Diagnose and repair a broken or half-working AutoRAG install so every configured source is both indexed and searchable. Checks AutoRAG, MinSync, Jikji, the embedding backend, and every CLI-backed datasource (lazykatok, discrawl, slacrawl, wacrawl, telecrawl, notcrawl, mailcrawl, rclone, Spotlight), then fixes orphan locks, orphan processes, embedding dimension or identity mismatches, stale indexes, and missing setup. Use when search returns nothing or too little, refresh hangs or fails, a datasource disappeared from results, indexes look stale, the embedder is unavailable, or the user asks to check, diagnose, verify, or repair AutoRAG.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -15,9 +15,10 @@ Always finish with the status table in [Report](#report).
|
|
|
15
15
|
|
|
16
16
|
## Safety
|
|
17
17
|
|
|
18
|
-
-
|
|
18
|
+
- Diagnosis and repair never delete, move, or edit source documents; a doctor
|
|
19
|
+
run changes only AutoRAG-owned state.
|
|
19
20
|
- Never delete a datasource's **native** store (`~/Library/Application Support/katok`, `~/.discrawl`,
|
|
20
|
-
`~/.mailcrawl`,
|
|
21
|
+
`~/.mailcrawl`, Telegram/WhatsApp/Notion archives). AutoRAG only
|
|
21
22
|
reads them; rebuilding them is the owning CLI's job.
|
|
22
23
|
- Only AutoRAG-owned state under `AUTORAG_HOME` and the workspace `.autorag`
|
|
23
24
|
directory may be reset.
|
|
@@ -69,7 +70,7 @@ Each CLI owns its archive, so ask the CLI, not AutoRAG. A datasource is only
|
|
|
69
70
|
| WhatsApp | `wacrawl --json doctor` | `wacrawl import` |
|
|
70
71
|
| Telegram | `telecrawl --json doctor`, `telecrawl --json status` | `telecrawl import` |
|
|
71
72
|
| Notion | `notcrawl doctor`, `notcrawl status` | `notcrawl sync --source desktop` |
|
|
72
|
-
| Obsidian / notes | `
|
|
73
|
+
| Obsidian / notes | `autorag status` (AutoRAG-owned index) | `autorag refresh --method datasources`; if corrupt, delete `.autorag/datasources/obsidian/<instance>` first |
|
|
73
74
|
| Mail | `mailcrawl doctor`, `mailcrawl status` | `mailcrawl sync && mailcrawl index` |
|
|
74
75
|
| Cloud drive | `rclone listremotes` | `autorag refresh --method datasources` |
|
|
75
76
|
| Spotlight (macOS) | `mdutil -s /` | indexed by the OS; no AutoRAG sync |
|
|
@@ -17,9 +17,9 @@ Use `autorag-setup` instead when the model-backed librarian must be configured.
|
|
|
17
17
|
`memoryPath`, `minSync`, `jikji`, `datasources`.
|
|
18
18
|
- Never print, copy, migrate, compare, or persist credential values. Store only
|
|
19
19
|
environment-variable names such as `tokenEnv` or `apiKeyEnv`.
|
|
20
|
-
-
|
|
21
|
-
indexes only under the configured workspace `.autorag/` directory
|
|
22
|
-
Jikji's central store (`<OS data dir>/jikji/`).
|
|
20
|
+
- Setup and Lite commands never move, rename, edit, or delete source documents.
|
|
21
|
+
They write indexes only under the configured workspace `.autorag/` directory
|
|
22
|
+
and Jikji's central store (`<OS data dir>/jikji/`).
|
|
23
23
|
- Do not index system trees, app bundles, caches, credential stores,
|
|
24
24
|
`node_modules`, `.git`, `dist`, `build`, `target`, `.cache`, `.autorag`, or
|
|
25
25
|
`.jikji`.
|
|
@@ -113,7 +113,7 @@ setup. Configure datasources directly in trusted config, wizard-style:
|
|
|
113
113
|
|
|
114
114
|
1. Probe every datasource for setup feasibility before asking the user
|
|
115
115
|
anything: the backing CLI exists (`lazykatok`, `discrawl`, `slacrawl`,
|
|
116
|
-
`wacrawl`, `telecrawl`, `notcrawl`, `
|
|
116
|
+
`wacrawl`, `telecrawl`, `notcrawl`, `mailcrawl`, `rclone`) and its
|
|
117
117
|
local store or archive is present. CLI-backed datasources own their own
|
|
118
118
|
archive, index, and authentication, so environment credentials (such as bot
|
|
119
119
|
tokens) are never required or checked for them. Non-CLI connectors
|
|
@@ -137,7 +137,7 @@ Datasource skills belong in trusted config.
|
|
|
137
137
|
|
|
138
138
|
Config keys may be builtin template names (`kakao`, `whatsapp`, `telegram`,
|
|
139
139
|
`slack`, `discord`, `clawgallery`, `notion`, `github`, `cloud-drive`,
|
|
140
|
-
`mail-export`, `mailcrawl`, `obsidian`, `rss`, `spotlight`, `lark`) or connection
|
|
140
|
+
`mail-export`, `mailcrawl`, `obsidian`, `rss`, `spotlight`, `lark`, `hister`) or connection
|
|
141
141
|
aliases with `"type": "<template>"`. Unknown names are skipped with an
|
|
142
142
|
`unknown-datasource-skill` warning; they do not fail config resolution.
|
|
143
143
|
`scope` narrows a query to a sub-path as ordinary filtering. Tags are
|
|
@@ -146,6 +146,24 @@ select configured connections before retrieval; discover their IDs with
|
|
|
146
146
|
`autorag.datasources.list`. Store only env-var names such as `tokenEnv` or
|
|
147
147
|
`apiKeyEnv`, never credential values.
|
|
148
148
|
|
|
149
|
+
### Browser history (Hister) and the shared embedding model
|
|
150
|
+
|
|
151
|
+
`hister` needs a separately installed, always-running Hister server (AGPL-3.0, never
|
|
152
|
+
bundled by AutoRAG). Run `autorag setup --format json` and read the `hister` object
|
|
153
|
+
(`installed`, `running`, `embedding`); each problem carries the exact command to run:
|
|
154
|
+
`brew install hister`, `brew services start hister`, then install the Hister browser
|
|
155
|
+
extension in the user's browser.
|
|
156
|
+
|
|
157
|
+
Hister embeds with its own `semantic_search` config, so it must use the same model as
|
|
158
|
+
AutoRAG (the `minsync serve` daemon, `Qwen/Qwen3-Embedding-0.6B`, 1024 dimensions) or
|
|
159
|
+
its vectors stop lining up without any error. `autorag setup --sync-hister` copies the
|
|
160
|
+
shared settings into Hister's `config.yml` (backup kept), restarts the service, waits
|
|
161
|
+
for it, and runs `hister reindex` when needed; it is idempotent, and it refuses a
|
|
162
|
+
remote or in-process backend. Re-run it after restarting the `minsync serve` daemon
|
|
163
|
+
(its port changes). Verify with `hister doctor`: `server.index.embeddings` must be `ok`.
|
|
164
|
+
Install a skip list in Hister's `rules.json` before importing past history, because the
|
|
165
|
+
importer re-downloads URLs without the browser's cookies (docs/datasource-skills.md).
|
|
166
|
+
|
|
149
167
|
## Build and refresh indexes
|
|
150
168
|
|
|
151
169
|
After connecting, call MCP `autorag.refresh` with `{}` for an incremental run.
|
|
@@ -21,7 +21,8 @@ librarian, not the Lite MCP server.
|
|
|
21
21
|
- Never print, copy, migrate, compare, or persist credential values. Store only
|
|
22
22
|
environment-variable names such as `apiKeyEnv`.
|
|
23
23
|
- Do not scan the whole filesystem or home directory without explicit approval.
|
|
24
|
-
-
|
|
24
|
+
- Setup, indexing, and refresh never move, rename, edit, or delete source
|
|
25
|
+
documents. The librarian itself may organize files when the user asks it to.
|
|
25
26
|
- Do not index system trees, app bundles, caches, credential stores,
|
|
26
27
|
`node_modules`, `.git`, `dist`, `build`, `target`, `.cache`, `.autorag`, or
|
|
27
28
|
`.jikji`.
|
|
@@ -361,7 +362,7 @@ setup. Configure datasources directly in trusted config, wizard-style:
|
|
|
361
362
|
|
|
362
363
|
1. Probe every datasource for setup feasibility before asking the user
|
|
363
364
|
anything: the backing CLI exists (`lazykatok`, `discrawl`, `slacrawl`,
|
|
364
|
-
`wacrawl`, `telecrawl`, `notcrawl`, `
|
|
365
|
+
`wacrawl`, `telecrawl`, `notcrawl`, `mailcrawl`, `rclone`, `lark-cli`) and its
|
|
365
366
|
local store or archive is present. CLI-backed datasources own their own
|
|
366
367
|
archive, index, and authentication, so environment credentials (such as bot
|
|
367
368
|
tokens) are never required or checked for them. Non-CLI connectors
|
|
@@ -384,7 +385,7 @@ setup. Configure datasources directly in trusted config, wizard-style:
|
|
|
384
385
|
Datasource skills belong in trusted config. Builtin
|
|
385
386
|
template names are `kakao`, `whatsapp`, `telegram`, `slack`, `discord`,
|
|
386
387
|
`clawgallery`, `notion`, `github`, `github-gist`, `cloud-drive`, `mail-export`,
|
|
387
|
-
`mailcrawl`, `obsidian`, `rss`, `spotlight`, and `
|
|
388
|
+
`mailcrawl`, `obsidian`, `rss`, `spotlight`, `lark`, and `hister`. Config keys may be connection
|
|
388
389
|
aliases with `"type": "<template>"`. Unknown names are skipped with an
|
|
389
390
|
`unknown-datasource-skill` warning; they do not fail config resolution.
|
|
390
391
|
`scope` narrows a query to a sub-path as ordinary filtering. Tags are descriptive metadata only, not search filters. MCP `datasourceIds` selects configured connections before retrieval; discover their IDs with `autorag.datasources.list`.
|
|
@@ -418,6 +419,62 @@ the next `index`. kakao needs `lazykatok` 0.3.3 or newer for the same reason.
|
|
|
418
419
|
Use mailcrawl for Gmail, IMAP, and Maildir retrieval. The former Gmail REST
|
|
419
420
|
datasource is removed.
|
|
420
421
|
|
|
422
|
+
### Browser history (Hister) and the shared embedding model
|
|
423
|
+
|
|
424
|
+
`hister` is the one datasource whose backing program AutoRAG does not install,
|
|
425
|
+
start, or bundle (it is AGPL-3.0-or-later and stays a separate program). Setting
|
|
426
|
+
it up is an agent task with these steps. Run each command; do not just describe it.
|
|
427
|
+
|
|
428
|
+
1. **Probe first.** Add the datasource entry, then run `autorag setup --format json`
|
|
429
|
+
and read the `hister` object: `installed`, `running`, and `embedding`. Every
|
|
430
|
+
problem has a `remediation` string with the exact next command.
|
|
431
|
+
2. **Install Hister** when `installed` is false: `brew install hister` (other
|
|
432
|
+
platforms: the release binaries at https://github.com/asciimoo/hister/releases).
|
|
433
|
+
3. **Run it as a login item** when `running` is false: `brew services start hister`.
|
|
434
|
+
Hister must stay running: its browser extension only captures while it is up,
|
|
435
|
+
and a page visited while it is down is not re-sent. AutoRAG never starts it.
|
|
436
|
+
4. **Install the browser extension** (Chrome Web Store "Hister", or Firefox
|
|
437
|
+
Add-ons). It must be done in the user's browser; tell the user if you cannot.
|
|
438
|
+
5. **Share the embedding model** (below).
|
|
439
|
+
6. **Before importing past history, install a skip list** in Hister's `rules.json`
|
|
440
|
+
(login, mail, documents, social and console domains, private hosts, token-bearing
|
|
441
|
+
URLs). `hister import browser history` re-downloads each URL *without* the
|
|
442
|
+
browser's cookies. See docs/datasource-skills.md, "Browser history via Hister".
|
|
443
|
+
7. Add `"browser": { "type": "hister", "connector": { "semantic": true } }` under
|
|
444
|
+
`datasources`, then `autorag refresh` (only probes Hister) and
|
|
445
|
+
`autorag lite retrieve "<a question>" --scope '/browser/**' --json`.
|
|
446
|
+
|
|
447
|
+
**Shared embedding model.** Hister keeps its own vector store and embeds with
|
|
448
|
+
whatever its `config.yml` `semantic_search` block says. Pointing it at a different
|
|
449
|
+
model does not fail: vectors simply stop lining up and results get worse. So Hister
|
|
450
|
+
must use the same model as AutoRAG, which is the `minsync serve` daemon (model
|
|
451
|
+
`Qwen/Qwen3-Embedding-0.6B`, 1024 dimensions, with Qwen3's query instruction).
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
autorag setup --format json # reports hister.embedding.differs: the keys that disagree
|
|
455
|
+
autorag setup --sync-hister # writes them, restarts Hister, re-embeds pages if needed
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
- `--sync-hister` rewrites only `enable`, `embedding_endpoint`, `embedding_model`,
|
|
459
|
+
`dimensions`, `query_prefix`, `document_prefix` in Hister's config (a
|
|
460
|
+
`config.yml.bak.<time>` is kept next to it), then runs `brew services restart hister`,
|
|
461
|
+
waits for it to answer, and runs `hister reindex` when a change makes stored
|
|
462
|
+
vectors stale. Without the flag setup never writes Hister's config.
|
|
463
|
+
- The daemon port is chosen when `minsync serve` starts. After restarting the daemon,
|
|
464
|
+
run `autorag setup --sync-hister` again. It is idempotent: when nothing differs
|
|
465
|
+
it changes nothing and restarts nothing.
|
|
466
|
+
- It refuses, and says why, when the shared backend is a remote endpoint (browsing
|
|
467
|
+
text would leave the machine) or MinSync's in-process engine (Hister cannot reach
|
|
468
|
+
it; run `minsync serve --idle-timeout 0`, docs/minsync-setup.md).
|
|
469
|
+
- If `restartRequired` or `reindexRequired` is true in the report, the step was
|
|
470
|
+
not done (no Homebrew service, or it failed): run `brew services restart hister`
|
|
471
|
+
and `hister reindex` yourself. Check with `hister doctor`: the line
|
|
472
|
+
`server.index.embeddings` must be `ok`.
|
|
473
|
+
- A changed `query_prefix` alone needs a restart but no reindex. Never hand-edit the
|
|
474
|
+
`query_prefix` value across two lines: Hister's YAML parser folds the newline into
|
|
475
|
+
a space and the model's instruction is silently corrupted. `--sync-hister` writes
|
|
476
|
+
it correctly.
|
|
477
|
+
|
|
421
478
|
## Verify and build indexes
|
|
422
479
|
|
|
423
480
|
Configuration alone is not a successful setup:
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { QmdEmbedResult, QmdEnsureResult, QmdOptions, QmdSearchMode, QmdSearchOptions, QmdSearchResult, QmdUpdateResult } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Thin external `qmd` CLI wrapper for Obsidian vault indexing/search.
|
|
4
|
-
* Every method spawns the `qmd` binary, never throws for expected failures,
|
|
5
|
-
* and isolates config/cache under the AutoRAG workspace.
|
|
6
|
-
*/
|
|
7
|
-
export declare class QmdClient {
|
|
8
|
-
private readonly options;
|
|
9
|
-
constructor(options?: QmdOptions);
|
|
10
|
-
ensureCollection(signal?: AbortSignal): Promise<QmdEnsureResult>;
|
|
11
|
-
update(signal?: AbortSignal): Promise<QmdUpdateResult>;
|
|
12
|
-
embed(signal?: AbortSignal): Promise<QmdEmbedResult>;
|
|
13
|
-
search(mode: QmdSearchMode, query: string, options?: QmdSearchOptions): Promise<QmdSearchResult>;
|
|
14
|
-
private run;
|
|
15
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { RetrievalOptions } from "../../../retrieval/types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Search modes accepted by the external `qmd` CLI.
|
|
4
|
-
*
|
|
5
|
-
* - `search` — BM25 / FTS5 lexical search
|
|
6
|
-
* - `vsearch` — dense vector semantic search
|
|
7
|
-
*/
|
|
8
|
-
export type QmdSearchMode = "search" | "vsearch";
|
|
9
|
-
/**
|
|
10
|
-
* Configuration for {@link QmdClient}. The client spawns the `qmd` binary as a
|
|
11
|
-
* child process and isolates config/cache under the AutoRAG workspace.
|
|
12
|
-
*/
|
|
13
|
-
export interface QmdOptions {
|
|
14
|
-
/** Explicit path to the `qmd` binary. Defaults to a bare `qmd` PATH lookup. */
|
|
15
|
-
readonly binaryPath?: string;
|
|
16
|
-
/** Spawn timeout in milliseconds. Default 60_000 (embed can be slow). */
|
|
17
|
-
readonly timeoutMs?: number;
|
|
18
|
-
/** Max stdout/stderr bytes retained. Default 1_048_576 (1 MiB). */
|
|
19
|
-
readonly maxBufferBytes?: number;
|
|
20
|
-
/** Absolute path to the Obsidian vault. Required for ensure/update. */
|
|
21
|
-
readonly vaultPath?: string;
|
|
22
|
-
/** AutoRAG workspace root used to isolate qmd config/cache. */
|
|
23
|
-
readonly workspaceRoot?: string;
|
|
24
|
-
/** Instance id used for source paths and collection naming. Default `default`. */
|
|
25
|
-
readonly instanceId?: string;
|
|
26
|
-
/** Explicit collection name; defaults to a sanitized instance id. */
|
|
27
|
-
readonly collectionName?: string;
|
|
28
|
-
/** Environment overrides merged on top of a restricted process env. */
|
|
29
|
-
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
30
|
-
/** Explicit operator-owned qmd config directory, never rewritten. */
|
|
31
|
-
readonly configPath?: string;
|
|
32
|
-
}
|
|
33
|
-
export declare const DEFAULT_QMD_BINARY = "qmd";
|
|
34
|
-
export declare const DEFAULT_QMD_TIMEOUT_MS = 60000;
|
|
35
|
-
export declare const DEFAULT_QMD_MAX_BUFFER_BYTES = 1048576;
|
|
36
|
-
export type QmdFailureReason = "binary-missing" | "not-configured" | "nonzero-exit" | "spawn-error" | "timeout" | "aborted" | "stdout-too-large" | "stderr-too-large" | "invalid-json" | "invalid-shape";
|
|
37
|
-
export interface QmdFailure {
|
|
38
|
-
readonly ok: false;
|
|
39
|
-
readonly reason: QmdFailureReason;
|
|
40
|
-
readonly stdout: string;
|
|
41
|
-
readonly stderr: string;
|
|
42
|
-
readonly code: number | null;
|
|
43
|
-
}
|
|
44
|
-
export interface QmdOk<T> {
|
|
45
|
-
readonly ok: true;
|
|
46
|
-
readonly data: T;
|
|
47
|
-
readonly stdout: string;
|
|
48
|
-
readonly stderr: string;
|
|
49
|
-
readonly code: number;
|
|
50
|
-
}
|
|
51
|
-
export interface QmdUpdateInfo {
|
|
52
|
-
readonly indexed: number;
|
|
53
|
-
readonly updated: number;
|
|
54
|
-
readonly unchanged: number;
|
|
55
|
-
readonly removed: number;
|
|
56
|
-
readonly needsEmbedding?: boolean;
|
|
57
|
-
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
58
|
-
}
|
|
59
|
-
export interface QmdEmbedInfo {
|
|
60
|
-
readonly embedded: boolean;
|
|
61
|
-
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
62
|
-
}
|
|
63
|
-
export interface QmdEnsureInfo {
|
|
64
|
-
readonly collectionName: string;
|
|
65
|
-
readonly vaultPath: string;
|
|
66
|
-
readonly configDir: string;
|
|
67
|
-
}
|
|
68
|
-
/** A scored search hit from `qmd search` / `qmd vsearch`. */
|
|
69
|
-
export interface QmdSearchHit {
|
|
70
|
-
readonly chunkId: string;
|
|
71
|
-
readonly score: number;
|
|
72
|
-
readonly content: string;
|
|
73
|
-
readonly title?: string;
|
|
74
|
-
readonly file?: string;
|
|
75
|
-
readonly docid?: string;
|
|
76
|
-
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
77
|
-
}
|
|
78
|
-
export interface QmdSearchOk {
|
|
79
|
-
readonly ok: true;
|
|
80
|
-
readonly hits: readonly QmdSearchHit[];
|
|
81
|
-
readonly stdout: string;
|
|
82
|
-
readonly stderr: string;
|
|
83
|
-
readonly code: number;
|
|
84
|
-
readonly data: {
|
|
85
|
-
readonly hits: readonly QmdSearchHit[];
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
export type QmdEnsureResult = QmdOk<QmdEnsureInfo> | QmdFailure;
|
|
89
|
-
export type QmdUpdateResult = QmdOk<QmdUpdateInfo> | QmdFailure;
|
|
90
|
-
export type QmdEmbedResult = QmdOk<QmdEmbedInfo> | QmdFailure;
|
|
91
|
-
export type QmdSearchResult = QmdSearchOk | QmdFailure;
|
|
92
|
-
export type QmdSearchOptions = RetrievalOptions;
|