@autorag/librarian 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +275 -0
- package/dist/agent/agent.d.ts +294 -0
- package/dist/agent/bash-tool.d.ts +41 -0
- package/dist/agent/datasource-skill.d.ts +45 -0
- package/dist/agent/emit-results-tool.d.ts +75 -0
- package/dist/agent/index.d.ts +11 -0
- package/dist/agent/jikji-find-tool.d.ts +73 -0
- package/dist/agent/search-all-tool.d.ts +36 -0
- package/dist/agent/search-bm25-tool.d.ts +18 -0
- package/dist/agent/search-datasource-tool.d.ts +26 -0
- package/dist/agent/search-documents.d.ts +56 -0
- package/dist/agent/search-minsync-tool.d.ts +24 -0
- package/dist/agent/system-prompt.d.ts +13 -0
- package/dist/agent/watch-refresh.d.ts +29 -0
- package/dist/cli/commands/feedback.d.ts +8 -0
- package/dist/cli/commands/health.d.ts +146 -0
- package/dist/cli/commands/index.d.ts +9 -0
- package/dist/cli/commands/init.d.ts +9 -0
- package/dist/cli/commands/memory.d.ts +8 -0
- package/dist/cli/commands/refresh.d.ts +19 -0
- package/dist/cli/commands/search.d.ts +34 -0
- package/dist/cli/commands/status.d.ts +7 -0
- package/dist/cli/commands/types.d.ts +10 -0
- package/dist/cli/commands/watch.d.ts +8 -0
- package/dist/cli/config.d.ts +172 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.js +10845 -0
- package/dist/cli/output.d.ts +32 -0
- package/dist/config/home.d.ts +2 -0
- package/dist/datasource/access-context.d.ts +49 -0
- package/dist/datasource/diagnostics.d.ts +20 -0
- package/dist/datasource/index.d.ts +9 -0
- package/dist/datasource/polling.d.ts +51 -0
- package/dist/datasource/registry.d.ts +52 -0
- package/dist/datasource/result-filter.d.ts +63 -0
- package/dist/datasource/scope.d.ts +38 -0
- package/dist/datasource/skills/katok/client.d.ts +24 -0
- package/dist/datasource/skills/katok/index.d.ts +12 -0
- package/dist/datasource/skills/katok/methods.d.ts +40 -0
- package/dist/datasource/skills/katok/paths.d.ts +40 -0
- package/dist/datasource/skills/katok/skill.d.ts +33 -0
- package/dist/datasource/skills/katok/types.d.ts +146 -0
- package/dist/datasource/types.d.ts +183 -0
- package/dist/filesystem/file-lock.d.ts +16 -0
- package/dist/filesystem/source-paths.d.ts +38 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9361 -0
- package/dist/jikji/answer-pack.d.ts +31 -0
- package/dist/jikji/client.d.ts +18 -0
- package/dist/jikji/diagnostics.d.ts +26 -0
- package/dist/jikji/index.d.ts +10 -0
- package/dist/jikji/installer.d.ts +46 -0
- package/dist/jikji/path-map.d.ts +8 -0
- package/dist/jikji/types.d.ts +112 -0
- package/dist/manifest/index.d.ts +2 -0
- package/dist/manifest/loader.d.ts +3 -0
- package/dist/manifest/types.d.ts +8 -0
- package/dist/memory/check-memory-tool.d.ts +13 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/memory.d.ts +179 -0
- package/dist/memory/renderer.d.ts +6 -0
- package/dist/minsync/client.d.ts +14 -0
- package/dist/minsync/embedder-config.d.ts +22 -0
- package/dist/minsync/index.d.ts +7 -0
- package/dist/minsync/installer.d.ts +27 -0
- package/dist/minsync/method.d.ts +37 -0
- package/dist/minsync/paths.d.ts +4 -0
- package/dist/minsync/process.d.ts +10 -0
- package/dist/minsync/types.d.ts +33 -0
- package/dist/minsync/workspace.d.ts +14 -0
- package/dist/mirror/index-store.d.ts +16 -0
- package/dist/mirror/index.d.ts +5 -0
- package/dist/mirror/paths.d.ts +6 -0
- package/dist/mirror/sync.d.ts +38 -0
- package/dist/observability/run-log.d.ts +53 -0
- package/dist/parser/defaults.d.ts +6 -0
- package/dist/parser/eml.d.ts +6 -0
- package/dist/parser/errors.d.ts +5 -0
- package/dist/parser/hwp.d.ts +6 -0
- package/dist/parser/index.d.ts +10 -0
- package/dist/parser/ocr.d.ts +25 -0
- package/dist/parser/office.d.ts +16 -0
- package/dist/parser/opendataloader-pdf.d.ts +21 -0
- package/dist/parser/plain-text.d.ts +6 -0
- package/dist/parser/registry.d.ts +8 -0
- package/dist/parser/text.d.ts +2 -0
- package/dist/parser/types.d.ts +14 -0
- package/dist/parser/xml-text.d.ts +2 -0
- package/dist/retrieval/evidence-id.d.ts +16 -0
- package/dist/retrieval/index.d.ts +7 -0
- package/dist/retrieval/merger.d.ts +18 -0
- package/dist/retrieval/methods/bm25.d.ts +52 -0
- package/dist/retrieval/registry.d.ts +8 -0
- package/dist/retrieval/scope.d.ts +4 -0
- package/dist/retrieval/types.d.ts +64 -0
- package/dist/subagents/contracts.d.ts +90 -0
- package/dist/subagents/dispatch-templates.d.ts +104 -0
- package/dist/subagents/dispatch-validation.d.ts +169 -0
- package/dist/subagents/explorer-tools-extension.d.ts +4 -0
- package/dist/subagents/explorer-tools-extension.js +130 -0
- package/dist/subagents/local-models.d.ts +14 -0
- package/dist/subagents/model-policy.d.ts +31 -0
- package/dist/subagents/runtime.d.ts +52 -0
- package/dist/tool/index.d.ts +1 -0
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +66 -0
- package/skills/autorag/SKILL.md +149 -0
- package/skills/autorag-setup/SKILL.md +396 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SourceRoot } from "../filesystem/source-paths.js";
|
|
2
|
+
import type { JikjiAnswerPack } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Strict-parse and validate a `jikji find --json` answer-pack from raw stdout.
|
|
5
|
+
*
|
|
6
|
+
* Required fields are checked for presence and correct type; the
|
|
7
|
+
* `candidates[].next_read` and `evidence_pack[].next_read` enums and the
|
|
8
|
+
* `handoff_action` enum are validated. Extra fields are tolerated. Returns
|
|
9
|
+
* `undefined` when ANY required field is missing or wrong-typed, or when the
|
|
10
|
+
* stdout is not valid JSON.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseJikjiAnswerPack(stdout: string): JikjiAnswerPack | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Normalize a path returned in a jikji answer-pack into a REAL absolute path
|
|
15
|
+
* usable by bash, scoped to one of the configured source roots.
|
|
16
|
+
*
|
|
17
|
+
* Accepted forms:
|
|
18
|
+
* - An absolute path that `realpath`-resolves within a configured root.
|
|
19
|
+
* - A relative path scoped to a root (resolved against each root in turn).
|
|
20
|
+
*
|
|
21
|
+
* Rejected:
|
|
22
|
+
* - Root escapes (realpath outside every root).
|
|
23
|
+
* - Windows drive-letter paths (`C:\...`, `C:/...`).
|
|
24
|
+
* - URL-like values (`https://`, `file://`, `file:foo`).
|
|
25
|
+
* - Empty / non-string input.
|
|
26
|
+
*
|
|
27
|
+
* Duplicate roots (same real path) are deduped: the first matching root wins
|
|
28
|
+
* and subsequent identical roots are skipped. Output is a real absolute path —
|
|
29
|
+
* no opaque IDs, no sanitization.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeJikjiAnswerPath(rawPath: string, sourceRoots: readonly SourceRoot[]): string | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JikjiFindOptions, JikjiFindResult, JikjiOptions, JikjiPrepareOptions, JikjiPrepareResult } from "./types.js";
|
|
2
|
+
export declare class JikjiClient {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private resolvedCommand;
|
|
5
|
+
constructor(options?: JikjiOptions);
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the jikji command following the priority chain:
|
|
8
|
+
* 1. explicit binaryPath
|
|
9
|
+
* 2. PATH lookup for `jikji`
|
|
10
|
+
* 3. cached `<root>/.autorag/bin/jikji`
|
|
11
|
+
* 4. autoInstall (default true) via `cargo install jikji-cli` into the cache
|
|
12
|
+
* 5. bare `jikji` (spawn-error degrade preserves the previous behavior)
|
|
13
|
+
* The result is cached per client so a failed install is not retried.
|
|
14
|
+
*/
|
|
15
|
+
private resolveCommand;
|
|
16
|
+
prepare(root: string, options?: JikjiPrepareOptions): Promise<JikjiPrepareResult>;
|
|
17
|
+
find(root: string, query: string, options?: JikjiFindOptions): Promise<JikjiFindResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JikjiFindResult, JikjiPrepareResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Diagnostic codes for the optional Jikji indexing/preparation layer. These are
|
|
4
|
+
* a subset of the search-level diagnostic code union and are intentionally
|
|
5
|
+
* path-free so they can be surfaced through public search/refresh diagnostics
|
|
6
|
+
* without leaking filesystem or binary paths.
|
|
7
|
+
*/
|
|
8
|
+
export type JikjiDiagnosticCode = "jikji-unavailable" | "jikji-prepare-failed" | "jikji-find-failed";
|
|
9
|
+
export interface JikjiDiagnostic {
|
|
10
|
+
readonly code: JikjiDiagnosticCode;
|
|
11
|
+
readonly severity: "warning" | "error";
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly source: "jikji";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Maps a {@link JikjiPrepareResult} to a path-opaque degraded-mode diagnostic.
|
|
17
|
+
* Successful results map to `undefined`. The message never echoes the binary
|
|
18
|
+
* path, stderr, or any filesystem path so it is safe for public diagnostics.
|
|
19
|
+
*/
|
|
20
|
+
export declare function jikjiPrepareDiagnostic(result: JikjiPrepareResult): JikjiDiagnostic | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Maps a {@link JikjiFindResult} to a path-opaque degraded-mode diagnostic.
|
|
23
|
+
* Successful results map to `undefined`. The message never echoes the binary
|
|
24
|
+
* path, stderr, or any filesystem path so it is safe for public diagnostics.
|
|
25
|
+
*/
|
|
26
|
+
export declare function jikjiFindDiagnostic(result: JikjiFindResult): JikjiDiagnostic | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { normalizeJikjiAnswerPath, parseJikjiAnswerPack, } from "./answer-pack.js";
|
|
2
|
+
export { JikjiClient } from "./client.js";
|
|
3
|
+
export type { JikjiDiagnostic, JikjiDiagnosticCode } from "./diagnostics.js";
|
|
4
|
+
export { jikjiFindDiagnostic, jikjiPrepareDiagnostic } from "./diagnostics.js";
|
|
5
|
+
export type { EnsureJikjiBinaryOptions, EnsureJikjiBinaryResult, JikjiInstallRunner, JikjiInstallRunResult, } from "./installer.js";
|
|
6
|
+
export { cachedJikjiBinaryPath, ensureJikjiBinary, JIKJI_CRATE_NAME, JIKJI_INSTALL_TIMEOUT_MS, jikjiExecutableName, lookupExecutableInPath, } from "./installer.js";
|
|
7
|
+
export type { JikjiSourceRoot } from "./path-map.js";
|
|
8
|
+
export { mapJikjiPath, planJikjiSourceRoots, resolveReturnedPath } from "./path-map.js";
|
|
9
|
+
export type { JikjiAnswerPack, JikjiCandidate, JikjiEvidence, JikjiFailureReason, JikjiFindOptions, JikjiFindResult, JikjiHandoffAction, JikjiNextRead, JikjiOptions, JikjiPrepareOptions, JikjiPrepareResult, JikjiToolCallPolicy, } from "./types.js";
|
|
10
|
+
export { DEFAULT_JIKJI_OPTIONS } from "./types.js";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jikji CLI installer. Jikji ships as the `jikji-cli` crate on crates.io
|
|
3
|
+
* (binary name `jikji`); there are no prebuilt GitHub release binaries, so
|
|
4
|
+
* installation compiles from source through the user's Rust toolchain.
|
|
5
|
+
* The binary is cached under `<root>/.autorag/bin` — the same directory the
|
|
6
|
+
* MinSync installer uses.
|
|
7
|
+
*/
|
|
8
|
+
export declare const JIKJI_CRATE_NAME = "jikji-cli";
|
|
9
|
+
export declare const JIKJI_INSTALL_TIMEOUT_MS: number;
|
|
10
|
+
export declare function jikjiExecutableName(platform?: NodeJS.Platform): string;
|
|
11
|
+
export declare function cargoExecutableName(platform?: NodeJS.Platform): string;
|
|
12
|
+
export declare function cachedJikjiBinaryPath(root: string, platform?: NodeJS.Platform): string;
|
|
13
|
+
/** Resolve an executable from PATH directories. Returns the absolute path of the first match or undefined. */
|
|
14
|
+
export declare function lookupExecutableInPath(executable: string, env: NodeJS.ProcessEnv): string | undefined;
|
|
15
|
+
export interface JikjiInstallRunResult {
|
|
16
|
+
readonly code: number | null;
|
|
17
|
+
readonly stderr: string;
|
|
18
|
+
}
|
|
19
|
+
export type JikjiInstallRunner = (args: readonly string[], timeoutMs: number) => Promise<JikjiInstallRunResult>;
|
|
20
|
+
export interface EnsureJikjiBinaryOptions {
|
|
21
|
+
/** Workspace root; the binary is cached at `<root>/.autorag/bin/jikji`. */
|
|
22
|
+
readonly root: string;
|
|
23
|
+
/** crates.io version pin for `jikji-cli`. Defaults to latest. */
|
|
24
|
+
readonly version?: string;
|
|
25
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
26
|
+
readonly timeoutMs?: number;
|
|
27
|
+
/** Injectable process runner for tests. Defaults to spawning `cargo install`. */
|
|
28
|
+
readonly runner?: JikjiInstallRunner;
|
|
29
|
+
/** Injectable cargo lookup for tests. Defaults to PATH lookup. */
|
|
30
|
+
readonly cargoLocator?: (env: NodeJS.ProcessEnv) => string | undefined;
|
|
31
|
+
}
|
|
32
|
+
export type EnsureJikjiBinaryResult = {
|
|
33
|
+
readonly ok: true;
|
|
34
|
+
readonly binaryPath: string;
|
|
35
|
+
readonly source: "cached" | "installed";
|
|
36
|
+
} | {
|
|
37
|
+
readonly ok: false;
|
|
38
|
+
readonly reason: "missing-cargo" | "install-failed";
|
|
39
|
+
readonly message: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Ensure a `jikji` binary exists under `<root>/.autorag/bin`, installing the
|
|
43
|
+
* `jikji-cli` crate through cargo when missing. Never throws: failures are
|
|
44
|
+
* reported as degraded results so callers can fall back to raw discovery.
|
|
45
|
+
*/
|
|
46
|
+
export declare function ensureJikjiBinary(options: EnsureJikjiBinaryOptions): Promise<EnsureJikjiBinaryResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SourceRoot } from "../filesystem/source-paths.js";
|
|
2
|
+
export interface JikjiSourceRoot extends SourceRoot {
|
|
3
|
+
readonly searchPath: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function planJikjiSourceRoots(searchPaths: readonly string[]): readonly JikjiSourceRoot[];
|
|
6
|
+
export declare function mapJikjiPath(sourceRoot: SourceRoot, returnedPath: string): string | undefined;
|
|
7
|
+
export declare function resolveReturnedPath(rootPath: string, returnedPath: string): string | undefined;
|
|
8
|
+
export declare function isUnsafeReturnedPath(normalizedPath: string): boolean;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export interface JikjiOptions {
|
|
2
|
+
readonly binaryPath?: string;
|
|
3
|
+
/** Workspace root used to cache/auto-install the jikji binary under `.autorag/bin`. */
|
|
4
|
+
readonly root?: string;
|
|
5
|
+
/**
|
|
6
|
+
* When true (default) and no `jikji` binary is found on PATH or in the
|
|
7
|
+
* `.autorag/bin` cache, install the `jikji-cli` crate from crates.io via
|
|
8
|
+
* cargo. Set false to disable auto-installation.
|
|
9
|
+
*/
|
|
10
|
+
readonly autoInstall?: boolean;
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
readonly maxBufferBytes?: number;
|
|
13
|
+
readonly includeHidden?: boolean;
|
|
14
|
+
readonly includeSensitive?: boolean;
|
|
15
|
+
readonly parseTimeout?: number;
|
|
16
|
+
readonly maxFiles?: number;
|
|
17
|
+
readonly exclude?: readonly string[];
|
|
18
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
19
|
+
readonly maxHashBytes?: number;
|
|
20
|
+
readonly docTextMaxChars?: number;
|
|
21
|
+
readonly docTextChunkChars?: number;
|
|
22
|
+
/**
|
|
23
|
+
* SAFE DEFAULT: AutoRAG passes `--no-agent-rules` to `jikji prepare` so it
|
|
24
|
+
* NEVER rewrites AGENTS.md/CLAUDE.md/.cursorrules. Set `writeAgentRules: true`
|
|
25
|
+
* to opt INTO upstream routing-block injection. This is the only way to omit
|
|
26
|
+
* `--no-agent-rules`.
|
|
27
|
+
*/
|
|
28
|
+
readonly writeAgentRules?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Kept for back-compat. No longer controls `--no-agent-rules`.
|
|
31
|
+
* Use `writeAgentRules` instead. The flag is always emitted unless
|
|
32
|
+
* `writeAgentRules === true`.
|
|
33
|
+
*/
|
|
34
|
+
readonly noAgentRules?: boolean;
|
|
35
|
+
readonly enableMediaIndex?: boolean;
|
|
36
|
+
readonly mediaIndexMaxMb?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface JikjiDefaultOptions {
|
|
39
|
+
readonly binaryPath: string;
|
|
40
|
+
readonly timeoutMs: number;
|
|
41
|
+
readonly maxBufferBytes: number;
|
|
42
|
+
readonly includeHidden: boolean;
|
|
43
|
+
readonly includeSensitive: boolean;
|
|
44
|
+
readonly maxFiles: number;
|
|
45
|
+
readonly writeAgentRules: boolean;
|
|
46
|
+
readonly enableMediaIndex: boolean;
|
|
47
|
+
readonly exclude: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
export declare const DEFAULT_JIKJI_OPTIONS: JikjiDefaultOptions;
|
|
50
|
+
export interface JikjiPrepareOptions {
|
|
51
|
+
readonly signal?: AbortSignal;
|
|
52
|
+
}
|
|
53
|
+
export type JikjiFailureReason = "aborted" | "nonzero-exit" | "spawn-error" | "stderr-too-large" | "stdout-too-large" | "timeout" | "bad-answer-pack";
|
|
54
|
+
export type JikjiPrepareResult = {
|
|
55
|
+
readonly ok: true;
|
|
56
|
+
readonly stdout: string;
|
|
57
|
+
readonly stderr: string;
|
|
58
|
+
readonly code: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly ok: false;
|
|
61
|
+
readonly reason: JikjiFailureReason;
|
|
62
|
+
readonly stdout: string;
|
|
63
|
+
readonly stderr: string;
|
|
64
|
+
readonly code: number | null;
|
|
65
|
+
};
|
|
66
|
+
export type JikjiNextRead = "cache" | "wiki" | "original" | "none";
|
|
67
|
+
export interface JikjiCandidate {
|
|
68
|
+
readonly path: string;
|
|
69
|
+
readonly nextRead: JikjiNextRead;
|
|
70
|
+
readonly label?: string;
|
|
71
|
+
readonly score?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface JikjiEvidence {
|
|
74
|
+
readonly path: string;
|
|
75
|
+
readonly nextRead: JikjiNextRead;
|
|
76
|
+
}
|
|
77
|
+
export interface JikjiToolCallPolicy {
|
|
78
|
+
readonly stopAfterFind: boolean;
|
|
79
|
+
readonly forbiddenTools: readonly string[];
|
|
80
|
+
readonly allowedFollowups: readonly string[];
|
|
81
|
+
}
|
|
82
|
+
export type JikjiHandoffAction = "direct_use" | "jikji_retry" | "raw_fallback_after_retry";
|
|
83
|
+
export interface JikjiAnswerPack {
|
|
84
|
+
readonly answerPaths: readonly string[];
|
|
85
|
+
readonly paths: readonly string[];
|
|
86
|
+
readonly candidates: readonly JikjiCandidate[];
|
|
87
|
+
readonly evidencePack: readonly JikjiEvidence[];
|
|
88
|
+
readonly handoffAction: JikjiHandoffAction;
|
|
89
|
+
readonly toolCallPolicy: JikjiToolCallPolicy;
|
|
90
|
+
readonly agentShouldNotRerank: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface JikjiFindOptions {
|
|
93
|
+
readonly topK?: number;
|
|
94
|
+
readonly first?: boolean;
|
|
95
|
+
readonly fresh?: boolean;
|
|
96
|
+
readonly autoPrepare?: boolean;
|
|
97
|
+
readonly staleAfterSeconds?: number;
|
|
98
|
+
readonly signal?: AbortSignal;
|
|
99
|
+
}
|
|
100
|
+
export type JikjiFindResult = {
|
|
101
|
+
readonly ok: true;
|
|
102
|
+
readonly answerPack: JikjiAnswerPack;
|
|
103
|
+
readonly stdout: string;
|
|
104
|
+
readonly stderr: string;
|
|
105
|
+
readonly code: number;
|
|
106
|
+
} | {
|
|
107
|
+
readonly ok: false;
|
|
108
|
+
readonly reason: JikjiFailureReason;
|
|
109
|
+
readonly stdout: string;
|
|
110
|
+
readonly stderr: string;
|
|
111
|
+
readonly code: number | null;
|
|
112
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { RetrievalMemory } from "./memory.js";
|
|
4
|
+
declare const checkMemorySchema: Type.TObject<{
|
|
5
|
+
query: Type.TString;
|
|
6
|
+
}>;
|
|
7
|
+
export interface CheckMemoryDetails {
|
|
8
|
+
signalCount: number;
|
|
9
|
+
topMethod: string | null;
|
|
10
|
+
insightCount: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createCheckMemoryTool(memory: RetrievalMemory): AgentTool<typeof checkMemorySchema, CheckMemoryDetails>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { CheckMemoryDetails } from "./check-memory-tool.js";
|
|
2
|
+
export { createCheckMemoryTool } from "./check-memory-tool.js";
|
|
3
|
+
export type { MemoryEntry, ResultFeedback, RetrievalInsight, RetrievalMemoryOptions, SearchAttempt } from "./memory.js";
|
|
4
|
+
export { RetrievalMemory } from "./memory.js";
|
|
5
|
+
export { renderMemoryContext } from "./renderer.js";
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { type NormalizedEvidenceRef } from "../retrieval/evidence-id.js";
|
|
2
|
+
export type FeedbackOutcome = "pending" | "useful" | "not_useful";
|
|
3
|
+
export type FeedbackSentiment = "useful" | "not_useful";
|
|
4
|
+
export type FeedbackSignalSource = "explicit" | "followup" | "retry";
|
|
5
|
+
export interface SignalDefaults {
|
|
6
|
+
readonly explicitWeight: number;
|
|
7
|
+
readonly followupWeight: number;
|
|
8
|
+
readonly retryWeight: number;
|
|
9
|
+
readonly implicitCap: number;
|
|
10
|
+
readonly decayHalfLifeMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface EvidenceChunkRecord extends NormalizedEvidenceRef {
|
|
13
|
+
readonly excerptHash: string;
|
|
14
|
+
readonly firstSeenAt: number;
|
|
15
|
+
readonly lastSeenAt: number;
|
|
16
|
+
readonly metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface CuratedResultRecord {
|
|
19
|
+
readonly resultId: string;
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
readonly number: number;
|
|
22
|
+
readonly query: string;
|
|
23
|
+
readonly title: string;
|
|
24
|
+
readonly summary: string;
|
|
25
|
+
readonly resultHash: string;
|
|
26
|
+
readonly evidenceIds: readonly string[];
|
|
27
|
+
readonly createdAt: number;
|
|
28
|
+
}
|
|
29
|
+
export interface FeedbackSignal {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly target: {
|
|
32
|
+
readonly type: "curated_result";
|
|
33
|
+
readonly resultId: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "evidence_chunk";
|
|
36
|
+
readonly stableEvidenceId: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "method";
|
|
39
|
+
readonly method: string;
|
|
40
|
+
};
|
|
41
|
+
readonly query: string;
|
|
42
|
+
readonly method?: string;
|
|
43
|
+
readonly sentiment: FeedbackSentiment;
|
|
44
|
+
readonly source: FeedbackSignalSource;
|
|
45
|
+
readonly weight: number;
|
|
46
|
+
readonly confidenceCap: number;
|
|
47
|
+
readonly eventId: string;
|
|
48
|
+
readonly timestamp: number;
|
|
49
|
+
}
|
|
50
|
+
export interface MethodHint {
|
|
51
|
+
readonly method: string;
|
|
52
|
+
readonly score: number;
|
|
53
|
+
readonly confidence: number;
|
|
54
|
+
readonly reason: string;
|
|
55
|
+
}
|
|
56
|
+
export interface RetrievalInsight {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly clusterKey: string;
|
|
59
|
+
readonly domain: string;
|
|
60
|
+
readonly recommendedSources: string[];
|
|
61
|
+
readonly recommendedMethods: string[];
|
|
62
|
+
readonly rationale: string;
|
|
63
|
+
supportingSignalCount: number;
|
|
64
|
+
confidence: number;
|
|
65
|
+
readonly createdAt: number;
|
|
66
|
+
updatedAt: number;
|
|
67
|
+
}
|
|
68
|
+
export interface InsightExtractionSignal {
|
|
69
|
+
readonly signal: FeedbackSignal;
|
|
70
|
+
readonly method?: string;
|
|
71
|
+
readonly source?: string;
|
|
72
|
+
}
|
|
73
|
+
export type InsightExtractor = (signals: readonly InsightExtractionSignal[], now: number) => RetrievalInsight[];
|
|
74
|
+
export interface MemoryWarning {
|
|
75
|
+
readonly code: string;
|
|
76
|
+
readonly message: string;
|
|
77
|
+
readonly timestamp: number;
|
|
78
|
+
}
|
|
79
|
+
export interface MemorySchemaV4 {
|
|
80
|
+
readonly version: 4;
|
|
81
|
+
curatedResults: CuratedResultRecord[];
|
|
82
|
+
evidenceChunks: EvidenceChunkRecord[];
|
|
83
|
+
feedbackSignals: FeedbackSignal[];
|
|
84
|
+
readonly signalDefaults: SignalDefaults;
|
|
85
|
+
warnings: MemoryWarning[];
|
|
86
|
+
insights: RetrievalInsight[];
|
|
87
|
+
pendingInsightSignals: InsightExtractionSignal[];
|
|
88
|
+
}
|
|
89
|
+
export interface MemoryEntry {
|
|
90
|
+
id: string;
|
|
91
|
+
query: string;
|
|
92
|
+
method: string;
|
|
93
|
+
outcome: FeedbackOutcome;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
metadata?: {
|
|
96
|
+
resultCount?: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export interface SearchAttempt {
|
|
100
|
+
id: string;
|
|
101
|
+
query: string;
|
|
102
|
+
method: string;
|
|
103
|
+
sources: string[];
|
|
104
|
+
timestamp: number;
|
|
105
|
+
}
|
|
106
|
+
export interface ResultFeedback {
|
|
107
|
+
source: string;
|
|
108
|
+
useful: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface SessionEvidenceRef extends NormalizedEvidenceRef {
|
|
111
|
+
readonly metadata?: Record<string, unknown>;
|
|
112
|
+
}
|
|
113
|
+
export interface SessionCuratedResultInput {
|
|
114
|
+
readonly number: number;
|
|
115
|
+
readonly title: string;
|
|
116
|
+
readonly summary: string;
|
|
117
|
+
readonly content: string;
|
|
118
|
+
readonly method: string;
|
|
119
|
+
readonly source: string;
|
|
120
|
+
readonly evidenceRefs: readonly SessionEvidenceRef[];
|
|
121
|
+
}
|
|
122
|
+
export interface SessionRecordInput {
|
|
123
|
+
readonly sessionId: string;
|
|
124
|
+
readonly query: string;
|
|
125
|
+
readonly results: readonly SessionCuratedResultInput[];
|
|
126
|
+
}
|
|
127
|
+
export interface NumberedFeedbackInput {
|
|
128
|
+
readonly sessionId: string;
|
|
129
|
+
readonly query: string;
|
|
130
|
+
readonly feedback: readonly {
|
|
131
|
+
readonly number: number;
|
|
132
|
+
readonly useful: boolean;
|
|
133
|
+
}[];
|
|
134
|
+
}
|
|
135
|
+
export interface RetrievalMemoryOptions {
|
|
136
|
+
storagePath: string;
|
|
137
|
+
insightExtractor?: InsightExtractor;
|
|
138
|
+
}
|
|
139
|
+
export declare class RetrievalMemory {
|
|
140
|
+
private readonly storagePath;
|
|
141
|
+
private readonly insightExtractor;
|
|
142
|
+
private data;
|
|
143
|
+
private persistedData;
|
|
144
|
+
private legacyEntries;
|
|
145
|
+
private legacySourceToAttemptId;
|
|
146
|
+
constructor(options: RetrievalMemoryOptions);
|
|
147
|
+
load(): void;
|
|
148
|
+
save(): void;
|
|
149
|
+
getSchema(): MemorySchemaV4;
|
|
150
|
+
getSignalCount(): number;
|
|
151
|
+
recordCuratedResultsSession(input: SessionRecordInput): void;
|
|
152
|
+
recordNumberedFeedback(input: NumberedFeedbackInput): boolean;
|
|
153
|
+
recordWeakSignal(query: string, method: string, source: "followup" | "retry"): void;
|
|
154
|
+
getMethodHints(query: string): MethodHint[];
|
|
155
|
+
getInsights(query: string): RetrievalInsight[];
|
|
156
|
+
getMethodPriority(query: string): Array<{
|
|
157
|
+
method: string;
|
|
158
|
+
score: number;
|
|
159
|
+
}>;
|
|
160
|
+
append(entry: Omit<MemoryEntry, "id" | "timestamp">): MemoryEntry;
|
|
161
|
+
getEntries(): readonly MemoryEntry[];
|
|
162
|
+
registerAttempt(attempt: SearchAttempt): void;
|
|
163
|
+
recordResultFeedback(feedback: ResultFeedback[]): void;
|
|
164
|
+
resolvePendingEntries(query: string, method: string | null, outcome: "useful" | "not_useful"): void;
|
|
165
|
+
recordFeedback(query: string, methodName: string, satisfied: boolean): void;
|
|
166
|
+
private readPersistedData;
|
|
167
|
+
private incompatibleMemory;
|
|
168
|
+
private acquireLock;
|
|
169
|
+
private mergeWithPersisted;
|
|
170
|
+
private capData;
|
|
171
|
+
private extractInsightsFromEvictedSignals;
|
|
172
|
+
private mergeInsights;
|
|
173
|
+
private upsertEvidence;
|
|
174
|
+
private methodForSignal;
|
|
175
|
+
private sourceForSignal;
|
|
176
|
+
}
|
|
177
|
+
export declare function normalizeSessionEvidenceRef(input: Omit<SessionEvidenceRef, "stableEvidenceId"> & {
|
|
178
|
+
readonly stableEvidenceId?: string;
|
|
179
|
+
}): SessionEvidenceRef;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MinSyncEmbedderConfig, MinSyncQueryHit, MinSyncSyncResult } from "./types.js";
|
|
2
|
+
export interface MinSyncClientOptions {
|
|
3
|
+
readonly binaryPath: string;
|
|
4
|
+
readonly workspacePath: string;
|
|
5
|
+
readonly embedder?: MinSyncEmbedderConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare class MinSyncClient {
|
|
8
|
+
private readonly binaryPath;
|
|
9
|
+
private readonly workspacePath;
|
|
10
|
+
private readonly embedder;
|
|
11
|
+
constructor(options: MinSyncClientOptions);
|
|
12
|
+
sync(): Promise<MinSyncSyncResult>;
|
|
13
|
+
query(text: string, topK: number): Promise<readonly MinSyncQueryHit[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MinSyncEmbedderConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* MinSync config.toml lives at `<workspace>/.minsync/config.toml`.
|
|
4
|
+
* After `minsync init` runs, we rewrite allowlisted embedder fields so
|
|
5
|
+
* the caller's configuration wins over init defaults.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MINSYNC_CONFIG_DIR = ".minsync";
|
|
8
|
+
export declare const MINSYNC_CONFIG_FILE = "config.toml";
|
|
9
|
+
export declare function minSyncConfigPath(workspacePath: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Atomically rewrite allowlisted embedder fields in MinSync config.toml.
|
|
12
|
+
* Reads the existing file, merges the allowlisted fields from `embedder`,
|
|
13
|
+
* and writes the result back. Only fields present on `embedder` are applied;
|
|
14
|
+
* absent fields are left untouched.
|
|
15
|
+
*
|
|
16
|
+
* Allowlisted [embedder] fields: id, base_url, query_prefix, passage_prefix,
|
|
17
|
+
* batch_size, max_retries, max_concurrent, timeout_seconds (from timeoutMs / 1000 ceil).
|
|
18
|
+
* Dimension is written under [vectorstore.options] as `dimension`.
|
|
19
|
+
*
|
|
20
|
+
* Returns true if the file was rewritten, false if the file does not exist.
|
|
21
|
+
*/
|
|
22
|
+
export declare function rewriteEmbedderConfig(workspacePath: string, embedder: MinSyncEmbedderConfig): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MinSyncClient, type MinSyncClientOptions } from "./client.js";
|
|
2
|
+
export { MINSYNC_CONFIG_DIR, MINSYNC_CONFIG_FILE, minSyncConfigPath, rewriteEmbedderConfig, } from "./embedder-config.js";
|
|
3
|
+
export { type EnsureMinSyncBinaryOptions, ensureMinSyncBinary, executableName, fetchLatestMinSyncRelease, type InstalledMinSyncBinary, type MinSyncRelease, type MinSyncReleaseAsset, MinSyncReleaseError, selectReleaseAsset, } from "./installer.js";
|
|
4
|
+
export { MinSyncVectorMethod, type MinSyncVectorMethodOptions } from "./method.js";
|
|
5
|
+
export { MINSYNC_FILES_SUBDIR, MINSYNC_SUBDIR, minSyncDocumentPath, minSyncWorkspaceRoot } from "./paths.js";
|
|
6
|
+
export type { MinSyncEmbedderConfig, MinSyncOptions, MinSyncQueryHit, MinSyncSyncResult } from "./types.js";
|
|
7
|
+
export { buildMinSyncPathMap, type MinSyncWorkspaceEntry, type MinSyncWorkspaceSyncResult, syncMinSyncWorkspace, } from "./workspace.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface MinSyncReleaseAsset {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly downloadUrl: string;
|
|
4
|
+
readonly sha256?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface MinSyncRelease {
|
|
7
|
+
readonly tagName: string;
|
|
8
|
+
readonly assets: readonly MinSyncReleaseAsset[];
|
|
9
|
+
}
|
|
10
|
+
export interface InstalledMinSyncBinary {
|
|
11
|
+
readonly binaryPath: string;
|
|
12
|
+
readonly version: string;
|
|
13
|
+
}
|
|
14
|
+
export interface EnsureMinSyncBinaryOptions {
|
|
15
|
+
readonly root: string;
|
|
16
|
+
readonly platform?: NodeJS.Platform;
|
|
17
|
+
readonly arch?: NodeJS.Architecture;
|
|
18
|
+
readonly releaseProvider?: () => Promise<MinSyncRelease>;
|
|
19
|
+
readonly assetInstaller?: (asset: MinSyncReleaseAsset, destination: string) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function ensureMinSyncBinary(options: EnsureMinSyncBinaryOptions): Promise<InstalledMinSyncBinary>;
|
|
22
|
+
export declare function fetchLatestMinSyncRelease(): Promise<MinSyncRelease>;
|
|
23
|
+
export declare function selectReleaseAsset(release: MinSyncRelease, platform: NodeJS.Platform, arch: NodeJS.Architecture): MinSyncReleaseAsset;
|
|
24
|
+
export declare function executableName(platform: NodeJS.Platform): string;
|
|
25
|
+
export declare class MinSyncReleaseError extends Error {
|
|
26
|
+
readonly name = "MinSyncReleaseError";
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../retrieval/types.js";
|
|
2
|
+
import { type EnsureMinSyncBinaryOptions } from "./installer.js";
|
|
3
|
+
import type { MinSyncEmbedderConfig, MinSyncSyncResult } from "./types.js";
|
|
4
|
+
export interface MinSyncVectorMethodOptions {
|
|
5
|
+
readonly root: string;
|
|
6
|
+
readonly binaryPath?: string;
|
|
7
|
+
readonly workspacePath?: string;
|
|
8
|
+
readonly installer?: Omit<EnsureMinSyncBinaryOptions, "root">;
|
|
9
|
+
readonly autoInstall?: boolean;
|
|
10
|
+
readonly embedder?: MinSyncEmbedderConfig;
|
|
11
|
+
}
|
|
12
|
+
export declare class MinSyncVectorMethod implements RetrievalMethod {
|
|
13
|
+
private readonly root;
|
|
14
|
+
private readonly binaryPath;
|
|
15
|
+
private readonly workspacePath;
|
|
16
|
+
private readonly installer;
|
|
17
|
+
private readonly autoInstall;
|
|
18
|
+
private readonly embedder;
|
|
19
|
+
constructor(options: MinSyncVectorMethodOptions);
|
|
20
|
+
describe(): RetrievalMethodDescriptor;
|
|
21
|
+
sync(): Promise<MinSyncSyncResult>;
|
|
22
|
+
/** True when a configured binary path is missing (an explicit degraded state). */
|
|
23
|
+
isBinaryMissing(): boolean;
|
|
24
|
+
retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the minsync binary path following the priority chain:
|
|
27
|
+
* 1. explicit binaryPath if set and exists
|
|
28
|
+
* 2. PATH lookup for `minsync`
|
|
29
|
+
* 3. cached join(root, '.autorag', 'bin', execName) if exists
|
|
30
|
+
* 4. if autoInstall===true, try ensureMinSyncBinary in try/catch => install-failed degrade
|
|
31
|
+
* 5. else return undefined (missing-binary degrade)
|
|
32
|
+
*
|
|
33
|
+
* Returns: string path on success, undefined for missing-binary, or a MinSyncSyncResult
|
|
34
|
+
* for install-failed.
|
|
35
|
+
*/
|
|
36
|
+
private resolveBinary;
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ProcessResult {
|
|
2
|
+
readonly ok: boolean;
|
|
3
|
+
readonly stdout: string;
|
|
4
|
+
readonly stderr: string;
|
|
5
|
+
readonly code: number | null;
|
|
6
|
+
readonly timedOut?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function spawnProcess(command: string, args: readonly string[], cwd: string, options?: {
|
|
9
|
+
readonly timeoutMs?: number;
|
|
10
|
+
}): Promise<ProcessResult>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Embedder configuration for MinSync vector indexing. Shared by config and method layers. */
|
|
2
|
+
export interface MinSyncEmbedderConfig {
|
|
3
|
+
readonly id?: string;
|
|
4
|
+
readonly baseUrl?: string;
|
|
5
|
+
/** Environment variable name whose value holds the embedder API key. /^[A-Za-z_][A-Za-z0-9_]*$/ */
|
|
6
|
+
readonly apiKeyEnv?: string;
|
|
7
|
+
/** Positive integer embedding dimension. */
|
|
8
|
+
readonly dimension?: number;
|
|
9
|
+
readonly queryPrefix?: string;
|
|
10
|
+
readonly passagePrefix?: string;
|
|
11
|
+
readonly timeoutMs?: number;
|
|
12
|
+
readonly batchSize?: number;
|
|
13
|
+
readonly maxRetries?: number;
|
|
14
|
+
readonly maxConcurrent?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface MinSyncOptions {
|
|
17
|
+
readonly root: string;
|
|
18
|
+
readonly binaryPath?: string;
|
|
19
|
+
readonly workspacePath?: string;
|
|
20
|
+
readonly autoInstall?: boolean;
|
|
21
|
+
readonly embedder?: MinSyncEmbedderConfig;
|
|
22
|
+
}
|
|
23
|
+
export interface MinSyncSyncResult {
|
|
24
|
+
readonly ok: boolean;
|
|
25
|
+
readonly synced: number;
|
|
26
|
+
readonly workspacePath: string;
|
|
27
|
+
readonly reason?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MinSyncQueryHit {
|
|
30
|
+
readonly path: string;
|
|
31
|
+
readonly score: number;
|
|
32
|
+
readonly text: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface MinSyncWorkspaceEntry {
|
|
2
|
+
readonly virtualPath: string;
|
|
3
|
+
readonly sourcePath: string;
|
|
4
|
+
readonly parsedOutputPath: string;
|
|
5
|
+
readonly minSyncPath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MinSyncWorkspaceSyncResult {
|
|
8
|
+
readonly workspacePath: string;
|
|
9
|
+
readonly entries: readonly MinSyncWorkspaceEntry[];
|
|
10
|
+
}
|
|
11
|
+
export declare function syncMinSyncWorkspace(root: string, options?: {
|
|
12
|
+
readonly workspacePath?: string;
|
|
13
|
+
}): MinSyncWorkspaceSyncResult;
|
|
14
|
+
export declare function buildMinSyncPathMap(root: string, workspacePath: string): ReadonlyMap<string, MinSyncWorkspaceEntry>;
|