@autorag/librarian 2.13.7 → 2.13.9
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/README.md +15 -0
- package/dist/agent/agent.d.ts +41 -1
- package/dist/agent/calculator-tool.d.ts +39 -0
- package/dist/agent/evidence-ledger.d.ts +11 -0
- package/dist/agent/index-schedule.d.ts +45 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/result-render.d.ts +43 -0
- package/dist/agent/search-all-tool.d.ts +2 -1
- package/dist/agent/search-minsync-tool.d.ts +2 -1
- package/dist/agent/search-single-datasource-tool.d.ts +2 -1
- package/dist/agent/watch-refresh.d.ts +2 -0
- package/dist/calculator/civil.d.ts +27 -0
- package/dist/calculator/decimal.d.ts +47 -0
- package/dist/calculator/errors.d.ts +4 -0
- package/dist/calculator/expression.d.ts +11 -0
- package/dist/calculator/index.d.ts +17 -0
- package/dist/calculator/operations.d.ts +36 -0
- package/dist/calculator/temporal.d.ts +18 -0
- package/dist/calculator/timezone.d.ts +19 -0
- package/dist/cli/commands/index.d.ts +1 -1
- package/dist/cli/commands/lite-find.d.ts +26 -0
- package/dist/cli/commands/lite-refresh.d.ts +1 -1
- package/dist/cli/commands/refresh.d.ts +4 -0
- package/dist/cli/commands/watch.d.ts +2 -1
- package/dist/cli/index.js +2979 -265
- package/dist/cli/signal-abort.d.ts +21 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.js +2164 -188
- package/dist/find/groups.d.ts +35 -0
- package/dist/find/index.d.ts +10 -0
- package/dist/find/relevance.d.ts +29 -0
- package/dist/find/run.d.ts +24 -0
- package/dist/find/text.d.ts +37 -0
- package/dist/find/types.d.ts +86 -0
- package/dist/index.js +2200 -227
- package/dist/mcp/index.js +2199 -227
- package/dist/minsync/channel-union.d.ts +23 -0
- package/dist/minsync/method.d.ts +7 -0
- package/dist/mirror/sync.d.ts +9 -0
- package/dist/profiles.js +2187 -216
- package/dist/retrieval/engine.d.ts +7 -0
- package/dist/retrieval/merger.d.ts +6 -0
- package/dist/retrieval/record-cut.d.ts +101 -0
- package/package.json +1 -1
- package/skills/autorag/SKILL.md +28 -0
- package/skills/autorag-setup/SKILL.md +39 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The group runners behind `autorag lite find`: one model-free search per
|
|
3
|
+
* surface — the platform file-name index, local document content, and each
|
|
4
|
+
* connected datasource, each asked on its own so a slow one never blocks the
|
|
5
|
+
* rest.
|
|
6
|
+
*/
|
|
7
|
+
import type { RetrievalResult } from "../retrieval/types.js";
|
|
8
|
+
import type { FindGroupDescriptor, FindGroupStatus, FindHit, FindJudge, FindRuntime } from "./types.js";
|
|
9
|
+
/** The result of running one group. */
|
|
10
|
+
export interface FindGroupOutcome {
|
|
11
|
+
readonly status: FindGroupStatus;
|
|
12
|
+
readonly hits: readonly FindHit[];
|
|
13
|
+
readonly error: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface FindGroupRunner {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
readonly descriptor: FindGroupDescriptor;
|
|
18
|
+
run(): Promise<FindGroupOutcome>;
|
|
19
|
+
}
|
|
20
|
+
export interface BuildGroupRunnersOptions {
|
|
21
|
+
readonly query: string;
|
|
22
|
+
readonly topK: number;
|
|
23
|
+
readonly runtime: FindRuntime;
|
|
24
|
+
readonly judge?: FindJudge;
|
|
25
|
+
readonly platform?: NodeJS.Platform;
|
|
26
|
+
/** Whether the platform file-name index is enabled in config (default true). */
|
|
27
|
+
readonly fileSearchEnabled?: boolean;
|
|
28
|
+
/** Whether local semantic search is enabled in config (default true). */
|
|
29
|
+
readonly semanticEnabled?: boolean;
|
|
30
|
+
/** The enabled, registered datasources, in config order. */
|
|
31
|
+
readonly datasources?: readonly FindGroupDescriptor[];
|
|
32
|
+
}
|
|
33
|
+
/** A retrieval result as a datasource hit; exported for tests. */
|
|
34
|
+
export declare function sourceHit(result: RetrievalResult, query: string): FindHit;
|
|
35
|
+
export declare function buildGroupRunners(options: BuildGroupRunnersOptions): FindGroupRunner[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `autorag lite find`: a model-free whole search across the platform file-name
|
|
3
|
+
* index, local document content, and every connected datasource. Pure and
|
|
4
|
+
* injectable (runtime, judge); the CLI wires the real ones and prints NDJSON.
|
|
5
|
+
*/
|
|
6
|
+
export { type BuildGroupRunnersOptions, buildGroupRunners, type FindGroupOutcome, type FindGroupRunner, sourceHit, } from "./groups.js";
|
|
7
|
+
export { createRelevanceGate, JEV_RELEVANCE_THRESHOLD, type RelevanceCandidate, type RelevanceGateDeps, type SearchRelevanceGate, } from "./relevance.js";
|
|
8
|
+
export { type FindRunOptions, runFind } from "./run.js";
|
|
9
|
+
export { capContent, contentSnippet, escapeSearchRegex, everythingRegexQuery, fsearchRegexQuery, matchesQueryLexically, SEARCH_HIT_CONTENT_LIMIT, } from "./text.js";
|
|
10
|
+
export type { FindDoneLine, FindGroupDescriptor, FindGroupLine, FindGroupStatus, FindGroupsLine, FindHit, FindJudge, FindJudgment, FindKind, FindLine, FindRuntime, FindSearchAnswer, FindVerdict, } from "./types.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The relevance gate for the `content` and `source:*` groups.
|
|
3
|
+
*
|
|
4
|
+
* A deterministic lexical pass auto-keeps obvious hits; everything else goes to
|
|
5
|
+
* the decision model as batched `noul` questions, and only candidates with
|
|
6
|
+
* P(relevant) at or above {@link JEV_RELEVANCE_THRESHOLD} survive, ordered by
|
|
7
|
+
* probability. When no decision model can answer — the judge throws, or returns
|
|
8
|
+
* no numeric verdicts — every candidate is kept unfiltered (fail open).
|
|
9
|
+
*/
|
|
10
|
+
import type { FindJudge } from "./types.js";
|
|
11
|
+
/** Minimum judged probability `P(relevant)` required for a non-lexical hit to be shown. */
|
|
12
|
+
export declare const JEV_RELEVANCE_THRESHOLD = 0.5;
|
|
13
|
+
export interface RelevanceCandidate {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly sourceLabel: string;
|
|
16
|
+
readonly title?: string | null;
|
|
17
|
+
readonly subtitle?: string | null;
|
|
18
|
+
readonly content: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SearchRelevanceGate {
|
|
21
|
+
filter<T extends RelevanceCandidate>(query: string, candidates: readonly T[]): Promise<T[]>;
|
|
22
|
+
}
|
|
23
|
+
export interface RelevanceGateDeps {
|
|
24
|
+
readonly judge: FindJudge;
|
|
25
|
+
readonly threshold?: number;
|
|
26
|
+
readonly maxQuestionsPerBatch?: number;
|
|
27
|
+
readonly maxConcurrentBatches?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function createRelevanceGate(deps: RelevanceGateDeps): SearchRelevanceGate;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrates a whole search: emit the group list immediately, run every group
|
|
3
|
+
* in parallel, stream one group line per group in completion order, and finish
|
|
4
|
+
* with the done line. One group throwing never affects the others.
|
|
5
|
+
*/
|
|
6
|
+
import type { FindGroupDescriptor, FindJudge, FindLine, FindRuntime } from "./types.js";
|
|
7
|
+
export interface FindRunOptions {
|
|
8
|
+
readonly query: string;
|
|
9
|
+
readonly topK: number;
|
|
10
|
+
readonly runtime: FindRuntime;
|
|
11
|
+
readonly judge?: FindJudge;
|
|
12
|
+
readonly platform?: NodeJS.Platform;
|
|
13
|
+
readonly fileSearchEnabled?: boolean;
|
|
14
|
+
readonly semanticEnabled?: boolean;
|
|
15
|
+
/** The enabled, registered datasources, in config order. */
|
|
16
|
+
readonly datasources?: readonly FindGroupDescriptor[];
|
|
17
|
+
/** `--groups` narrowing: run only these keys. */
|
|
18
|
+
readonly groups?: readonly string[];
|
|
19
|
+
/** Emit the `groups` line before running. Pass false when the caller already announced it. */
|
|
20
|
+
readonly announce?: boolean;
|
|
21
|
+
readonly emit: (line: FindLine) => void;
|
|
22
|
+
readonly now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
export declare function runFind(options: FindRunOptions): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text helpers for the whole-search groups: the relevance gate's deterministic
|
|
3
|
+
* lexical pass, the one-line snippet, and the platform file-name regexes.
|
|
4
|
+
*
|
|
5
|
+
* The lexical pass is ported from the Finder's `matchesQueryLexicallyOrApprox`
|
|
6
|
+
* with the approximate edit-distance step dropped, so it stays dependency-free.
|
|
7
|
+
*/
|
|
8
|
+
/** Passed text a hit carries, capped at this many characters. */
|
|
9
|
+
export declare const SEARCH_HIT_CONTENT_LIMIT = 2000;
|
|
10
|
+
/** The passage as one line, cut to {@link SNIPPET_LENGTH} around the first query term that appears in it. */
|
|
11
|
+
export declare function contentSnippet(text: string, query: string): string;
|
|
12
|
+
/** The passage flattened to one line and capped at {@link SEARCH_HIT_CONTENT_LIMIT} characters. */
|
|
13
|
+
export declare function capContent(text: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Fast deterministic pass-through before Jev: exact query word match (NFKC
|
|
16
|
+
* case-folded, ASCII boundary-aware so `_`/`-`/Hangul neighbors work while
|
|
17
|
+
* partial stems like `art` in `start` do not, plus Korean postposition
|
|
18
|
+
* stripping like `비행기를` → `비행기`). The approximate edit-distance step the
|
|
19
|
+
* Finder had is intentionally dropped: this is dependency-free.
|
|
20
|
+
*/
|
|
21
|
+
export declare function matchesQueryLexically(query: string, candidateText: string): boolean;
|
|
22
|
+
/** Escape a literal query so an index's regex mode matches it as a substring. */
|
|
23
|
+
export declare function escapeSearchRegex(text: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Regex for the fsearch index. macOS stores Hangul file names decomposed (NFD)
|
|
26
|
+
* while typed queries are composed (NFC), and the index compares bytes, so a
|
|
27
|
+
* name matches only when the query uses the same form. Sending both forms as an
|
|
28
|
+
* alternation finds either spelling; a query that has one form (ASCII) stays the
|
|
29
|
+
* plain escaped substring.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fsearchRegexQuery(text: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Everything's `regex:` search function is the working regex surface on the
|
|
34
|
+
* bundled ES build. A bare space ends the function's argument, so spaces become
|
|
35
|
+
* `\x20` to keep a literal substring.
|
|
36
|
+
*/
|
|
37
|
+
export declare function everythingRegexQuery(text: string): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Question } from "jev-use";
|
|
2
|
+
import type { EverythingSearchRequest, EverythingSearchResult } from "../everything/index.js";
|
|
3
|
+
import type { FSearchSearchRequest, FSearchSearchResult } from "../fsearch/index.js";
|
|
4
|
+
import type { RetrievalSelection } from "../retrieval/selection.js";
|
|
5
|
+
import type { RetrievalDiagnostic, RetrievalOptions, RetrievalResult, RetrievalUnsearchedSurface } from "../retrieval/types.js";
|
|
6
|
+
/** What a whole-search hit is: a file name, document content, or a datasource message. */
|
|
7
|
+
export type FindKind = "file" | "content" | "message";
|
|
8
|
+
/** One hit on one group, shared by the filename, content, and datasource surfaces. */
|
|
9
|
+
export interface FindHit {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly kind: FindKind;
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly author: string | null;
|
|
14
|
+
readonly snippet: string;
|
|
15
|
+
/** Passed text, capped at {@link SEARCH_HIT_CONTENT_LIMIT} characters. */
|
|
16
|
+
readonly content: string;
|
|
17
|
+
/** Absolute local path for file and content hits; null for datasource messages. */
|
|
18
|
+
readonly path: string | null;
|
|
19
|
+
readonly line: number | null;
|
|
20
|
+
/** Epoch milliseconds, when the source states one. */
|
|
21
|
+
readonly timestamp: number | null;
|
|
22
|
+
readonly url: string | null;
|
|
23
|
+
readonly score: number | null;
|
|
24
|
+
}
|
|
25
|
+
/** The group list line, printed before any group runs. */
|
|
26
|
+
export interface FindGroupDescriptor {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly datasourceId?: string;
|
|
29
|
+
readonly datasourceType?: string;
|
|
30
|
+
}
|
|
31
|
+
/** `off` = the surface is disabled in config; `unavailable` = its index is not built. */
|
|
32
|
+
export type FindGroupStatus = "ready" | "error" | "off" | "unavailable";
|
|
33
|
+
export interface FindGroupsLine {
|
|
34
|
+
readonly type: "groups";
|
|
35
|
+
readonly groups: readonly FindGroupDescriptor[];
|
|
36
|
+
}
|
|
37
|
+
export interface FindGroupLine {
|
|
38
|
+
readonly type: "group";
|
|
39
|
+
readonly key: string;
|
|
40
|
+
readonly status: FindGroupStatus;
|
|
41
|
+
readonly hits: readonly FindHit[];
|
|
42
|
+
/** The group's own failure text verbatim, or null. */
|
|
43
|
+
readonly error: string | null;
|
|
44
|
+
readonly elapsedMs: number;
|
|
45
|
+
}
|
|
46
|
+
export interface FindDoneLine {
|
|
47
|
+
readonly type: "done";
|
|
48
|
+
readonly elapsedMs: number;
|
|
49
|
+
}
|
|
50
|
+
export type FindLine = FindGroupsLine | FindGroupLine | FindDoneLine;
|
|
51
|
+
/** The answer shape `searchSelected` returns; a structural subset of the retrieval engine's. */
|
|
52
|
+
export interface FindSearchAnswer {
|
|
53
|
+
readonly results: readonly RetrievalResult[];
|
|
54
|
+
readonly diagnostics: readonly RetrievalDiagnostic[];
|
|
55
|
+
readonly unsearched: readonly RetrievalUnsearchedSurface[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The model-free runtime a whole search drives. `AutoRAGLite` satisfies it
|
|
59
|
+
* structurally; tests inject a fake. Only these methods are touched, so a
|
|
60
|
+
* search never enters the model-backed agent loop.
|
|
61
|
+
*/
|
|
62
|
+
export interface FindRuntime {
|
|
63
|
+
listDatasources(): readonly {
|
|
64
|
+
readonly datasourceId: string;
|
|
65
|
+
}[];
|
|
66
|
+
searchSelected(query: string, selection?: RetrievalSelection, options?: RetrievalOptions): Promise<FindSearchAnswer>;
|
|
67
|
+
searchFsearch(request: FSearchSearchRequest): Promise<FSearchSearchResult>;
|
|
68
|
+
searchEverything(request: EverythingSearchRequest): Promise<EverythingSearchResult>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One batched `noul` judgment over relevance questions. The real implementation
|
|
72
|
+
* is `createDecisionModels(...).judge`; a thrown error means "no decision model
|
|
73
|
+
* can answer", and the gate fails open.
|
|
74
|
+
*/
|
|
75
|
+
export type FindJudge = (state: string, questions: Question[]) => Promise<FindJudgment>;
|
|
76
|
+
/** The verdicts the gate reads; a structural subset of `jev-use`'s `JudgeResult`. */
|
|
77
|
+
export interface FindJudgment {
|
|
78
|
+
readonly verdicts: readonly FindVerdict[];
|
|
79
|
+
}
|
|
80
|
+
export interface FindVerdict {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly type?: string;
|
|
83
|
+
readonly answer: number | string | null;
|
|
84
|
+
readonly confidence?: number;
|
|
85
|
+
readonly escalate?: boolean;
|
|
86
|
+
}
|