@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.
Files changed (110) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +275 -0
  3. package/dist/agent/agent.d.ts +294 -0
  4. package/dist/agent/bash-tool.d.ts +41 -0
  5. package/dist/agent/datasource-skill.d.ts +45 -0
  6. package/dist/agent/emit-results-tool.d.ts +75 -0
  7. package/dist/agent/index.d.ts +11 -0
  8. package/dist/agent/jikji-find-tool.d.ts +73 -0
  9. package/dist/agent/search-all-tool.d.ts +36 -0
  10. package/dist/agent/search-bm25-tool.d.ts +18 -0
  11. package/dist/agent/search-datasource-tool.d.ts +26 -0
  12. package/dist/agent/search-documents.d.ts +56 -0
  13. package/dist/agent/search-minsync-tool.d.ts +24 -0
  14. package/dist/agent/system-prompt.d.ts +13 -0
  15. package/dist/agent/watch-refresh.d.ts +29 -0
  16. package/dist/cli/commands/feedback.d.ts +8 -0
  17. package/dist/cli/commands/health.d.ts +146 -0
  18. package/dist/cli/commands/index.d.ts +9 -0
  19. package/dist/cli/commands/init.d.ts +9 -0
  20. package/dist/cli/commands/memory.d.ts +8 -0
  21. package/dist/cli/commands/refresh.d.ts +19 -0
  22. package/dist/cli/commands/search.d.ts +34 -0
  23. package/dist/cli/commands/status.d.ts +7 -0
  24. package/dist/cli/commands/types.d.ts +10 -0
  25. package/dist/cli/commands/watch.d.ts +8 -0
  26. package/dist/cli/config.d.ts +172 -0
  27. package/dist/cli/index.d.ts +10 -0
  28. package/dist/cli/index.js +10845 -0
  29. package/dist/cli/output.d.ts +32 -0
  30. package/dist/config/home.d.ts +2 -0
  31. package/dist/datasource/access-context.d.ts +49 -0
  32. package/dist/datasource/diagnostics.d.ts +20 -0
  33. package/dist/datasource/index.d.ts +9 -0
  34. package/dist/datasource/polling.d.ts +51 -0
  35. package/dist/datasource/registry.d.ts +52 -0
  36. package/dist/datasource/result-filter.d.ts +63 -0
  37. package/dist/datasource/scope.d.ts +38 -0
  38. package/dist/datasource/skills/katok/client.d.ts +24 -0
  39. package/dist/datasource/skills/katok/index.d.ts +12 -0
  40. package/dist/datasource/skills/katok/methods.d.ts +40 -0
  41. package/dist/datasource/skills/katok/paths.d.ts +40 -0
  42. package/dist/datasource/skills/katok/skill.d.ts +33 -0
  43. package/dist/datasource/skills/katok/types.d.ts +146 -0
  44. package/dist/datasource/types.d.ts +183 -0
  45. package/dist/filesystem/file-lock.d.ts +16 -0
  46. package/dist/filesystem/source-paths.d.ts +38 -0
  47. package/dist/index.d.ts +11 -0
  48. package/dist/index.js +9361 -0
  49. package/dist/jikji/answer-pack.d.ts +31 -0
  50. package/dist/jikji/client.d.ts +18 -0
  51. package/dist/jikji/diagnostics.d.ts +26 -0
  52. package/dist/jikji/index.d.ts +10 -0
  53. package/dist/jikji/installer.d.ts +46 -0
  54. package/dist/jikji/path-map.d.ts +8 -0
  55. package/dist/jikji/types.d.ts +112 -0
  56. package/dist/manifest/index.d.ts +2 -0
  57. package/dist/manifest/loader.d.ts +3 -0
  58. package/dist/manifest/types.d.ts +8 -0
  59. package/dist/memory/check-memory-tool.d.ts +13 -0
  60. package/dist/memory/index.d.ts +5 -0
  61. package/dist/memory/memory.d.ts +179 -0
  62. package/dist/memory/renderer.d.ts +6 -0
  63. package/dist/minsync/client.d.ts +14 -0
  64. package/dist/minsync/embedder-config.d.ts +22 -0
  65. package/dist/minsync/index.d.ts +7 -0
  66. package/dist/minsync/installer.d.ts +27 -0
  67. package/dist/minsync/method.d.ts +37 -0
  68. package/dist/minsync/paths.d.ts +4 -0
  69. package/dist/minsync/process.d.ts +10 -0
  70. package/dist/minsync/types.d.ts +33 -0
  71. package/dist/minsync/workspace.d.ts +14 -0
  72. package/dist/mirror/index-store.d.ts +16 -0
  73. package/dist/mirror/index.d.ts +5 -0
  74. package/dist/mirror/paths.d.ts +6 -0
  75. package/dist/mirror/sync.d.ts +38 -0
  76. package/dist/observability/run-log.d.ts +53 -0
  77. package/dist/parser/defaults.d.ts +6 -0
  78. package/dist/parser/eml.d.ts +6 -0
  79. package/dist/parser/errors.d.ts +5 -0
  80. package/dist/parser/hwp.d.ts +6 -0
  81. package/dist/parser/index.d.ts +10 -0
  82. package/dist/parser/ocr.d.ts +25 -0
  83. package/dist/parser/office.d.ts +16 -0
  84. package/dist/parser/opendataloader-pdf.d.ts +21 -0
  85. package/dist/parser/plain-text.d.ts +6 -0
  86. package/dist/parser/registry.d.ts +8 -0
  87. package/dist/parser/text.d.ts +2 -0
  88. package/dist/parser/types.d.ts +14 -0
  89. package/dist/parser/xml-text.d.ts +2 -0
  90. package/dist/retrieval/evidence-id.d.ts +16 -0
  91. package/dist/retrieval/index.d.ts +7 -0
  92. package/dist/retrieval/merger.d.ts +18 -0
  93. package/dist/retrieval/methods/bm25.d.ts +52 -0
  94. package/dist/retrieval/registry.d.ts +8 -0
  95. package/dist/retrieval/scope.d.ts +4 -0
  96. package/dist/retrieval/types.d.ts +64 -0
  97. package/dist/subagents/contracts.d.ts +90 -0
  98. package/dist/subagents/dispatch-templates.d.ts +104 -0
  99. package/dist/subagents/dispatch-validation.d.ts +169 -0
  100. package/dist/subagents/explorer-tools-extension.d.ts +4 -0
  101. package/dist/subagents/explorer-tools-extension.js +130 -0
  102. package/dist/subagents/local-models.d.ts +14 -0
  103. package/dist/subagents/model-policy.d.ts +31 -0
  104. package/dist/subagents/runtime.d.ts +52 -0
  105. package/dist/tool/index.d.ts +1 -0
  106. package/dist/types/errors.d.ts +4 -0
  107. package/dist/types/index.d.ts +1 -0
  108. package/package.json +66 -0
  109. package/skills/autorag/SKILL.md +149 -0
  110. package/skills/autorag-setup/SKILL.md +396 -0
