@autorag/librarian 2.10.4 → 2.10.6
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 +9 -9
- package/README.md +32 -17
- package/dist/agent/agent.d.ts +63 -51
- package/dist/agent/context-token-guard.d.ts +11 -0
- package/dist/agent/discord-remote.d.ts +30 -0
- package/dist/agent/embedding-controls.d.ts +22 -0
- package/dist/agent/index.d.ts +1 -2
- package/dist/agent/pi-session.d.ts +21 -1
- package/dist/agent/query-decomposition.d.ts +1 -1
- package/dist/agent/search-documents.d.ts +2 -2
- package/dist/agent/system-prompt.d.ts +1 -1
- package/dist/agent/web-search-tool.d.ts +2 -2
- package/dist/cli/commands/models.d.ts +0 -14
- package/dist/cli/commands/search.d.ts +3 -4
- package/dist/cli/config.d.ts +7 -19
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +6056 -9408
- package/dist/cli/setup.d.ts +13 -36
- package/dist/cli/whatsapp-extension.d.ts +21 -0
- package/dist/cloud/config.d.ts +3 -3
- package/dist/core.js +7126 -9804
- package/dist/datasource/embedding-env.d.ts +29 -0
- package/dist/datasource/sidecar/config.d.ts +3 -0
- package/dist/datasource/sidecar/index.d.ts +1 -1
- package/dist/datasource/skills/discrawl/client.d.ts +1 -0
- package/dist/datasource/skills/discrawl/embedding.d.ts +17 -0
- package/dist/datasource/skills/discrawl/types.d.ts +11 -3
- package/dist/datasource/skills/factory.d.ts +14 -1
- package/dist/datasource/skills/github-gist/semantic.d.ts +5 -5
- package/dist/datasource/skills/github-gist/skill.d.ts +2 -3
- package/dist/datasource/skills/lazykatok/types.d.ts +9 -1
- package/dist/datasource/skills/mailcrawl/types.d.ts +9 -1
- package/dist/embedding/daemon.d.ts +57 -0
- package/dist/embedding/embedder.d.ts +59 -0
- package/dist/embedding/http-embedder.d.ts +28 -0
- package/dist/embedding/in-process.d.ts +19 -0
- package/dist/embedding/index.d.ts +28 -0
- package/dist/embedding/managed.d.ts +44 -0
- package/dist/embedding/prefixes.d.ts +18 -0
- package/dist/embedding/settings.d.ts +9 -0
- package/dist/index.js +7149 -9829
- package/dist/mcp/index.js +7146 -9824
- package/dist/memory/context.d.ts +1 -1
- package/dist/memory/similar-queries.d.ts +1 -1
- package/dist/minsync/binary.d.ts +21 -0
- package/dist/minsync/client.d.ts +19 -10
- package/dist/minsync/embedder-config.d.ts +11 -1
- package/dist/minsync/index.d.ts +1 -1
- package/dist/minsync/installer.d.ts +1 -1
- package/dist/minsync/kiwi.d.ts +17 -0
- package/dist/minsync/lexical-language.d.ts +18 -0
- package/dist/minsync/method.d.ts +3 -11
- package/dist/minsync/process.d.ts +1 -0
- package/dist/minsync/types.d.ts +9 -2
- package/dist/retrieval/rerank.d.ts +10 -3
- package/dist/web/search/types.d.ts +22 -18
- package/package.json +4 -3
- package/skills/autorag/SKILL.md +3 -8
- package/skills/autorag-doctor/SKILL.md +47 -26
- package/skills/autorag-lite-setup/SKILL.md +8 -8
- package/skills/autorag-setup/SKILL.md +39 -23
- package/dist/agent/peer-target-tool.d.ts +0 -19
- package/dist/agent/query-peer-tool.d.ts +0 -51
- package/dist/cli/commands/gateway.d.ts +0 -7
- package/dist/cli/commands/p2p-policy.d.ts +0 -2
- package/dist/cli/commands/p2p.d.ts +0 -7
- package/dist/cli/commands/serve.d.ts +0 -19
- package/dist/embedding-runtime/cache.d.ts +0 -30
- package/dist/embedding-runtime/gateway-embedder.d.ts +0 -41
- package/dist/embedding-runtime/gateway.d.ts +0 -27
- package/dist/embedding-runtime/index.d.ts +0 -120
- package/dist/embedding-runtime/manifest.d.ts +0 -20
- package/dist/embedding-runtime/supervisor.d.ts +0 -74
- package/dist/embedding-runtime/types.d.ts +0 -70
- package/dist/p2p/approval-store.d.ts +0 -32
- package/dist/p2p/egress-gate.d.ts +0 -22
- package/dist/p2p/file-sharing.d.ts +0 -33
- package/dist/p2p/injection-classifier.d.ts +0 -33
- package/dist/p2p/injection-gate.d.ts +0 -37
- package/dist/p2p/pii-gate.d.ts +0 -47
- package/dist/p2p/policy-filter.d.ts +0 -15
- package/dist/p2p/policy.d.ts +0 -77
- package/dist/p2p/simplex-query-store.d.ts +0 -44
- package/dist/p2p/simplex-server.d.ts +0 -115
- package/dist/p2p/simplex-transport.d.ts +0 -62
- package/dist/p2p/wire.d.ts +0 -39
- package/licenses/embedding-assets.json +0 -85
- package/licenses/llama.cpp-MIT.txt +0 -21
- package/licenses/qwen3-embedding-notice.txt +0 -13
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { EmbedderEndpoint, ManagedEmbedder } from "../embedding/embedder.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pointing an external CLI that embeds for itself (mailcrawl, lazykatok) at the same backend as the rest of
|
|
4
|
+
* AutoRAG. The CLI keeps ownership of its archive and vector store; AutoRAG only tells it where the vectors
|
|
5
|
+
* come from, through the environment variables the CLI documents. A remote key travels as the value of the
|
|
6
|
+
* variable the operator's `minSync.embedder.apiKeyEnv` names, to that one child only.
|
|
7
|
+
*/
|
|
8
|
+
/** An endpoint whose vector length is known; the CLIs require it up front. */
|
|
9
|
+
export interface ResolvedEmbeddingEndpoint extends EmbedderEndpoint {
|
|
10
|
+
readonly dimension: number;
|
|
11
|
+
}
|
|
12
|
+
export type EmbeddingEndpointSource = () => Promise<ResolvedEmbeddingEndpoint | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* The shared embedder as an endpoint source. Probes only: it never starts a daemon. `undefined` means the
|
|
15
|
+
* embedder would run in-process, which an external CLI cannot reach.
|
|
16
|
+
*/
|
|
17
|
+
export declare function embeddingEndpointSource(embedder: ManagedEmbedder): EmbeddingEndpointSource;
|
|
18
|
+
/**
|
|
19
|
+
* mailcrawl's `openai` and `tei` providers (0.2.2+). Identity is provider + model + dimension, so moving a
|
|
20
|
+
* server keeps its vectors, while switching backend rebuilds the index on the next `mailcrawl index`.
|
|
21
|
+
* mailcrawl accepts a non-loopback endpoint only over https with an explicit opt-in, which is set here
|
|
22
|
+
* because the operator configured that remote themselves.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mailcrawlEmbeddingEnv(endpoint: ResolvedEmbeddingEndpoint, parentEnv?: NodeJS.ProcessEnv): Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* lazykatok's OpenAI-compatible embedder (0.3.3+). It speaks `POST /v1/embeddings` only, so a TEI endpoint
|
|
27
|
+
* cannot be offered and lazykatok keeps its own embedder, as discrawl does.
|
|
28
|
+
*/
|
|
29
|
+
export declare function lazykatokEmbeddingEnv(endpoint: ResolvedEmbeddingEndpoint, parentEnv?: NodeJS.ProcessEnv): Record<string, string> | undefined;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* The sidecar's own database always lives under the AutoRAG workspace, one file
|
|
13
13
|
* per datasource instance, never next to (or inside) the crawler's archive.
|
|
14
14
|
*/
|
|
15
|
+
import type { Embedder } from "../../embedding/embedder.js";
|
|
15
16
|
import type { CrawlerDescriptor } from "./descriptors.js";
|
|
16
17
|
import type { CrawlerSidecarOptions } from "./index.js";
|
|
17
18
|
export interface ResolveSidecarInput {
|
|
@@ -22,5 +23,7 @@ export interface ResolveSidecarInput {
|
|
|
22
23
|
readonly instanceId: string;
|
|
23
24
|
/** Where the crawler keeps its archive when the user did not say. */
|
|
24
25
|
readonly defaultCrawlerDb: string;
|
|
26
|
+
/** The embedder shared with the rest of AutoRAG. Without one the sidecar is lexical-only. */
|
|
27
|
+
readonly embedder?: Embedder;
|
|
25
28
|
}
|
|
26
29
|
export declare function resolveSidecarOptions(input: ResolveSidecarInput): CrawlerSidecarOptions | undefined;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Everything crawler-specific lives in a {@link CrawlerDescriptor}; this file
|
|
12
12
|
* is shared by every crawler.
|
|
13
13
|
*/
|
|
14
|
-
import type { Embedder } from "../../embedding
|
|
14
|
+
import type { Embedder } from "../../embedding/embedder.js";
|
|
15
15
|
import type { CrawlerDescriptor } from "./descriptors.js";
|
|
16
16
|
export interface SidecarHit {
|
|
17
17
|
readonly key: string;
|
|
@@ -13,6 +13,7 @@ export declare class DiscrawlClient {
|
|
|
13
13
|
private readonly options;
|
|
14
14
|
constructor(options?: DiscrawlOptions);
|
|
15
15
|
configureEmbeddings(runtime: DiscrawlEmbeddingRuntime): Promise<DiscrawlEmbeddingConfigResult>;
|
|
16
|
+
private resolveRuntime;
|
|
16
17
|
prepareEmbeddings(): Promise<boolean>;
|
|
17
18
|
metadata(signal?: AbortSignal): Promise<DiscrawlMetadataResult>;
|
|
18
19
|
doctor(signal?: AbortSignal): Promise<DiscrawlDoctorResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EmbedderEndpoint } from "../../../embedding/embedder.js";
|
|
2
|
+
import type { DiscrawlEmbeddingRuntime } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* discrawl keeps `openai_compatible` embeddings off ("requires API key env ...") unless the variable its
|
|
5
|
+
* config names is non-empty, while `minsync serve` has no authentication and ignores the value. For the
|
|
6
|
+
* local daemon AutoRAG therefore names a variable of its own and supplies this fixed, non-secret placeholder
|
|
7
|
+
* to the discrawl child only. It is never a credential and never read from the operator's environment.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LOCAL_EMBEDDING_KEY_ENV = "AUTORAG_LOCAL_EMBEDDING_KEY";
|
|
10
|
+
export declare const LOCAL_EMBEDDING_KEY_PLACEHOLDER = "local";
|
|
11
|
+
/**
|
|
12
|
+
* What discrawl's own `[search.embeddings]` section should say so that it embeds through the same backend
|
|
13
|
+
* as the rest of AutoRAG. discrawl speaks OpenAI `POST {base_url}/embeddings` only (its provider name is
|
|
14
|
+
* `openai_compatible`, with an underscore), so a TEI endpoint cannot be offered and discrawl keeps its own
|
|
15
|
+
* configuration. A remote key travels as the name of an environment variable, never as a value.
|
|
16
|
+
*/
|
|
17
|
+
export declare function discrawlEmbeddingRuntimeFor(endpoint: EmbedderEndpoint | undefined): DiscrawlEmbeddingRuntime | undefined;
|
|
@@ -43,7 +43,12 @@ export interface DiscrawlEmbeddingRuntime {
|
|
|
43
43
|
readonly provider: string;
|
|
44
44
|
readonly model: string;
|
|
45
45
|
readonly baseUrl: string;
|
|
46
|
-
|
|
46
|
+
/** Omitted when the endpoint's dimension is not known; discrawl infers it from the first response. */
|
|
47
|
+
readonly dimensions?: number;
|
|
48
|
+
/** Name of the environment variable that holds the bearer token (remote endpoints). Never the token. */
|
|
49
|
+
readonly apiKeyEnv?: string;
|
|
50
|
+
/** A non-secret placeholder for a keyless local daemon, passed to the child only. Never set for a remote endpoint. */
|
|
51
|
+
readonly apiKeyValue?: string;
|
|
47
52
|
readonly identity?: string;
|
|
48
53
|
}
|
|
49
54
|
export interface DiscrawlEmbeddingConfigResult {
|
|
@@ -78,8 +83,11 @@ export interface DiscrawlOptions {
|
|
|
78
83
|
readonly guildId?: string;
|
|
79
84
|
/** Embedding provider understood by the native discrawl configuration. */
|
|
80
85
|
readonly embeddingProvider?: string;
|
|
81
|
-
/**
|
|
82
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Where discrawl should embed, written into a managed workspace config. A function is evaluated on each
|
|
88
|
+
* `prepareEmbeddings`, because the endpoint of a `minsync serve` daemon exists only while it runs.
|
|
89
|
+
*/
|
|
90
|
+
readonly embeddingRuntime?: DiscrawlEmbeddingRuntime | (() => Promise<DiscrawlEmbeddingRuntime | undefined>);
|
|
83
91
|
/**
|
|
84
92
|
* Embedding model understood by the native discrawl configuration.
|
|
85
93
|
* English-only models are accepted but reported through a diagnostic.
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* configuration path. Unknown skill names and disabled entries are skipped
|
|
8
8
|
* and reported so setup surfaces actionable (but path-opaque) feedback.
|
|
9
9
|
*/
|
|
10
|
+
import type { Embedder } from "../../embedding/embedder.js";
|
|
11
|
+
import type { EmbeddingEndpointSource } from "../embedding-env.js";
|
|
10
12
|
import type { DatasourceSkill } from "../types.js";
|
|
11
13
|
import { type DiscrawlEmbeddingRuntime } from "./discrawl/index.js";
|
|
12
14
|
/** One configured datasource entry (the trusted `datasources.<name>` value). */
|
|
@@ -34,6 +36,17 @@ export interface BuildDatasourceSkillsResult {
|
|
|
34
36
|
/** Names that were configured but not recognized. */
|
|
35
37
|
readonly unknown: readonly string[];
|
|
36
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* What the shared embedding backend gives a datasource. AutoRAG-owned semantic stores (chat sidecars, the
|
|
41
|
+
* gist vector index) call the `embedder`; an external CLI that embeds for itself (discrawl) is pointed at the
|
|
42
|
+
* same backend through `discrawl`.
|
|
43
|
+
*/
|
|
44
|
+
export interface DatasourceEmbeddingOptions {
|
|
45
|
+
readonly embedder?: Embedder;
|
|
46
|
+
readonly discrawl?: DiscrawlEmbeddingRuntime | (() => Promise<DiscrawlEmbeddingRuntime | undefined>);
|
|
47
|
+
/** For CLIs that embed for themselves through env (mailcrawl, lazykatok): where the shared backend is. */
|
|
48
|
+
readonly cliEndpoint?: EmbeddingEndpointSource;
|
|
49
|
+
}
|
|
37
50
|
/** Skill names this factory can build. */
|
|
38
51
|
export declare const BUILTIN_DATASOURCE_SKILL_NAMES: readonly string[];
|
|
39
52
|
/**
|
|
@@ -42,4 +55,4 @@ export declare const BUILTIN_DATASOURCE_SKILL_NAMES: readonly string[];
|
|
|
42
55
|
* collected in `unknown` (never thrown) so callers can surface setup
|
|
43
56
|
* feedback without failing agent construction.
|
|
44
57
|
*/
|
|
45
|
-
export declare function buildDatasourceSkills(config: DatasourcesConfig | undefined, workspaceRoot?: string,
|
|
58
|
+
export declare function buildDatasourceSkills(config: DatasourcesConfig | undefined, workspaceRoot?: string, embedding?: DatasourceEmbeddingOptions): BuildDatasourceSkillsResult;
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* A small persisted vector sidecar (`vectors.json`) mirrors the chunk store:
|
|
5
5
|
* entries are keyed by chunk id with a content hash so unchanged chunks are
|
|
6
6
|
* never re-embedded, removed chunks are pruned, and an embedding-identity
|
|
7
|
-
* change (provider/model/dimension) forces a full re-embed. The
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* change (provider/model/dimension) forces a full re-embed. The embedder is
|
|
8
|
+
* the one AutoRAG shares with every consumer (MinSync's daemon or in-process
|
|
9
|
+
* engine, or the configured remote endpoint). Every failure degrades —
|
|
10
|
+
* indexing stays lexical-only and retrieval returns [].
|
|
11
11
|
*/
|
|
12
|
-
import type { Embedder } from "../../../embedding
|
|
12
|
+
import type { Embedder } from "../../../embedding/embedder.js";
|
|
13
13
|
import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../../../retrieval/types.js";
|
|
14
14
|
import type { DatasourceChunkStore, StoredChunk } from "../../chunk-store.js";
|
|
15
15
|
export interface GistSemanticSyncOk {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* through the loopback embedding gateway. Embedding failures degrade to a
|
|
8
8
|
* `semantic-unavailable` warning — indexing and lexical retrieval continue.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import type { Embedder } from "../../../embedding/embedder.js";
|
|
11
11
|
import type { RetrievalMethod } from "../../../retrieval/types.js";
|
|
12
12
|
import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
|
|
13
13
|
import type { DatasourceIndexOptions, DatasourceIndexResult } from "../../types.js";
|
|
@@ -17,9 +17,8 @@ export declare function gistDatasourceDir(workspaceRoot: string, skillName: stri
|
|
|
17
17
|
export interface GitHubGistSemanticOptions {
|
|
18
18
|
/** Set false to run lexical-only. Default true. */
|
|
19
19
|
readonly enabled?: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** The embedder shared with the rest of AutoRAG. Without one the gist index is lexical-only. */
|
|
21
21
|
readonly embedder?: Embedder;
|
|
22
|
-
readonly embedderOptions?: GatewayEmbedderOptions;
|
|
23
22
|
/** Vector sidecar path override; defaults under `.autorag/datasources/…`. */
|
|
24
23
|
readonly statePath?: string;
|
|
25
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RetrievalOptions } from "../../../retrieval/types.js";
|
|
2
|
+
import type { EmbeddingEndpointSource } from "../../embedding-env.js";
|
|
2
3
|
/**
|
|
3
4
|
* Search modes accepted by the external `lazykatok search` subcommand.
|
|
4
5
|
*
|
|
@@ -43,6 +44,13 @@ export interface LazykatokOptions {
|
|
|
43
44
|
readonly source?: string;
|
|
44
45
|
/** Environment overrides merged on top of `process.env` for the child. */
|
|
45
46
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
47
|
+
/**
|
|
48
|
+
* Where lazykatok gets its vectors. When set, `index` and the semantic and hybrid searches run lazykatok's
|
|
49
|
+
* OpenAI-compatible embedder against the endpoint it returns (a `minsync serve` daemon or the operator's
|
|
50
|
+
* remote), and lazykatok's own fastembed model is never used; with no endpoint, or a TEI one, those commands
|
|
51
|
+
* fail instead. Without it lazykatok keeps whatever embedder its own environment selects.
|
|
52
|
+
*/
|
|
53
|
+
readonly embeddingEndpoint?: EmbeddingEndpointSource;
|
|
46
54
|
}
|
|
47
55
|
export declare const DEFAULT_LAZYKATOK_BINARY = "lazykatok";
|
|
48
56
|
export declare const DEFAULT_LAZYKATOK_TIMEOUT_MS = 60000;
|
|
@@ -65,7 +73,7 @@ export declare const DEFAULT_LAZYKATOK_OPTIONS: {
|
|
|
65
73
|
* every method returns a discriminated union with `ok: false` and one of these
|
|
66
74
|
* reasons.
|
|
67
75
|
*/
|
|
68
|
-
export type LazykatokFailureReason = "binary-missing" | "nonzero-exit" | "spawn-error" | "timeout" | "aborted" | "stdout-too-large" | "stderr-too-large" | "invalid-json" | "invalid-shape";
|
|
76
|
+
export type LazykatokFailureReason = "binary-missing" | "nonzero-exit" | "spawn-error" | "timeout" | "aborted" | "stdout-too-large" | "stderr-too-large" | "invalid-json" | "invalid-shape" | "embedding-unavailable";
|
|
69
77
|
/** Common failure payload shared by every method result union. */
|
|
70
78
|
export interface LazykatokFailure {
|
|
71
79
|
readonly ok: false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EmbeddingEndpointSource } from "../../embedding-env.js";
|
|
1
2
|
export type MailcrawlSearchMode = "keyword" | "bm25" | "semantic" | "hybrid";
|
|
2
3
|
export interface MailcrawlSearchOptions {
|
|
3
4
|
readonly topK?: number;
|
|
@@ -22,8 +23,15 @@ export interface MailcrawlOptions {
|
|
|
22
23
|
readonly indexTimeoutMs?: number;
|
|
23
24
|
readonly maxBufferBytes?: number;
|
|
24
25
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
26
|
+
/**
|
|
27
|
+
* Where mailcrawl gets its vectors. When set, `index` and the semantic and hybrid searches run mailcrawl's
|
|
28
|
+
* `openai`/`tei` provider against the endpoint it returns (a `minsync serve` daemon or the operator's remote),
|
|
29
|
+
* and mailcrawl's own native model is never used; with no endpoint those commands fail instead. Without it
|
|
30
|
+
* mailcrawl keeps whatever embedder its own environment selects.
|
|
31
|
+
*/
|
|
32
|
+
readonly embeddingEndpoint?: EmbeddingEndpointSource;
|
|
25
33
|
}
|
|
26
|
-
export type MailcrawlFailureReason = "binary-missing" | "not-configured" | "nonzero-exit" | "spawn-error" | "timeout" | "aborted" | "stdout-too-large" | "stderr-too-large" | "invalid-output" | "remote-embedding-rejected";
|
|
34
|
+
export type MailcrawlFailureReason = "binary-missing" | "not-configured" | "nonzero-exit" | "spawn-error" | "timeout" | "aborted" | "stdout-too-large" | "stderr-too-large" | "invalid-output" | "remote-embedding-rejected" | "embedding-unavailable";
|
|
27
35
|
export interface MailcrawlFailure {
|
|
28
36
|
readonly ok: false;
|
|
29
37
|
readonly reason: MailcrawlFailureReason;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The model `minsync serve` serves by default; callers pass another to look for that one. */
|
|
2
|
+
export declare const DEFAULT_DAEMON_MODEL = "Qwen/Qwen3-Embedding-0.6B";
|
|
3
|
+
export interface MinSyncDaemon {
|
|
4
|
+
/** `http://127.0.0.1:<port>`; the OpenAI route lives under `/v1`, TEI at `/embed`. */
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
readonly model: string;
|
|
7
|
+
readonly dimension: number;
|
|
8
|
+
readonly instance: string;
|
|
9
|
+
/** True when {@link ensureMinSyncDaemon} spawned it. */
|
|
10
|
+
readonly started: boolean;
|
|
11
|
+
readonly pid?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class MinSyncDaemonError extends Error {
|
|
14
|
+
constructor(message: string, options?: ErrorOptions);
|
|
15
|
+
}
|
|
16
|
+
export interface ProbeOptions {
|
|
17
|
+
/** User home; MinSync keeps its server state under `<home>/.cache/minsync/serve`. */
|
|
18
|
+
readonly home?: string;
|
|
19
|
+
/** Only accept a server of this model. Defaults to {@link DEFAULT_DAEMON_MODEL}. */
|
|
20
|
+
readonly model?: string;
|
|
21
|
+
readonly fetchImpl?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* MinSync publishes `host`/`port` (and `pid`) per model instance under
|
|
25
|
+
* `~/.cache/minsync/serve/<instance>/` and removes them on a clean stop. A leftover file from a crashed
|
|
26
|
+
* server is harmless because every candidate must answer `GET /health` as a loopback `status: ok` server of
|
|
27
|
+
* the wanted model before it is used.
|
|
28
|
+
*/
|
|
29
|
+
export declare function minSyncServeStateRoot(home?: string): string;
|
|
30
|
+
export declare function probeMinSyncDaemon(options?: ProbeOptions): Promise<MinSyncDaemon | undefined>;
|
|
31
|
+
export interface EnsureDaemonOptions extends ProbeOptions {
|
|
32
|
+
/** The `minsync` executable. Required only when no daemon is running yet. */
|
|
33
|
+
readonly binaryPath: string;
|
|
34
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
35
|
+
/** Working directory of the spawned server. `minsync serve` reads `.minsync/config.toml` from it. */
|
|
36
|
+
readonly cwd?: string;
|
|
37
|
+
/** How long to wait for the server to publish and answer; the first start may download the model. */
|
|
38
|
+
readonly readyTimeoutMs?: number;
|
|
39
|
+
/** Idle seconds before the daemon exits and frees the model (`minsync serve --idle-timeout`). */
|
|
40
|
+
readonly idleTimeoutSeconds?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The running `minsync serve` daemon, starting one detached when none answers. The daemon is MinSync's:
|
|
44
|
+
* it owns the model weights, the cache, and its own idle shutdown. Concurrent starters are safe because
|
|
45
|
+
* `minsync serve` adopts an already-running server of the same model instead of loading a second copy.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ensureMinSyncDaemon(options: EnsureDaemonOptions): Promise<MinSyncDaemon>;
|
|
48
|
+
export interface StopDaemonOptions extends ProbeOptions {
|
|
49
|
+
/** How long to wait for the server to remove its discovery files and stop answering. */
|
|
50
|
+
readonly timeoutMs?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stops the running `minsync serve` daemon with SIGTERM, which `minsync serve` handles by removing its
|
|
54
|
+
* discovery files and exiting. The pid comes from the server's own `GET /health` answer, so only a live
|
|
55
|
+
* loopback server of the wanted model is ever signalled. Returns the stopped daemon, or undefined when none ran.
|
|
56
|
+
*/
|
|
57
|
+
export declare function stopMinSyncDaemon(options?: StopDaemonOptions): Promise<MinSyncDaemon | undefined>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract every semantic consumer in AutoRAG codes against. AutoRAG does not run an embedding model:
|
|
3
|
+
* vectors come from MinSync (the `minsync serve` daemon, or MinSync's in-process engine) or from a
|
|
4
|
+
* remote endpoint the operator configured.
|
|
5
|
+
*/
|
|
6
|
+
export interface EmbeddingIdentity {
|
|
7
|
+
readonly provider: string;
|
|
8
|
+
readonly model: string;
|
|
9
|
+
readonly dimension: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* What a text is for. Instruction-aware models embed a search query differently from the document it should
|
|
13
|
+
* match, so a caller says which side it is on. `"document"` is the default.
|
|
14
|
+
*/
|
|
15
|
+
export type EmbedRole = "query" | "document";
|
|
16
|
+
export interface EmbedOptions {
|
|
17
|
+
readonly role?: EmbedRole;
|
|
18
|
+
}
|
|
19
|
+
export interface Embedder {
|
|
20
|
+
identity(): Promise<EmbeddingIdentity>;
|
|
21
|
+
embed(texts: readonly string[], options?: EmbedOptions): Promise<readonly (readonly number[])[]>;
|
|
22
|
+
}
|
|
23
|
+
/** Where a {@link ManagedEmbedder} is sending text right now. `none` means nothing can embed. */
|
|
24
|
+
export type EmbeddingBackend = "daemon" | "in-process" | "remote" | "none";
|
|
25
|
+
/** Whether the embedding backend answers right now. Probed on every call; nothing is cached. */
|
|
26
|
+
export interface EmbedderHealth {
|
|
27
|
+
readonly backend: EmbeddingBackend;
|
|
28
|
+
readonly alive: boolean;
|
|
29
|
+
/** The answering server's address when alive, or why it is not. */
|
|
30
|
+
readonly detail?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Where a {@link ManagedEmbedder} currently sends text, for external CLIs that need a URL. */
|
|
33
|
+
export interface EmbedderEndpoint {
|
|
34
|
+
/** Server root; the OpenAI route is under `/v1`, TEI at `/embed`. */
|
|
35
|
+
readonly baseUrl: string;
|
|
36
|
+
readonly protocol: "openai" | "tei";
|
|
37
|
+
readonly model: string;
|
|
38
|
+
readonly dimension: number | undefined;
|
|
39
|
+
/** Name of the environment variable that holds the bearer token; remote endpoints only. */
|
|
40
|
+
readonly apiKeyEnv?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Prefixes this endpoint's consumers must apply themselves: the server embeds text as sent. Set only when
|
|
43
|
+
* the embedder was given prefixes.
|
|
44
|
+
*/
|
|
45
|
+
readonly queryPrefix?: string;
|
|
46
|
+
readonly passagePrefix?: string;
|
|
47
|
+
readonly backend: "daemon" | "remote";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* An {@link Embedder} that reports where it embeds. AutoRAG never starts or stops a server: the operator
|
|
51
|
+
* runs `minsync serve` or configures a remote endpoint, and `health` / `describeEndpoint` only look.
|
|
52
|
+
*/
|
|
53
|
+
export interface ManagedEmbedder extends Embedder {
|
|
54
|
+
/** Probes the backend now: the daemon's or the remote's `GET /health`. Never starts anything. */
|
|
55
|
+
health(): Promise<EmbedderHealth>;
|
|
56
|
+
/** The HTTP endpoint behind this embedder right now, or undefined while it would embed in-process. */
|
|
57
|
+
describeEndpoint(): Promise<EmbedderEndpoint | undefined>;
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Embedder } from "./embedder.js";
|
|
2
|
+
export type EmbeddingProtocol = "openai" | "tei";
|
|
3
|
+
export interface HttpEmbedderOptions {
|
|
4
|
+
readonly protocol: EmbeddingProtocol;
|
|
5
|
+
/** Server root, with or without a trailing `/v1` (openai) and trailing slashes. */
|
|
6
|
+
readonly baseUrl: string;
|
|
7
|
+
readonly model: string;
|
|
8
|
+
/** Expected vector length. Learned from the first response when omitted. */
|
|
9
|
+
readonly dimension?: number;
|
|
10
|
+
/** Reported as `identity().provider`; stores keyed on identity re-embed when it changes. */
|
|
11
|
+
readonly provider: string;
|
|
12
|
+
/** Name of the environment variable holding the bearer token. Read on every call, never stored. */
|
|
13
|
+
readonly apiKeyEnv?: string;
|
|
14
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
15
|
+
/** Inputs per request. */
|
|
16
|
+
readonly batchSize?: number;
|
|
17
|
+
/** TEI only: ask the server to truncate inputs over its context instead of answering 413. */
|
|
18
|
+
readonly truncate?: boolean;
|
|
19
|
+
readonly timeoutMs?: number;
|
|
20
|
+
readonly fetchImpl?: typeof fetch;
|
|
21
|
+
}
|
|
22
|
+
/** The daemon rejects bodies over 32 MiB and more than 512 inputs; remote providers cap lower. */
|
|
23
|
+
export declare const DEFAULT_EMBED_BATCH_SIZE = 32;
|
|
24
|
+
/**
|
|
25
|
+
* Embedder over an HTTP endpoint: a `minsync serve` daemon (either route) or any remote OpenAI-compatible
|
|
26
|
+
* or TEI server. It owns no model and starts nothing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createHttpEmbedder(options: HttpEmbedderOptions): Embedder;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Embedder } from "./embedder.js";
|
|
2
|
+
/** MinSync's Node-API addon: the same engine, weights and cache as `minsync`'s `native:` embedder. */
|
|
3
|
+
export declare const NATIVE_ADDON_PACKAGE = "@nomadamas/minsync-native";
|
|
4
|
+
export declare const DEFAULT_NATIVE_MODEL_ID = "native:Qwen/Qwen3-Embedding-0.6B";
|
|
5
|
+
export interface InProcessEmbedder extends Embedder {
|
|
6
|
+
/** Releases the model; later calls reject. */
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare class NativeAddonMissingError extends Error {
|
|
10
|
+
constructor(cause: unknown);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Loads MinSync's in-process embedder. AutoRAG ships no model and no inference runtime; the addon is an
|
|
14
|
+
* optional peer that brings MinSync's engine into this process, and MinSync provisions the weights into its
|
|
15
|
+
* own cache on first use.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadNativeEmbedder(options?: {
|
|
18
|
+
readonly id?: string;
|
|
19
|
+
}): Promise<InProcessEmbedder>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MinSyncEmbedderConfig } from "../minsync/types.js";
|
|
2
|
+
import type { ManagedEmbedder } from "./embedder.js";
|
|
3
|
+
export { DEFAULT_DAEMON_MODEL, ensureMinSyncDaemon, MinSyncDaemonError, probeMinSyncDaemon, stopMinSyncDaemon, } from "./daemon.js";
|
|
4
|
+
export type { Embedder, EmbedderEndpoint, EmbedderHealth, EmbeddingBackend, EmbeddingIdentity, EmbedOptions, EmbedRole, ManagedEmbedder, } from "./embedder.js";
|
|
5
|
+
export { createHttpEmbedder, type EmbeddingProtocol } from "./http-embedder.js";
|
|
6
|
+
export { loadNativeEmbedder, NATIVE_ADDON_PACKAGE, NativeAddonMissingError } from "./in-process.js";
|
|
7
|
+
export { createManagedEmbedder, type ManagedEmbedderOptions, type RemoteEmbedderSettings } from "./managed.js";
|
|
8
|
+
export { type EmbeddingPrefixes, QWEN3_QUERY_PREFIX, resolveEmbeddingPrefixes } from "./prefixes.js";
|
|
9
|
+
export { remoteEmbedderFromMinSync } from "./settings.js";
|
|
10
|
+
export interface EmbedderFromConfigOptions {
|
|
11
|
+
/** The `minSync.embedder` block: it selects the embedding backend for MinSync and every other consumer. */
|
|
12
|
+
readonly embedder?: MinSyncEmbedderConfig;
|
|
13
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
14
|
+
/** User home that holds MinSync's `minsync serve` state; defaults to the real home. */
|
|
15
|
+
readonly home?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The single embedder AutoRAG shares between its own semantic stores and the datasources: a configured
|
|
19
|
+
* remote endpoint, else the `minsync serve` daemon the operator runs, else MinSync's in-process engine.
|
|
20
|
+
* AutoRAG never starts the daemon for it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createEmbedderFromConfig(options: EmbedderFromConfigOptions): ManagedEmbedder;
|
|
23
|
+
/**
|
|
24
|
+
* Unload every in-process model this process loaded. A short-lived command calls this on the way out so the
|
|
25
|
+
* addon's native threads cannot keep the process alive after its answer is written. A `minsync serve` daemon
|
|
26
|
+
* is not touched: it belongs to the operator.
|
|
27
|
+
*/
|
|
28
|
+
export declare function releaseEmbedders(): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ManagedEmbedder } from "./embedder.js";
|
|
2
|
+
import { type EmbeddingProtocol } from "./http-embedder.js";
|
|
3
|
+
import { type InProcessEmbedder } from "./in-process.js";
|
|
4
|
+
import type { EmbeddingPrefixes } from "./prefixes.js";
|
|
5
|
+
/** An operator-configured remote endpoint. When present, AutoRAG never looks for MinSync's daemon. */
|
|
6
|
+
export interface RemoteEmbedderSettings {
|
|
7
|
+
readonly baseUrl: string;
|
|
8
|
+
readonly model: string;
|
|
9
|
+
readonly protocol: EmbeddingProtocol;
|
|
10
|
+
readonly dimension?: number;
|
|
11
|
+
readonly apiKeyEnv?: string;
|
|
12
|
+
readonly batchSize?: number;
|
|
13
|
+
readonly timeoutMs?: number;
|
|
14
|
+
/** Reported as the identity provider; defaults to the protocol name. */
|
|
15
|
+
readonly provider?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ManagedEmbedderOptions {
|
|
18
|
+
readonly remote?: RemoteEmbedderSettings;
|
|
19
|
+
/**
|
|
20
|
+
* Prepended to every input by role: `query` for `role: "query"`, `passage` otherwise. Applied here, on the
|
|
21
|
+
* client, for every backend, because neither the daemon nor a remote server is asked to prefix.
|
|
22
|
+
*/
|
|
23
|
+
readonly prefixes?: EmbeddingPrefixes;
|
|
24
|
+
/** User home that holds MinSync's server state. */
|
|
25
|
+
readonly home?: string;
|
|
26
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
27
|
+
/** Model of the daemon to use. Defaults to MinSync's default Qwen3 embedder. */
|
|
28
|
+
readonly model?: string;
|
|
29
|
+
/** Loads MinSync's in-process engine; only called when no daemon answers. */
|
|
30
|
+
readonly inProcess?: () => Promise<InProcessEmbedder>;
|
|
31
|
+
readonly fetchImpl?: typeof fetch;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The one embedder every AutoRAG consumer shares. AutoRAG owns no embedding model and never starts or stops
|
|
35
|
+
* a process: the operator runs `minsync serve` (see docs/minsync-setup.md) or points at a remote endpoint.
|
|
36
|
+
*
|
|
37
|
+
* - **remote**: a configured endpoint is used as is; nothing local is looked for or loaded.
|
|
38
|
+
* - **daemon**: a running `minsync serve` is preferred, because it keeps one warm copy of the model for every
|
|
39
|
+
* process. It is looked up again on every call, so one started or stopped while AutoRAG runs is noticed.
|
|
40
|
+
* - **in-process**: MinSync's own engine, used when no daemon answers. Daemon and in-process vectors are
|
|
41
|
+
* identical for the same model and device, so both report one identity and stores never re-embed
|
|
42
|
+
* because the daemon came or went.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createManagedEmbedder(options: ManagedEmbedderOptions): ManagedEmbedder;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MinSyncEmbedderConfig } from "../minsync/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Qwen3-Embedding is instruction-aware: the query side is `Instruct: {task}\nQuery:{query}` and documents are
|
|
4
|
+
* embedded raw (model card `get_detailed_instruct`; there is no space after `Query:`). The task stays in
|
|
5
|
+
* English even for non-English queries, as the card recommends.
|
|
6
|
+
*/
|
|
7
|
+
export declare const QWEN3_QUERY_PREFIX = "Instruct: Given a web search query, retrieve relevant passages that answer the query\nQuery:";
|
|
8
|
+
/** Text prepended to an embedding input, by what the input is for. */
|
|
9
|
+
export interface EmbeddingPrefixes {
|
|
10
|
+
readonly query: string;
|
|
11
|
+
readonly passage: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The query and passage prefixes for the embedder `minSync.embedder` describes. An operator value, including
|
|
15
|
+
* `""`, always wins. Without one, MinSync's local Qwen3 gets the model's own query instruction; every other
|
|
16
|
+
* model gets none, because its prefix scheme is unknown here.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveEmbeddingPrefixes(embedder: MinSyncEmbedderConfig | undefined): EmbeddingPrefixes;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MinSyncEmbedderConfig } from "../minsync/types.js";
|
|
2
|
+
import type { RemoteEmbedderSettings } from "./managed.js";
|
|
3
|
+
/**
|
|
4
|
+
* The remote endpoint that `minSync.embedder` describes, if any. The same block configures MinSync itself
|
|
5
|
+
* and every AutoRAG-owned consumer (memory, chat sidecars, gist, discrawl), so one remote setting reaches
|
|
6
|
+
* all of them. `tei:` ids and a `baseUrl` mean a remote server; `openai:` ids default to api.openai.com;
|
|
7
|
+
* `native:` ids, a missing id, and a missing endpoint mean MinSync's local Qwen3.
|
|
8
|
+
*/
|
|
9
|
+
export declare function remoteEmbedderFromMinSync(embedder: MinSyncEmbedderConfig | undefined): RemoteEmbedderSettings | undefined;
|