@@ -0,0 +1,16 @@
1
+ export interface ParsedMirrorEntry {
2
+ readonly virtualPath: string;
3
+ readonly sourcePath: string;
4
+ readonly outputPath: string;
5
+ readonly parserName: string;
6
+ readonly sourceMtimeNs: number;
7
+ readonly sourceSizeBytes: number;
8
+ readonly updatedAt: string;
9
+ }
10
+ export interface ParsedMirrorIndex {
11
+ readonly version: 1;
12
+ readonly entries: Readonly<Record<string, ParsedMirrorEntry>>;
13
+ }
14
+ export declare function emptyMirrorIndex(): ParsedMirrorIndex;
15
+ export declare function loadMirrorIndex(root: string): ParsedMirrorIndex;
16
+ export declare function saveMirrorIndex(root: string, index: ParsedMirrorIndex): void;
@@ -0,0 +1,5 @@
1
+ export type { ParsedMirrorEntry, ParsedMirrorIndex } from "./index-store.js";
2
+ export { emptyMirrorIndex, loadMirrorIndex, saveMirrorIndex } from "./index-store.js";
3
+ export { parsedMirrorIndexPath, parsedMirrorRoot, parsedOutputPath } from "./paths.js";
4
+ export type { ParsedMirrorDiagnostic, ParsedMirrorDiagnosticCode, ParsedMirrorSyncOptions, ParsedMirrorSyncResult, } from "./sync.js";
5
+ export { DEFAULT_MAX_SOURCE_BYTES, detectMirrorStaleness, syncParsedMirrors } from "./sync.js";
@@ -0,0 +1,6 @@
1
+ export declare const PARSED_MIRROR_SUBDIR: string;
2
+ export declare const PARSED_FILES_SUBDIR = "files";
3
+ export declare const PARSED_INDEX_FILE = "index.json";
4
+ export declare function parsedMirrorRoot(root: string): string;
5
+ export declare function parsedMirrorIndexPath(root: string): string;
6
+ export declare function parsedOutputPath(root: string, virtualPath: string): string;
@@ -0,0 +1,38 @@
1
+ import { type DefaultParserRegistryOptions } from "../parser/defaults.js";
2
+ import type { ParserRegistry } from "../parser/registry.js";
3
+ /** Refuse to fully load/parse sources larger than this. Keeps Node heap stable on home folders. */
4
+ export declare const DEFAULT_MAX_SOURCE_BYTES: number;
5
+ export interface ParsedMirrorSyncOptions {
6
+ readonly root: string;
7
+ readonly searchPaths: readonly string[];
8
+ readonly registry?: ParserRegistry;
9
+ readonly parserOptions?: DefaultParserRegistryOptions;
10
+ readonly force?: boolean;
11
+ /** Override max source size for parse attempts (bytes). */
12
+ readonly maxSourceBytes?: number;
13
+ }
14
+ export type ParsedMirrorDiagnosticCode = "unsupported-file" | "parser-skipped" | "parser-failed" | "deleted-mirror" | "stale-index";
15
+ /** Path-opaque refresh diagnostic. `source` is an opaque virtual path, never a real fs path. */
16
+ export interface ParsedMirrorDiagnostic {
17
+ readonly code: ParsedMirrorDiagnosticCode;
18
+ readonly severity: "info" | "warning";
19
+ readonly message: string;
20
+ readonly source: string;
21
+ }
22
+ export interface ParsedMirrorSyncResult {
23
+ readonly scanned: number;
24
+ readonly written: number;
25
+ readonly deleted: number;
26
+ readonly skipped: number;
27
+ readonly indexPath: string;
28
+ readonly diagnostics: readonly ParsedMirrorDiagnostic[];
29
+ }
30
+ export declare function syncParsedMirrors(options: ParsedMirrorSyncOptions): Promise<ParsedMirrorSyncResult>;
31
+ /**
32
+ * Cheap, parse-free staleness check: compares current source files (by mtime and
33
+ * size only — no parsing) against the recorded mirror index. Returns a
34
+ * `stale-index` diagnostic (opaque virtual path) for every supported source that
35
+ * is new or changed since the last successful refresh. Safe to call outside the
36
+ * query hot path (e.g. from getRefreshStatus).
37
+ */
38
+ export declare function detectMirrorStaleness(options: ParsedMirrorSyncOptions): Promise<ParsedMirrorDiagnostic[]>;
@@ -0,0 +1,53 @@
1
+ export type AutoRAGRunEvent = {
2
+ event: "search_started";
3
+ timestamp: string;
4
+ sessionId: string;
5
+ queryLength: number;
6
+ orchestratorModel: string;
7
+ explorerModel: string;
8
+ } | {
9
+ event: "search_completed";
10
+ timestamp: string;
11
+ sessionId: string;
12
+ resultCount: number;
13
+ } | {
14
+ event: "search_failed";
15
+ timestamp: string;
16
+ sessionId: string;
17
+ errorType: string;
18
+ } | {
19
+ event: "cleanup_failed";
20
+ timestamp: string;
21
+ sessionId: string;
22
+ failureCount: number;
23
+ errorTypes: string[];
24
+ } | {
25
+ event: "dispatch_rejected";
26
+ schemaVersion: 1;
27
+ sessionId: string;
28
+ toolCallId: string | null;
29
+ sequence: number;
30
+ timestamp: string;
31
+ dispatchKind: "launch" | "admin" | "control" | "mutation" | "schedule" | "hybrid" | "unknown";
32
+ code: string;
33
+ field: string;
34
+ forceCorrectable: boolean;
35
+ } | {
36
+ event: "dispatch_autofilled";
37
+ schemaVersion: 1;
38
+ sessionId: string;
39
+ toolCallId: string | null;
40
+ sequence: number;
41
+ timestamp: string;
42
+ dispatchKind: "launch";
43
+ fields: {
44
+ artifacts: boolean;
45
+ agentScope: boolean;
46
+ leafModelFillCount: number;
47
+ };
48
+ };
49
+ export declare class AutoRAGRunLogger {
50
+ private readonly path;
51
+ constructor(path: string);
52
+ write(event: AutoRAGRunEvent): void;
53
+ }
@@ -0,0 +1,6 @@
1
+ import { type OcrParserOptions } from "./ocr.js";
2
+ import { ParserRegistry } from "./registry.js";
3
+ export interface DefaultParserRegistryOptions {
4
+ readonly ocr?: OcrParserOptions;
5
+ }
6
+ export declare function createDefaultParserRegistry(options?: DefaultParserRegistryOptions): ParserRegistry;
@@ -0,0 +1,6 @@
1
+ import { type ParseInput, type ParseOutput, Parser } from "./types.js";
2
+ export declare class EmlParser extends Parser {
3
+ readonly name = "eml";
4
+ readonly extensions: readonly [".eml"];
5
+ parse(input: ParseInput): Promise<ParseOutput>;
6
+ }
@@ -0,0 +1,5 @@
1
+ export declare class ParseError extends Error {
2
+ readonly parserName: string;
3
+ readonly virtualPath: string;
4
+ constructor(parserName: string, virtualPath: string, cause: unknown);
5
+ }
@@ -0,0 +1,6 @@
1
+ import { type ParseInput, type ParseOutput, Parser } from "./types.js";
2
+ export declare class HwpParser extends Parser {
3
+ readonly name = "hwp";
4
+ readonly extensions: readonly [".hwpx", ".hwp"];
5
+ parse(input: ParseInput): Promise<ParseOutput>;
6
+ }
@@ -0,0 +1,10 @@
1
+ export { createDefaultParserRegistry, type DefaultParserRegistryOptions } from "./defaults.js";
2
+ export { EmlParser } from "./eml.js";
3
+ export { ParseError } from "./errors.js";
4
+ export { HwpParser } from "./hwp.js";
5
+ export { ImageOcrParser, type OcrEngine, type OcrEngineInput, type OcrParserOptions } from "./ocr.js";
6
+ export { DocxParser, PptxParser, XlsxParser } from "./office.js";
7
+ export { OpendataloaderPdfParser, type PdfConverter } from "./opendataloader-pdf.js";
8
+ export { PlainTextParser } from "./plain-text.js";
9
+ export { ParserRegistry } from "./registry.js";
10
+ export { type ParseInput, type ParseOutput, Parser } from "./types.js";
@@ -0,0 +1,25 @@
1
+ import { type ParseInput, type ParseOutput, Parser } from "./types.js";
2
+ export interface OcrEngineInput {
3
+ readonly bytes: Uint8Array;
4
+ readonly languages: readonly string[];
5
+ readonly timeoutMs: number;
6
+ readonly signal: AbortSignal;
7
+ }
8
+ export type OcrEngine = (input: OcrEngineInput) => Promise<string>;
9
+ export interface OcrParserOptions {
10
+ readonly enabled: boolean;
11
+ readonly languages?: readonly string[];
12
+ readonly timeoutMs?: number;
13
+ readonly maxBytes?: number;
14
+ readonly engine?: OcrEngine;
15
+ }
16
+ export declare class ImageOcrParser extends Parser {
17
+ readonly name = "image-ocr";
18
+ readonly extensions: readonly [".jpg", ".jpeg", ".png", ".bmp", ".tiff"];
19
+ private readonly languages;
20
+ private readonly timeoutMs;
21
+ private readonly maxBytes;
22
+ private readonly engine;
23
+ constructor(options: OcrParserOptions);
24
+ parse(input: ParseInput): Promise<ParseOutput>;
25
+ }
@@ -0,0 +1,16 @@
1
+ import { type ParseInput, type ParseOutput, Parser } from "./types.js";
2
+ export declare class DocxParser extends Parser {
3
+ readonly name = "docx";
4
+ readonly extensions: readonly [".docx"];
5
+ parse(input: ParseInput): Promise<ParseOutput>;
6
+ }
7
+ export declare class PptxParser extends Parser {
8
+ readonly name = "pptx";
9
+ readonly extensions: readonly [".pptx"];
10
+ parse(input: ParseInput): Promise<ParseOutput>;
11
+ }
12
+ export declare class XlsxParser extends Parser {
13
+ readonly name = "xlsx";
14
+ readonly extensions: readonly [".xlsx", ".xls"];
15
+ parse(input: ParseInput): Promise<ParseOutput>;
16
+ }
@@ -0,0 +1,21 @@
1
+ import type { ConvertOptions } from "@opendataloader/pdf";
2
+ import { type ParseInput, type ParseOutput, Parser } from "./types.js";
3
+ export type PdfConverter = (inputPath: string, options: ConvertOptions) => Promise<string>;
4
+ export interface OpendataloaderPdfParserOptions {
5
+ readonly converter?: PdfConverter;
6
+ readonly ocr?: {
7
+ readonly enabled: boolean;
8
+ readonly timeoutMs?: number;
9
+ readonly hybrid?: string;
10
+ readonly hybridMode?: string;
11
+ readonly maxBytes?: number;
12
+ };
13
+ }
14
+ export declare class OpendataloaderPdfParser extends Parser {
15
+ readonly name = "opendataloader-pdf";
16
+ readonly extensions: readonly [".pdf"];
17
+ private readonly options;
18
+ private readonly converter;
19
+ constructor(options?: OpendataloaderPdfParserOptions);
20
+ parse(input: ParseInput): Promise<ParseOutput>;
21
+ }
@@ -0,0 +1,6 @@
1
+ import { type ParseInput, type ParseOutput, Parser } from "./types.js";
2
+ export declare class PlainTextParser extends Parser {
3
+ readonly name = "plain-text";
4
+ readonly extensions: readonly [".txt", ".text", ".md", ".markdown"];
5
+ parse(input: ParseInput): Promise<ParseOutput>;
6
+ }
@@ -0,0 +1,8 @@
1
+ import type { Parser } from "./types.js";
2
+ export declare class ParserRegistry {
3
+ private readonly parsersByExtension;
4
+ constructor(parsers?: readonly Parser[]);
5
+ register(parser: Parser): void;
6
+ getForVirtualPath(virtualPath: string): Parser | undefined;
7
+ list(): Parser[];
8
+ }
@@ -0,0 +1,2 @@
1
+ export declare function decodeText(bytes: Uint8Array): string;
2
+ export declare function normalizeMarkdown(markdown: string): string;
@@ -0,0 +1,14 @@
1
+ export interface ParseInput {
2
+ readonly virtualPath: string;
3
+ readonly sourcePath?: string;
4
+ readonly bytes: Uint8Array;
5
+ }
6
+ export interface ParseOutput {
7
+ readonly markdown: string;
8
+ readonly metadata?: Readonly<Record<string, unknown>>;
9
+ }
10
+ export declare abstract class Parser {
11
+ abstract readonly name: string;
12
+ abstract readonly extensions: readonly string[];
13
+ abstract parse(input: ParseInput): Promise<ParseOutput>;
14
+ }
@@ -0,0 +1,2 @@
1
+ export declare function readZipXmlText(bytes: Uint8Array, pathPattern: RegExp): Promise<string[]>;
2
+ export declare function extractTextFromXml(xml: string): string[];
@@ -0,0 +1,16 @@
1
+ export interface EvidenceIdInput {
2
+ readonly method: string;
3
+ readonly source: string;
4
+ readonly retrievalResultId?: string;
5
+ readonly chunkIndex?: number;
6
+ readonly lineNumber?: number;
7
+ readonly excerpt?: string;
8
+ readonly content?: string;
9
+ }
10
+ export interface NormalizedEvidenceRef extends EvidenceIdInput {
11
+ readonly stableEvidenceId: string;
12
+ }
13
+ export declare function normalizeEvidenceText(text: string): string;
14
+ export declare function isPathOpaqueIdentifier(value: string): boolean;
15
+ export declare function stableEvidenceId(input: EvidenceIdInput): string;
16
+ export declare function normalizeEvidenceRef(input: EvidenceIdInput): NormalizedEvidenceRef;
@@ -0,0 +1,7 @@
1
+ export type { MergeOptions } from "./merger.js";
2
+ export { ParallelRetriever, ResultMerger } from "./merger.js";
3
+ export type { BM25Engine, BM25FallbackMode, BM25MethodOptions, BM25ReadinessState, BM25Status, BM25SyncResult, } from "./methods/bm25.js";
4
+ export { BM25Method, BM25UnavailableError } from "./methods/bm25.js";
5
+ export { RetrievalMethodRegistry } from "./registry.js";
6
+ export { matchesVirtualPathScope, normalizeVirtualPath, normalizeVirtualPathScope, virtualPathScopeToRegExp, } from "./scope.js";
7
+ export type { CuratedResult, NumberedResult, RetrievalDiagnostic, RetrievalDiagnosticCode, RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult, RetrievalWithDiagnostics, } from "./types.js";
@@ -0,0 +1,18 @@
1
+ import type { RetrievalMethod, RetrievalOptions, RetrievalResult, RetrievalWithDiagnostics } from "./types.js";
2
+ export interface MergeOptions {
3
+ topK: number;
4
+ dedup: boolean;
5
+ }
6
+ export declare class ResultMerger {
7
+ merge(results: Map<string, RetrievalResult[]>, options: MergeOptions): RetrievalResult[];
8
+ }
9
+ export declare class ParallelRetriever {
10
+ retrieve(methods: RetrievalMethod[], query: string, options: RetrievalOptions): Promise<Map<string, RetrievalResult[]>>;
11
+ /**
12
+ * Like {@link retrieve} but also returns path-opaque diagnostics for methods
13
+ * that failed. Partial results from healthy methods are preserved; failed
14
+ * methods yield an empty result set plus a diagnostic. The legacy
15
+ * {@link retrieve} return shape is intentionally unchanged for compatibility.
16
+ */
17
+ retrieveWithDiagnostics(methods: RetrievalMethod[], query: string, options: RetrievalOptions): Promise<RetrievalWithDiagnostics>;
18
+ }
@@ -0,0 +1,52 @@
1
+ import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../types.js";
2
+ export type BM25ReadinessState = "disabled" | "dependency_unavailable" | "index_missing" | "indexing" | "ready" | "degraded_fallback" | "error";
3
+ export type BM25Engine = "tantivy" | "typescript-fallback" | "none";
4
+ export type BM25FallbackMode = "typescript" | "disabled";
5
+ export interface BM25MethodOptions {
6
+ readonly root: string;
7
+ readonly indexPath?: string;
8
+ readonly enabled?: boolean;
9
+ readonly fallback?: BM25FallbackMode;
10
+ readonly forceEngine?: Exclude<BM25Engine, "none">;
11
+ readonly importBinding?: () => Promise<TantivyBinding>;
12
+ }
13
+ export interface BM25SyncResult {
14
+ readonly indexPath: string;
15
+ readonly indexedChunks: number;
16
+ readonly readiness: BM25ReadinessState;
17
+ readonly engine: BM25Engine;
18
+ }
19
+ export interface BM25Status {
20
+ readonly readiness: BM25ReadinessState;
21
+ readonly engine: BM25Engine;
22
+ readonly message?: string;
23
+ }
24
+ type TantivyBinding = typeof import("@pngwasi/node-tantivy-binding");
25
+ export declare const BM25_SUBDIR: string;
26
+ export declare class BM25UnavailableError extends Error {
27
+ readonly readiness: BM25ReadinessState;
28
+ constructor(readiness: BM25ReadinessState, message: string);
29
+ }
30
+ export declare class BM25Method implements RetrievalMethod {
31
+ private readonly root;
32
+ private readonly indexPath;
33
+ private readonly fallback;
34
+ private readonly forceEngine;
35
+ private readonly importBinding;
36
+ private status;
37
+ constructor(options: BM25MethodOptions);
38
+ describe(): RetrievalMethodDescriptor;
39
+ getStatus(): BM25Status;
40
+ sync(): Promise<BM25SyncResult>;
41
+ retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
42
+ private writeTantivyIndex;
43
+ private retrieveTantivy;
44
+ private writeFallbackIndex;
45
+ private retrieveFallback;
46
+ private readFallbackIndex;
47
+ private hasFallbackIndex;
48
+ private tantivyIndexPath;
49
+ private fallbackIndexPath;
50
+ private syncResult;
51
+ }
52
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { RetrievalMethod } from "./types.js";
2
+ export declare class RetrievalMethodRegistry {
3
+ private readonly methods;
4
+ register(method: RetrievalMethod): void;
5
+ get(name: string): RetrievalMethod | undefined;
6
+ list(): RetrievalMethod[];
7
+ getByType(type: "posix" | "vector" | "bm25" | "hybrid" | "visual"): RetrievalMethod[];
8
+ }
@@ -0,0 +1,4 @@
1
+ export declare function normalizeVirtualPath(value: string): string;
2
+ export declare function normalizeVirtualPathScope(scope: string | undefined): string | undefined;
3
+ export declare function matchesVirtualPathScope(virtualPath: string, scope: string | undefined): boolean;
4
+ export declare function virtualPathScopeToRegExp(scope: string): RegExp;
@@ -0,0 +1,64 @@
1
+ export interface RetrievalResult {
2
+ id: string;
3
+ content: string;
4
+ source: string;
5
+ score: number;
6
+ metadata: Record<string, unknown>;
7
+ }
8
+ export interface RetrievalMethodDescriptor {
9
+ name: string;
10
+ type: "posix" | "vector" | "bm25" | "hybrid" | "visual";
11
+ description: string;
12
+ status: "active" | "stub";
13
+ capabilities: string[];
14
+ datasourceId?: string;
15
+ tags?: readonly string[];
16
+ }
17
+ export interface RetrievalOptions {
18
+ topK?: number;
19
+ scope?: string;
20
+ filters?: Record<string, unknown>;
21
+ allowedTags?: readonly string[];
22
+ allowedScopes?: readonly string[];
23
+ signal?: AbortSignal;
24
+ }
25
+ export interface RetrievalMethod {
26
+ describe(): RetrievalMethodDescriptor;
27
+ retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
28
+ }
29
+ export type RetrievalDiagnosticCode = "retrieval-method-failed" | "minsync-unavailable" | "bm25-unavailable" | "bm25-degraded-fallback";
30
+ /** Path-opaque diagnostic emitted by the multi-method retrieval pipeline. */
31
+ export interface RetrievalDiagnostic {
32
+ code: RetrievalDiagnosticCode;
33
+ severity: "info" | "warning" | "error";
34
+ message: string;
35
+ /** Component/method label — never a real filesystem path. */
36
+ source?: string;
37
+ }
38
+ export interface RetrievalWithDiagnostics {
39
+ results: Map<string, RetrievalResult[]>;
40
+ diagnostics: RetrievalDiagnostic[];
41
+ }
42
+ export interface NumberedResult {
43
+ index: number;
44
+ source: string;
45
+ content: string;
46
+ method: string;
47
+ }
48
+ export interface EvidenceReference {
49
+ method: string;
50
+ source: string;
51
+ excerpt?: string;
52
+ content?: string;
53
+ retrievalResultId?: string;
54
+ chunkIndex?: number;
55
+ lineNumber?: number;
56
+ stableEvidenceId: string;
57
+ }
58
+ export interface CuratedResult {
59
+ index: number;
60
+ content: string;
61
+ source: string;
62
+ method: string;
63
+ evidenceRefs?: readonly EvidenceReference[];
64
+ }
@@ -0,0 +1,90 @@
1
+ export declare const RETRIEVAL_METHODS: readonly ["posix", "bash", "posix/bash", "bm25", "minsync", "vector", "minsync/vector", "datasource"];
2
+ export type RetrievalMethod = (typeof RETRIEVAL_METHODS)[number];
3
+ export type SourceTemporalStatus = "asOf" | "updatedAt" | "createdAt" | "unknown";
4
+ export type SourceTemporal = {
5
+ readonly status: "asOf";
6
+ readonly asOf: string;
7
+ } | {
8
+ readonly status: "updatedAt";
9
+ readonly updatedAt: string;
10
+ } | {
11
+ readonly status: "createdAt";
12
+ readonly createdAt: string;
13
+ } | {
14
+ readonly status: "unknown";
15
+ };
16
+ export interface ExplorerAssignment {
17
+ readonly originalQuery: string;
18
+ readonly method: RetrievalMethod;
19
+ readonly queryVariant: string;
20
+ /** Optional set of variants retained when an orchestrator fans out work. */
21
+ readonly queryVariants?: readonly string[];
22
+ }
23
+ export interface EvidenceCandidate {
24
+ readonly source: string;
25
+ readonly method: RetrievalMethod;
26
+ readonly evidence: string;
27
+ readonly retrievedAt: string;
28
+ readonly sourceTemporal: SourceTemporal;
29
+ readonly locator?: string;
30
+ }
31
+ export interface ExplorerReport {
32
+ readonly assignment: ExplorerAssignment;
33
+ readonly evidenceCandidates: readonly EvidenceCandidate[];
34
+ /** Alias for consumers that use the shorter candidate field name. */
35
+ readonly candidates?: readonly EvidenceCandidate[];
36
+ readonly summary?: string;
37
+ }
38
+ export interface FollowUpRequest {
39
+ readonly reason: string;
40
+ readonly assignments: readonly ExplorerAssignment[];
41
+ }
42
+ export type JudgeDecision = {
43
+ readonly decision: "sufficient";
44
+ readonly rationale: string;
45
+ readonly followUp?: undefined;
46
+ } | {
47
+ readonly decision: "follow_up";
48
+ readonly rationale: string;
49
+ readonly followUp: FollowUpRequest;
50
+ };
51
+ export interface ExhaustionErrorDetails {
52
+ readonly code: "EXPLORER_EXHAUSTED";
53
+ readonly originalQuery: string;
54
+ readonly iterations: number;
55
+ readonly maxIterations: number;
56
+ readonly reason: string;
57
+ }
58
+ export type ContractErrorCode = "INVALID_OBJECT" | "MISSING_ORIGINAL_QUERY" | "INVALID_ORIGINAL_QUERY" | "MISSING_RETRIEVAL_METHOD" | "INVALID_RETRIEVAL_METHOD" | "MISSING_QUERY_VARIANT" | "INVALID_QUERY_VARIANT" | "INVALID_QUERY_VARIANTS" | "QUERY_VARIANT_NOT_INCLUDED" | "MISSING_SOURCE" | "INVALID_SOURCE" | "MISSING_EVIDENCE_METHOD" | "INVALID_EVIDENCE_METHOD" | "MISSING_EVIDENCE" | "INVALID_EVIDENCE" | "MISSING_RETRIEVED_AT" | "INVALID_RETRIEVED_AT" | "MISSING_SOURCE_TEMPORAL" | "INVALID_SOURCE_TEMPORAL" | "MISSING_SOURCE_TEMPORAL_DATE" | "INVALID_SOURCE_TEMPORAL_DATE" | "MISSING_ASSIGNMENT" | "MISSING_EVIDENCE_CANDIDATES" | "INVALID_EVIDENCE_CANDIDATES" | "INVALID_SUMMARY" | "MISSING_FOLLOW_UP_REASON" | "INVALID_FOLLOW_UP_REASON" | "MISSING_FOLLOW_UP_ASSIGNMENTS" | "EMPTY_FOLLOW_UP_ASSIGNMENTS" | "INVALID_FOLLOW_UP_ASSIGNMENTS" | "MISSING_JUDGE_DECISION" | "INVALID_JUDGE_DECISION" | "MISSING_JUDGE_RATIONALE" | "INVALID_JUDGE_RATIONALE" | "MISSING_FOLLOW_UP" | "INVALID_FOLLOW_UP" | "INVALID_EXHAUSTION_ERROR" | "INVALID_EXHAUSTION_CODE" | "MISSING_EXHAUSTION_QUERY" | "INVALID_EXHAUSTION_QUERY" | "INVALID_EXHAUSTION_ITERATIONS" | "INVALID_EXHAUSTION_LIMIT" | "MISSING_EXHAUSTION_REASON" | "INVALID_EXHAUSTION_REASON";
59
+ export declare class ContractValidationError extends Error {
60
+ readonly code: ContractErrorCode;
61
+ readonly path?: string;
62
+ constructor(code: ContractErrorCode, message: string, path?: string);
63
+ }
64
+ export declare class ExplorerExhaustionError extends Error {
65
+ readonly code: "EXPLORER_EXHAUSTED";
66
+ readonly originalQuery: string;
67
+ readonly iterations: number;
68
+ readonly maxIterations: number;
69
+ readonly reason: string;
70
+ constructor(details: Omit<ExhaustionErrorDetails, "code">);
71
+ toJSON(): ExhaustionErrorDetails;
72
+ }
73
+ export declare function parseExplorerAssignment(value: unknown): ExplorerAssignment;
74
+ export declare function parseEvidenceCandidate(value: unknown): EvidenceCandidate;
75
+ export declare function parseExplorerReport(value: unknown): ExplorerReport;
76
+ export declare function parseFollowUpRequest(value: unknown): FollowUpRequest;
77
+ export declare function parseJudgeDecision(value: unknown): JudgeDecision;
78
+ export declare function parseExhaustionError(value: unknown): ExhaustionErrorDetails;
79
+ export declare function isExplorerAssignment(value: unknown): value is ExplorerAssignment;
80
+ export declare function isEvidenceCandidate(value: unknown): value is EvidenceCandidate;
81
+ export declare function isExplorerReport(value: unknown): value is ExplorerReport;
82
+ export declare function isFollowUpRequest(value: unknown): value is FollowUpRequest;
83
+ export declare function isJudgeDecision(value: unknown): value is JudgeDecision;
84
+ export declare function isExhaustionError(value: unknown): value is ExhaustionErrorDetails;
85
+ export declare function safeParseExplorerAssignment(value: unknown): ExplorerAssignment | undefined;
86
+ export declare function safeParseEvidenceCandidate(value: unknown): EvidenceCandidate | undefined;
87
+ export declare function safeParseExplorerReport(value: unknown): ExplorerReport | undefined;
88
+ export declare function safeParseFollowUpRequest(value: unknown): FollowUpRequest | undefined;
89
+ export declare function safeParseJudgeDecision(value: unknown): JudgeDecision | undefined;
90
+ export declare function safeParseExhaustionError(value: unknown): ExhaustionErrorDetails | undefined;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Shared dispatch template builders, skeleton literals, and anti-examples for
3
+ * AutoRAG explorer subagent dispatch.
4
+ *
5
+ * This module is the single source of truth for:
6
+ * - Assignment V1 sentinel/role-line constants and block builder
7
+ * - Single-root and multi-root success dispatch payload builders
8
+ * - Compact skeleton literals consumed by `formatBlockReason`
9
+ * - Anti-examples for rejected dispatch patterns
10
+ * - Stable coded patch-error reference (single source of truth for the error catalog)
11
+ *
12
+ * `buildSearchPrompt` and prompt tests reuse these builders so no divergent
13
+ * template text exists inside TypeScript.
14
+ */
15
+ export declare const AUTORAG_ASSIGNMENT_V1_START = "<<<AUTORAG_ASSIGNMENT_V1>>>";
16
+ export declare const AUTORAG_ASSIGNMENT_V1_END = "<<<END_AUTORAG_ASSIGNMENT_V1>>>";
17
+ export declare const AUTORAG_ROLE_LINE_RETRIEVED_AT = "Required handoff: include retrievedAt.";
18
+ export declare const AUTORAG_ROLE_LINE_TEMPORAL_METADATA = "Required handoff: include temporal metadata.";
19
+ export declare const AUTORAG_CANONICAL_ROLE_LINES = "Required handoff: include retrievedAt.\nRequired handoff: include temporal metadata.";
20
+ export declare const PLACEHOLDER_CONFIGURED_MODEL = "<configured-model>";
21
+ export declare const PLACEHOLDER_ALLOWED_ROOT = "<allowed-root>";
22
+ export declare const PLACEHOLDER_ASSIGNMENT_V1_BLOCK = "<Assignment V1 block>";
23
+ export declare const PLACEHOLDER_CALLER_QUERY = "<caller query verbatim>";
24
+ export declare const DISPATCH_ADMIN_SKELETON = "{\"action\":\"list\"}";
25
+ export declare const DISPATCH_SINGLE_SKELETON = "{\"agentScope\":\"user\",\"artifacts\":false,\"agent\":\"autorag-explorer\",\"model\":\"<configured-model>\",\"cwd\":\"<allowed-root>\",\"task\":\"<Assignment V1 block>\"}";
26
+ export declare const DISPATCH_FANOUT_SKELETON = "{\"agentScope\":\"user\",\"artifacts\":false,\"tasks\":[{\"agent\":\"autorag-explorer\",\"model\":\"<configured-model>\",\"cwd\":\"<allowed-root>\",\"task\":\"<Assignment V1 block>\"}]}";
27
+ export interface AssignmentV1Options {
28
+ readonly originalQuery: string;
29
+ readonly method: string;
30
+ readonly queryVariants: readonly string[];
31
+ }
32
+ /**
33
+ * Build a canonical Assignment V1 block string for use as the `task` field
34
+ * value in a subagent dispatch payload.
35
+ *
36
+ * Output shape (LF-joined):
37
+ * ```
38
+ * <<<AUTORAG_ASSIGNMENT_V1>>>
39
+ * {"originalQuery":"...","method":"...","queryVariants":["..."]}
40
+ * <<<END_AUTORAG_ASSIGNMENT_V1>>>
41
+ * Required handoff: include retrievedAt.
42
+ * Required handoff: include temporal metadata.
43
+ * ```
44
+ */
45
+ export declare function buildAssignmentV1Block(opts: AssignmentV1Options): string;
46
+ export interface SingleRootDispatchOptions {
47
+ readonly explorerModel: string;
48
+ readonly allowedRoot: string;
49
+ readonly task: string;
50
+ }
51
+ /**
52
+ * Build a single-root success dispatch payload as pretty-printed JSON.
53
+ *
54
+ * `agentScope` and `artifacts` are set exactly once at the top level.
55
+ * The single leaf carries `agent`, `model`, `cwd`, and `task`.
56
+ * Pass `PLACEHOLDER_*` constants for prompt examples or real values for
57
+ * actual dispatch payloads.
58
+ */
59
+ export declare function buildSingleRootDispatchPayload(opts: SingleRootDispatchOptions): string;
60
+ export interface MultiRootDispatchTask {
61
+ readonly explorerModel: string;
62
+ readonly allowedRoot: string;
63
+ readonly task: string;
64
+ }
65
+ /**
66
+ * Build a multi-root success dispatch payload as pretty-printed JSON.
67
+ *
68
+ * `agentScope` and `artifacts` are set exactly once at the top level.
69
+ * Each task in `tasks` carries `agent`, `model`, `cwd`, and `task` and
70
+ * omits `agentScope`/`artifacts`. Pass one task per configured root.
71
+ */
72
+ export declare function buildMultiRootDispatchPayload(tasks: readonly MultiRootDispatchTask[]): string;
73
+ export interface DispatchAntiExample {
74
+ readonly label: string;
75
+ readonly body: string;
76
+ readonly reason: string;
77
+ }
78
+ /**
79
+ * Brief anti-examples showing dispatch patterns that are rejected.
80
+ * Each body is pretty-printed JSON using non-sensitive placeholders only.
81
+ */
82
+ export declare const DISPATCH_ANTIEXAMPLES: readonly DispatchAntiExample[];
83
+ export interface DispatchErrorInfo {
84
+ readonly code: string;
85
+ readonly exactFix: string;
86
+ readonly forceCorrectable: boolean;
87
+ }
88
+ /**
89
+ * Reference table of stable dispatch rejection codes, their exactFix strings,
90
+ * and forceCorrectable flags. This is the single source of truth for the error
91
+ * catalog — `dispatch-validation.ts` derives its `EXACT_FIX_MAP` and
92
+ * `FORCE_CORRECTABLE_MAP` from this table so no dual catalog exists.
93
+ *
94
+ * `DISPATCH_ROLE_METADATA_INVALID` is intentionally absent: valid tasks are
95
+ * normalized by `ensureRoleLines` and no rejection path emits that code.
96
+ */
97
+ export declare const DISPATCH_ERROR_REFERENCE: readonly DispatchErrorInfo[];
98
+ /**
99
+ * Build the `### Canonical dispatch templates` subsection text for the system
100
+ * prompt. Uses the builders and constants above so no divergent template text
101
+ * exists. The `explorerModelId` parameter fills the model field in the example
102
+ * payloads.
103
+ */
104
+ export declare function buildDispatchTemplatesPromptSection(explorerModelId: string): string;