@autorag/librarian 2.7.0 → 2.9.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 (98) hide show
  1. package/NOTICE +10 -4
  2. package/README.md +122 -38
  3. package/dist/agent/agent.d.ts +210 -53
  4. package/dist/agent/answer-guidelines.d.ts +19 -0
  5. package/dist/agent/citations.d.ts +43 -0
  6. package/dist/agent/datasource-skill.d.ts +30 -16
  7. package/dist/agent/emit-results-tool.d.ts +37 -2
  8. package/dist/agent/evidence-judgment.d.ts +58 -0
  9. package/dist/agent/evidence-ledger.d.ts +59 -0
  10. package/dist/agent/evidence-origins.d.ts +49 -0
  11. package/dist/agent/fast-answer-tool.d.ts +16 -6
  12. package/dist/agent/index.d.ts +2 -1
  13. package/dist/agent/jev-extension.d.ts +68 -0
  14. package/dist/agent/jikji-find-tool.d.ts +2 -1
  15. package/dist/agent/pi-session.d.ts +28 -1
  16. package/dist/agent/query-decomposition.d.ts +25 -0
  17. package/dist/agent/query-peer-tool.d.ts +3 -0
  18. package/dist/agent/query-routing.d.ts +115 -0
  19. package/dist/agent/search-all-tool.d.ts +5 -5
  20. package/dist/agent/search-documents.d.ts +3 -11
  21. package/dist/agent/search-minsync-tool.d.ts +5 -5
  22. package/dist/agent/search-single-datasource-tool.d.ts +9 -8
  23. package/dist/agent/self-config.d.ts +40 -0
  24. package/dist/agent/system-prompt.d.ts +3 -3
  25. package/dist/agent/web-fetch-tool.d.ts +2 -1
  26. package/dist/agent/web-search-tool.d.ts +2 -1
  27. package/dist/cli/commands/evidence.d.ts +22 -0
  28. package/dist/cli/commands/init.d.ts +2 -1
  29. package/dist/cli/commands/memory.d.ts +1 -1
  30. package/dist/cli/commands/report.d.ts +1 -1
  31. package/dist/cli/commands/update-check.d.ts +8 -0
  32. package/dist/cli/config.d.ts +80 -7
  33. package/dist/cli/index.d.ts +1 -1
  34. package/dist/cli/index.js +3844 -2291
  35. package/dist/cli/output.d.ts +2 -6
  36. package/dist/cli/update-check.d.ts +34 -0
  37. package/dist/cli/version.d.ts +5 -0
  38. package/dist/config/home.d.ts +6 -0
  39. package/dist/core.d.ts +30 -6
  40. package/dist/core.js +7742 -6225
  41. package/dist/datasource/chunk-store.d.ts +2 -6
  42. package/dist/datasource/connector-skill.d.ts +2 -3
  43. package/dist/datasource/index.d.ts +2 -4
  44. package/dist/datasource/registry.d.ts +11 -13
  45. package/dist/datasource/scope.d.ts +19 -0
  46. package/dist/datasource/skills/github-gist/index.d.ts +1 -1
  47. package/dist/datasource/skills/github-gist/semantic.d.ts +3 -44
  48. package/dist/datasource/skills/github-gist/skill.d.ts +3 -3
  49. package/dist/datasource/types.d.ts +14 -28
  50. package/dist/embedding-runtime/gateway-embedder.d.ts +41 -0
  51. package/dist/everything/bundle.d.ts +15 -3
  52. package/dist/everything/client.d.ts +22 -5
  53. package/dist/everything/index.d.ts +1 -1
  54. package/dist/filesystem/name-search.d.ts +57 -0
  55. package/dist/fsearch/client.d.ts +7 -1
  56. package/dist/index.d.ts +2 -1
  57. package/dist/index.js +9139 -6376
  58. package/dist/jikji/client.d.ts +6 -1
  59. package/dist/language.d.ts +2 -1
  60. package/dist/mcp/index.d.ts +2 -0
  61. package/dist/mcp/index.js +30542 -0
  62. package/dist/mcp/server.d.ts +9 -0
  63. package/dist/memory/check-memory-tool.d.ts +8 -4
  64. package/dist/memory/context.d.ts +51 -0
  65. package/dist/memory/index.d.ts +8 -1
  66. package/dist/memory/judged-evidence.d.ts +32 -0
  67. package/dist/memory/memory.d.ts +36 -120
  68. package/dist/memory/renderer.d.ts +16 -7
  69. package/dist/memory/similar-queries.d.ts +40 -0
  70. package/dist/minsync/errors.d.ts +14 -0
  71. package/dist/minsync/index.d.ts +1 -0
  72. package/dist/minsync/method.d.ts +8 -5
  73. package/dist/mirror/index.d.ts +1 -1
  74. package/dist/mirror/paths.d.ts +6 -0
  75. package/dist/mirror/sync.d.ts +5 -2
  76. package/dist/parser/defaults.d.ts +16 -5
  77. package/dist/parser/index.d.ts +1 -1
  78. package/dist/parser/kordoc.d.ts +8 -1
  79. package/dist/parser/ocr-engines.d.ts +19 -0
  80. package/dist/retrieval/bm25.d.ts +19 -0
  81. package/dist/retrieval/engine.d.ts +33 -43
  82. package/dist/retrieval/index.d.ts +3 -1
  83. package/dist/retrieval/merger.d.ts +6 -0
  84. package/dist/retrieval/rerank.d.ts +4 -2
  85. package/dist/retrieval/selection.d.ts +89 -0
  86. package/dist/retrieval/types.d.ts +1 -3
  87. package/dist/web/search/format.d.ts +5 -2
  88. package/dist/web/search/index.d.ts +7 -1
  89. package/package.json +11 -7
  90. package/skills/autorag/SKILL.md +43 -23
  91. package/skills/autorag-doctor/SKILL.md +40 -26
  92. package/skills/autorag-lite-setup/SKILL.md +123 -64
  93. package/skills/autorag-setup/SKILL.md +107 -22
  94. package/dist/cli/commands/feedback.d.ts +0 -8
  95. package/dist/datasource/access-context.d.ts +0 -43
  96. package/dist/datasource/result-filter.d.ts +0 -64
  97. package/dist/parser/ocr.d.ts +0 -31
  98. package/skills/autorag-lite-search/SKILL.md +0 -245
@@ -57,12 +57,8 @@ export declare class DatasourceChunkStore {
57
57
  hierarchies(): readonly (readonly string[])[];
58
58
  /**
59
59
  * BM25-style lexical search over the stored chunks. Empty queries and
60
- * empty stores return `[]`; this method never throws.
61
- *
62
- * Terms match document tokens exactly or as a prefix (min 2 chars), so
63
- * agglutinative suffixes — Korean particles/endings (인증서 → 인증서를) and
64
- * English inflections (index → indexing) — still rank. Prefix hits are
65
- * slightly discounted against exact hits.
60
+ * empty stores return `[]`; this method never throws. Scoring is delegated
61
+ * to {@link bm25Scores}.
66
62
  */
67
63
  search(query: string, topK: number): readonly ScoredChunk[];
68
64
  private persist;
@@ -14,8 +14,8 @@
14
14
  * - Constructed only from trusted, server-supplied configuration.
15
15
  * - Sources are stable slash-hierarchical paths `/<skill>/<instance>/…`.
16
16
  * - `index()` never throws; failures surface as traceable diagnostics.
17
- * - Retrieval honors `scope` and `allowedScopes` narrowing; tool arguments
18
- * can never widen access (enforced upstream by DatasourceAccessContext).
17
+ * - Retrieval honors the ordinary query `scope`; results are slash-hierarchical
18
+ * opaque sources with no `#` fragment.
19
19
  * - Results and metadata may carry real file paths or account identifiers;
20
20
  * privacy is the operator's responsibility (use a local LLM).
21
21
  */
@@ -111,6 +111,5 @@ export declare class ConnectorLexicalMethod implements RetrievalMethod {
111
111
  constructor(options: ConnectorLexicalMethodOptions);
112
112
  describe(): RetrievalMethodDescriptor;
113
113
  retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
114
- private matchesScope;
115
114
  }
116
115
  export {};
@@ -1,4 +1,3 @@
1
- export { DatasourceAccessContext, type DatasourceAccessContextOptions } from "./access-context.js";
2
1
  export { type AliasDatasourceSkillOptions, AliasedDatasourceSkill } from "./aliased-skill.js";
3
2
  export { DatasourceChunkStore, type DatasourceChunkStoreOptions, datasourceChunkStorePath, type ScoredChunk, type StoredChunk, } from "./chunk-store.js";
4
3
  export { boundDiagnosticText, type ConnectorDocument, type ConnectorFailureReason, type ConnectorFetchFail, type ConnectorFetchOk, type ConnectorFetchResult, connectorFailureToDiagnosticCode, type DatasourceConnector, sanitizeIdSegment, } from "./connector.js";
@@ -6,8 +5,7 @@ export { ConnectorDatasourceSkill, ConnectorLexicalMethod, type ConnectorSkillDe
6
5
  export { mapDatasourceDiagnostic, mapDatasourceDiagnostics } from "./diagnostics.js";
7
6
  export { type CronParseResult, isDue, parseCronExpr } from "./polling.js";
8
7
  export { DatasourceSkillRegistry, type RegisteredDatasourceSkill } from "./registry.js";
9
- export { DatasourceResultFilter, type ResultsByMethod } from "./result-filter.js";
10
- export { buildDatasourceChunkSource, buildDatasourceInstanceSource, DATASOURCE_CHUNKS_SEGMENT, datasourceSourceHasFragment, datasourceSourcePath, isDatasourceSource, matchesDatasourceScope, matchesVirtualPathScope, normalizeVirtualPath, } from "./scope.js";
8
+ export { buildDatasourceChunkSource, buildDatasourceInstanceSource, DATASOURCE_CHUNKS_SEGMENT, datasourceSourceHasFragment, datasourceSourcePath, filterDatasourceScope, isDatasourceSource, matchesDatasourceScope, matchesVirtualPathScope, normalizeVirtualPath, type ResultsByMethod, } from "./scope.js";
11
9
  export { CLOUD_DRIVE_SKILL_DEFINITION, CloudDriveSkill, type CloudDriveSkillOptions, RcloneConnector, type RcloneConnectorOptions, type RcloneRunner, type RcloneRunResult, } from "./skills/cloud-drive/index.js";
12
10
  export { DEFAULT_DISCRAWL_EMBEDDING_MODEL, DEFAULT_DISCRAWL_MODE, DiscrawlClient, type DiscrawlFailureReason, DiscrawlFtsMethod, DiscrawlHybridMethod, type DiscrawlOptions, type DiscrawlSearchHit, type DiscrawlSearchMode, type DiscrawlSearchOptions, type DiscrawlSearchResult, DiscrawlSemanticMethod, DiscrawlSkill, type DiscrawlSkillClient, type DiscrawlSkillOptions, ENGLISH_ONLY_EMBEDDING_MODELS, } from "./skills/discrawl/index.js";
13
11
  export { BUILTIN_DATASOURCE_SKILL_NAMES, type BuildDatasourceSkillsResult, buildDatasourceSkills, type DatasourceSkillConfig, type DatasourcesConfig, } from "./skills/factory.js";
@@ -24,4 +22,4 @@ export { SlackSkill, type SlackSkillOptions, SlacrawlClient, type SlacrawlOption
24
22
  export { SpotlightConnector, type SpotlightConnectorOptions, SpotlightSkill, type SpotlightSkillOptions, } from "./skills/spotlight/index.js";
25
23
  export { TelecrawlClient, type TelecrawlOptions, TelecrawlSkill, type TelecrawlSkillOptions, } from "./skills/telecrawl/index.js";
26
24
  export { WacrawlClient, type WacrawlOptions, WacrawlSkill, type WacrawlSkillOptions } from "./skills/wacrawl/index.js";
27
- export type { DatasourceAccessible, DatasourceDiagnostic, DatasourceDiagnosticCode, DatasourceIndexFail, DatasourceIndexOk, DatasourceIndexResult, DatasourceInstance, DatasourceSkill, DatasourceSkillDescriptor, DatasourceSkillManifest, PollingMetadata, SourceDescription, } from "./types.js";
25
+ export type { DatasourceDiagnostic, DatasourceDiagnosticCode, DatasourceIndexFail, DatasourceIndexOk, DatasourceIndexResult, DatasourceInstance, DatasourceSkill, DatasourceSkillDescriptor, DatasourceSkillManifest, PollingMetadata, SourceDescription, } from "./types.js";
@@ -3,14 +3,13 @@
3
3
  *
4
4
  * Skills are constructed from trusted, server-supplied configuration and
5
5
  * registered here so the retrieval pipeline can enumerate them, look them up
6
- * by tag, and resolve the concrete instances a given access context permits.
6
+ * by tag (descriptive metadata), and resolve the concrete instances they expose.
7
7
  *
8
- * The registry never grants access: {@link resolveInstances} only *narrows*
9
- * the registered skills to those a {@link DatasourceAccessContext} already
10
- * allows. Model/tool arguments are not consulted.
8
+ * Every configured/connected datasource is searchable without permission setup;
9
+ * there is no access context. The ordinary query `scope` narrows results later
10
+ * in the pipeline, not here. Model/tool arguments are not consulted.
11
11
  */
12
12
  import type { RetrievalMethod } from "../retrieval/types.js";
13
- import type { DatasourceAccessContext } from "./access-context.js";
14
13
  import type { DatasourceInstance, DatasourceSkill, DatasourceSkillDescriptor } from "./types.js";
15
14
  /** A registered skill paired with its cached descriptor. */
16
15
  export interface RegisteredDatasourceSkill {
@@ -30,23 +29,22 @@ export declare class DatasourceSkillRegistry {
30
29
  register(skill: DatasourceSkill): void;
31
30
  /** All registered skills in insertion order. */
32
31
  list(): readonly RegisteredDatasourceSkill[];
33
- /** Skills whose descriptor carries the given tag. */
32
+ /** Skills whose descriptor carries the given tag (descriptive metadata). */
34
33
  byTag(tag: string): readonly RegisteredDatasourceSkill[];
35
34
  /** Look up a registered skill by id, or `undefined`. */
36
35
  get(id: string): RegisteredDatasourceSkill | undefined;
37
36
  /**
38
- * Resolve the concrete datasource instances reachable under `ctx`.
37
+ * Resolve every configured datasource instance.
39
38
  *
40
- * Only skills whose descriptor {@link DatasourceAccessContext.isAccessible}
41
- * allows contribute instances, and only their declared instance ids are
39
+ * All registered skills contribute, and only their declared instance ids are
42
40
  * materialized. Each instance carries its opaque slash-hierarchical
43
41
  * {@link DatasourceInstance.sourcePath} (e.g. `/kakao/acct-1`), built from
44
42
  * the trusted skill name and instance id — never from model input.
45
43
  */
46
- resolveInstances(ctx: DatasourceAccessContext): readonly DatasourceInstance[];
44
+ resolveInstances(): readonly DatasourceInstance[];
47
45
  /**
48
- * Convenience: all retrieval methods exposed by accessible skills, for
49
- * feeding the shared retriever. Methods from denied skills are excluded.
46
+ * All retrieval methods exposed by registered skills, for feeding the shared
47
+ * retriever.
50
48
  */
51
- accessibleMethods(ctx: DatasourceAccessContext): readonly RetrievalMethod[];
49
+ retrievalMethods(): readonly RetrievalMethod[];
52
50
  }
@@ -9,6 +9,9 @@
9
9
  * `src/retrieval/scope.ts` so datasource scopes compose with the existing
10
10
  * retrieval scope grammar (globs, leading-slash normalization).
11
11
  */
12
+ import type { RetrievalMethod, RetrievalResult } from "../retrieval/types.js";
13
+ /** Per-method retrieval results keyed by method name. */
14
+ export type ResultsByMethod = Map<string, RetrievalResult[]>;
12
15
  /** Path segment separating an instance root from its chunk sub-namespace. */
13
16
  export declare const DATASOURCE_CHUNKS_SEGMENT = "chunks";
14
17
  /**
@@ -35,4 +38,20 @@ export declare function isDatasourceSource(source: string): boolean;
35
38
  * scope matcher so globs and leading-slash normalization behave identically.
36
39
  */
37
40
  export declare function matchesDatasourceScope(source: string, scope: string | undefined): boolean;
41
+ /**
42
+ * Narrow a per-method result map by the ordinary query `scope`.
43
+ *
44
+ * This is the only post-retrieval narrowing left in the datasource layer: every
45
+ * configured datasource is searchable without permission setup. Methods whose
46
+ * descriptor has no `datasourceId` (plain retrieval methods such as `posix`) and
47
+ * datasource methods that do not advertise the `scoped` capability pass through
48
+ * untouched. Scope-capable datasource methods keep only the results whose
49
+ * source matches `scope`; `undefined` scope matches every valid source, and
50
+ * sources containing a `#` fragment are always rejected.
51
+ *
52
+ * Result entries for methods not present in `methods` are passed through
53
+ * unchanged (they cannot be classified). A new map is returned; the input is
54
+ * not mutated.
55
+ */
56
+ export declare function filterDatasourceScope(byMethod: ResultsByMethod, methods: readonly RetrievalMethod[], scope?: string): ResultsByMethod;
38
57
  export { matchesVirtualPathScope, normalizeVirtualPath } from "../retrieval/scope.js";
@@ -1,3 +1,3 @@
1
1
  export { GitHubGistConnector, type GitHubGistConnectorOptions } from "./connector.js";
2
- export { createGatewayGistEmbedder, type GatewayGistEmbedderOptions, type GistEmbedder, type GistEmbeddingIdentity, GistSemanticIndex, GitHubGistSemanticMethod, } from "./semantic.js";
2
+ export { GistSemanticIndex, GitHubGistSemanticMethod } from "./semantic.js";
3
3
  export { GITHUB_GIST_SKILL_DEFINITION, type GitHubGistSemanticOptions, GitHubGistSkill, type GitHubGistSkillOptions, gistDatasourceDir, } from "./skill.js";
@@ -9,19 +9,9 @@
9
9
  * `cachedOnly`, then `POST /v1/embeddings`); tests inject a stub. Every
10
10
  * failure degrades — indexing stays lexical-only and retrieval returns [].
11
11
  */
12
- import type { ProfileId } from "../../../embedding-runtime/types.js";
12
+ import type { Embedder } from "../../../embedding-runtime/gateway-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
- export interface GistEmbeddingIdentity {
16
- readonly provider: string;
17
- readonly model: string;
18
- readonly dimension: number;
19
- }
20
- /** Embedder contract: identity is async because the gateway resolves it lazily. */
21
- export interface GistEmbedder {
22
- identity(): Promise<GistEmbeddingIdentity>;
23
- embed(texts: readonly string[]): Promise<readonly (readonly number[])[]>;
24
- }
25
15
  export interface GistSemanticSyncOk {
26
16
  readonly ok: true;
27
17
  /** Number of chunks (re-)embedded in this sync. */
@@ -44,7 +34,7 @@ export declare class GistSemanticIndex {
44
34
  * Embed new/changed chunks, prune removed ones, and persist. Never throws;
45
35
  * an embedder failure leaves prior entries intact and reports ok:false.
46
36
  */
47
- sync(chunks: readonly StoredChunk[], embedder: GistEmbedder): Promise<GistSemanticSyncOk | GistSemanticSyncFail>;
37
+ sync(chunks: readonly StoredChunk[], embedder: Embedder): Promise<GistSemanticSyncOk | GistSemanticSyncFail>;
48
38
  /** Cosine-ranked chunk ids for a query vector. Never throws. */
49
39
  searchByVector(queryVector: readonly number[], topK: number): readonly {
50
40
  chunkId: string;
@@ -60,7 +50,7 @@ export interface GitHubGistSemanticMethodOptions {
60
50
  readonly tags: readonly string[];
61
51
  readonly store: DatasourceChunkStore;
62
52
  readonly index: GistSemanticIndex;
63
- readonly embedder: GistEmbedder;
53
+ readonly embedder: Embedder;
64
54
  }
65
55
  /** Cosine similarity retrieval over the gist vector sidecar. Never throws. */
66
56
  export declare class GitHubGistSemanticMethod implements RetrievalMethod {
@@ -68,35 +58,4 @@ export declare class GitHubGistSemanticMethod implements RetrievalMethod {
68
58
  constructor(options: GitHubGistSemanticMethodOptions);
69
59
  describe(): RetrievalMethodDescriptor;
70
60
  retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
71
- private matchesScope;
72
61
  }
73
- export interface GatewayGistEmbedderOptions {
74
- /** Runtime resolver; defaults to the shared embedding-runtime ensureRuntime. */
75
- readonly runtime?: {
76
- ensureRuntime(input?: {
77
- profileId?: ProfileId;
78
- cachedOnly?: boolean;
79
- }): Promise<{
80
- baseUrl: string;
81
- identity: {
82
- provider: string;
83
- model: string;
84
- dimension: number;
85
- };
86
- }>;
87
- };
88
- readonly profileId?: ProfileId;
89
- readonly fetchImpl?: typeof fetch;
90
- }
91
- /**
92
- * Production embedder backed by the loopback autorag-gateway. The runtime is
93
- * ensured lazily with `cachedOnly` so semantic retrieval never triggers a
94
- * model download; an unprimed cache surfaces as a sync/retrieve degrade.
95
- */
96
- /**
97
- * Texts per `/v1/embeddings` call. The llama.cpp upstream rejects very large
98
- * batches (HTTP 413 on a full-archive sync), so embedding fans out in
99
- * bounded sequential batches while preserving input order.
100
- */
101
- export declare const GIST_EMBED_BATCH_SIZE = 32;
102
- export declare function createGatewayGistEmbedder(options?: GatewayGistEmbedderOptions): GistEmbedder;
@@ -7,19 +7,19 @@
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 { type Embedder, type GatewayEmbedderOptions } from "../../../embedding-runtime/gateway-embedder.js";
10
11
  import type { RetrievalMethod } from "../../../retrieval/types.js";
11
12
  import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
12
13
  import type { DatasourceIndexResult } from "../../types.js";
13
14
  import { GitHubGistConnector, type GitHubGistConnectorOptions } from "./connector.js";
14
- import { type GatewayGistEmbedderOptions, type GistEmbedder } from "./semantic.js";
15
15
  export declare const GITHUB_GIST_SKILL_DEFINITION: ConnectorSkillDefinition;
16
16
  export declare function gistDatasourceDir(workspaceRoot: string, skillName: string, instanceId: string): string;
17
17
  export interface GitHubGistSemanticOptions {
18
18
  /** Set false to run lexical-only. Default true. */
19
19
  readonly enabled?: boolean;
20
20
  /** Injected embedder (tests); defaults to the loopback gateway embedder. */
21
- readonly embedder?: GistEmbedder;
22
- readonly embedderOptions?: GatewayGistEmbedderOptions;
21
+ readonly embedder?: Embedder;
22
+ readonly embedderOptions?: GatewayEmbedderOptions;
23
23
  /** Vector sidecar path override; defaults under `.autorag/datasources/…`. */
24
24
  readonly statePath?: string;
25
25
  }
@@ -4,27 +4,24 @@
4
4
  * A *datasource* is an external, server-bound source of retrieval evidence
5
5
  * (e.g. a KakaoTalk export reached through the external `lazykatok` CLI). The
6
6
  * datasource layer sits *on top of* the existing retrieval pipeline: it owns
7
- * access gating and slash-hierarchical source naming, while actual retrieval
8
- * still flows through {@link RetrievalMethod} instances returned by a skill.
7
+ * slash-hierarchical source naming, while actual retrieval still flows through
8
+ * {@link RetrievalMethod} instances returned by a skill.
9
9
  *
10
- * Security invariants (enforced by {@link DatasourceAccessContext}):
11
- * - Access is **default-deny**: when no trusted allow-tags are configured,
12
- * every datasource descriptor and source is denied.
13
- * - Deny is always an explicit `false` boolean / predicate return — never
14
- * `undefined`-as-deny.
15
- * - Model/tool arguments never grant access. Only the trusted server-supplied
16
- * {@link DatasourceAccessContext} can authorize a datasource.
17
- * - Datasource sources are slash-hierarchical opaque paths when the skill
18
- * supports the `scoped` capability; skills without that capability may
19
- * expose another opaque identity format.
10
+ * Every configured/connected datasource is searchable without permission
11
+ * setup: there is no tag/scope authorization layer. The ordinary query `scope`
12
+ * narrows results after retrieval (see `filterDatasourceScope`), and skill
13
+ * descriptor `tags` are descriptive metadata only — never authority.
14
+ * Datasource sources are slash-hierarchical opaque paths for skills that
15
+ * advertise the `scoped` capability; skills without it may expose another
16
+ * opaque identity format.
20
17
  */
21
18
  import type { RetrievalMethod } from "../retrieval/types.js";
22
19
  export type { RetrievalMethod } from "../retrieval/types.js";
23
20
  /**
24
21
  * Descriptor for a datasource skill (e.g. KakaoTalk via `lazykatok`).
25
22
  *
26
- * Structurally compatible with {@link RetrievalMethodDescriptor} so that
27
- * retrieval method descriptors can be gated by the same access context.
23
+ * Structurally compatible with {@link RetrievalMethodDescriptor}: retrieval
24
+ * method descriptors carry the same `datasourceId`/`tags`/`capabilities` fields.
28
25
  */
29
26
  export interface DatasourceSkillDescriptor {
30
27
  /** Stable skill name, e.g. `"kakao"`. */
@@ -37,8 +34,8 @@ export interface DatasourceSkillDescriptor {
37
34
  /** Capability tags such as `"chat"`, `"external-cli"`, `"polling"`. */
38
35
  readonly capabilities: readonly string[];
39
36
  /**
40
- * Authorization tags. A descriptor is accessible only when at least one tag
41
- * intersects the trusted allow-tags on the access context.
37
+ * Descriptive tags such as `"chat"` or `"external-cli"`. Metadata only —
38
+ * never used to authorize or narrow access.
42
39
  */
43
40
  readonly tags: readonly string[];
44
41
  readonly status: "active" | "stub";
@@ -47,7 +44,7 @@ export interface DatasourceSkillDescriptor {
47
44
  /**
48
45
  * Set when this descriptor describes a datasource-backed surface.
49
46
  * Non-datasource descriptors (e.g. plain `posix` retrieval methods) leave
50
- * this undefined and are passed through by the access context.
47
+ * this undefined.
51
48
  */
52
49
  readonly datasourceId?: string;
53
50
  /** Optional primary instance id for single-instance skills. */
@@ -55,17 +52,6 @@ export interface DatasourceSkillDescriptor {
55
52
  /** Optional list of instance ids this skill reports. */
56
53
  readonly instances?: readonly string[];
57
54
  }
58
- /**
59
- * Minimal structural shape required to gate a descriptor by access context.
60
- * Both {@link DatasourceSkillDescriptor} and `RetrievalMethodDescriptor`
61
- * satisfy this interface structurally.
62
- */
63
- export interface DatasourceAccessible {
64
- readonly datasourceId?: string;
65
- readonly tags?: readonly string[];
66
- /** Capability names such as `scoped`; absent means no source-scope support. */
67
- readonly capabilities?: readonly string[];
68
- }
69
55
  /**
70
56
  * A pluggable datasource skill. Skills are server-bound: they are constructed
71
57
  * with trusted configuration and never derive authority from model/tool args.
@@ -0,0 +1,41 @@
1
+ import type { ProfileId } from "./types.js";
2
+ export interface EmbeddingIdentity {
3
+ readonly provider: string;
4
+ readonly model: string;
5
+ readonly dimension: number;
6
+ }
7
+ /** Embedder contract: identity is async because the gateway resolves it lazily. */
8
+ export interface Embedder {
9
+ identity(): Promise<EmbeddingIdentity>;
10
+ embed(texts: readonly string[]): Promise<readonly (readonly number[])[]>;
11
+ }
12
+ export interface GatewayEmbedderOptions {
13
+ /** Runtime resolver; defaults to the shared embedding-runtime ensureRuntime. */
14
+ readonly runtime?: {
15
+ ensureRuntime(input?: {
16
+ profileId?: ProfileId;
17
+ cachedOnly?: boolean;
18
+ }): Promise<{
19
+ baseUrl: string;
20
+ identity: {
21
+ provider: string;
22
+ model: string;
23
+ dimension: number;
24
+ };
25
+ }>;
26
+ };
27
+ readonly profileId?: ProfileId;
28
+ readonly fetchImpl?: typeof fetch;
29
+ }
30
+ /**
31
+ * Texts per `/v1/embeddings` call. The llama.cpp upstream rejects very large
32
+ * batches (HTTP 413 on a full-archive sync), so embedding fans out in
33
+ * bounded sequential batches while preserving input order.
34
+ */
35
+ export declare const EMBED_BATCH_SIZE = 32;
36
+ /**
37
+ * Production embedder backed by the loopback autorag-gateway. The runtime is
38
+ * ensured lazily with `cachedOnly` so embedding never triggers a model
39
+ * download; an unprimed cache surfaces as a caller-side degrade.
40
+ */
41
+ export declare function createGatewayEmbedder(options?: GatewayEmbedderOptions): Embedder;
@@ -6,6 +6,12 @@
6
6
  * and nothing is installed system-wide.
7
7
  */
8
8
  export type EverythingArch = "x64" | "arm64";
9
+ /**
10
+ * `"install"` extracts and verifies the pinned binaries when the workspace
11
+ * cache is missing or invalid; `"cached"` returns only an already extracted,
12
+ * hash-verified cache entry and never writes to disk.
13
+ */
14
+ export type EverythingBinaryResolutionMode = "cached" | "install";
9
15
  export interface EverythingArchAssets {
10
16
  readonly everythingArchive: string;
11
17
  readonly everythingArchiveSha256: string;
@@ -31,6 +37,8 @@ export interface EnsureEverythingBinariesOptions {
31
37
  readonly bundleDir?: string;
32
38
  /** Bundle manifest. Defaults to `<bundleDir>/manifest.json`. */
33
39
  readonly manifest?: EverythingBundleManifest;
40
+ /** Defaults to `"install"`; `"cached"` is the read-only resolution a query uses. */
41
+ readonly mode?: EverythingBinaryResolutionMode;
34
42
  }
35
43
  export type EnsureEverythingBinariesResult = {
36
44
  readonly ok: true;
@@ -39,7 +47,7 @@ export type EnsureEverythingBinariesResult = {
39
47
  readonly source: "cached" | "installed";
40
48
  } | {
41
49
  readonly ok: false;
42
- readonly reason: "unsupported-platform" | "bundle-missing" | "install-failed";
50
+ readonly reason: "unsupported-platform" | "bundle-missing" | "install-failed" | "not-installed";
43
51
  readonly message: string;
44
52
  };
45
53
  /**
@@ -56,7 +64,11 @@ export declare function everythingBinaryPaths(root: string, version: string, arc
56
64
  };
57
65
  export declare function loadEverythingBundleManifest(bundleDir: string): EverythingBundleManifest;
58
66
  /**
59
- * Extract and verify the bundled Everything + ES binaries for this Windows
60
- * host. Never throws: every failure is reported with its underlying message.
67
+ * Resolve the bundled Everything + ES binaries for this Windows host. Never
68
+ * throws: every failure is reported with its underlying message. `mode:
69
+ * "install"` (default) extracts and verifies them from the bundled ZIPs when
70
+ * the workspace cache is missing or invalid; `mode: "cached"` is read-only and
71
+ * reports `not-installed` instead of writing so a query can only use verified,
72
+ * already-extracted binaries.
61
73
  */
62
74
  export declare function ensureEverythingBinaries(options: EnsureEverythingBinariesOptions): Promise<EnsureEverythingBinariesResult>;
@@ -1,4 +1,4 @@
1
- import { type EnsureEverythingBinariesResult } from "./bundle.js";
1
+ import { type EnsureEverythingBinariesResult, type EverythingBinaryResolutionMode } from "./bundle.js";
2
2
  /**
3
3
  * Drives a private, user-level Everything instance per AutoRAG workspace.
4
4
  *
@@ -32,7 +32,7 @@ export interface EverythingSearchRequest {
32
32
  readonly offset?: number;
33
33
  readonly maxResults?: number;
34
34
  }
35
- export type EverythingFailureReason = "unsupported-platform" | "bundle-missing" | "install-failed" | "startup-failed" | "index-failed" | "search-failed";
35
+ export type EverythingFailureReason = "unsupported-platform" | "bundle-missing" | "install-failed" | "not-installed" | "not-running" | "startup-failed" | "index-failed" | "search-failed";
36
36
  export interface EverythingFailure {
37
37
  readonly ok: false;
38
38
  readonly reason: EverythingFailureReason;
@@ -70,7 +70,12 @@ export interface EverythingClientOptions extends EverythingOptions {
70
70
  /** Folders Everything indexes (the configured search paths). */
71
71
  readonly folders: readonly string[];
72
72
  readonly platform?: NodeJS.Platform;
73
- readonly resolveBinaries?: () => Promise<EnsureEverythingBinariesResult>;
73
+ /**
74
+ * Resolve the bundled executables. `"cached"` (queries and stop) must
75
+ * return only already extracted, hash-verified binaries; `"install"`
76
+ * (refresh/index) may extract them. Defaults to `ensureEverythingBinaries`.
77
+ */
78
+ readonly resolveBinaries?: (mode: EverythingBinaryResolutionMode) => Promise<EnsureEverythingBinariesResult>;
74
79
  readonly run?: EverythingRunner;
75
80
  readonly launch?: EverythingLauncher;
76
81
  readonly pollIntervalMs?: number;
@@ -105,16 +110,28 @@ export declare class EverythingClient {
105
110
  private operation;
106
111
  constructor(options: EverythingClientOptions);
107
112
  isSupported(): boolean;
108
- /** Start the instance when needed and search it. */
113
+ /**
114
+ * Search the running instance. Read-only: never starts Everything, waits
115
+ * for it to index, or installs its binaries (refresh does that), so a query
116
+ * never pays startup or extraction cost. A cold cache reports
117
+ * `not-installed` with a refresh hint instead.
118
+ */
109
119
  search(request: EverythingSearchRequest): Promise<EverythingSearchResult>;
110
120
  /**
111
121
  * (Re)write the folder configuration, restart the instance so Everything
112
122
  * loads it, and wait until the database finished indexing.
113
123
  */
114
124
  index(): Promise<EverythingIndexResult>;
115
- /** Exit this workspace's Everything instance if it is running. */
125
+ /** Exit this workspace's Everything instance if it is running. Never installs binaries. */
116
126
  stop(): Promise<void>;
117
127
  private serialize;
128
+ /**
129
+ * Resolve the ES + Everything executables. `"cached"` reads only the
130
+ * already extracted, hash-verified workspace cache and never writes;
131
+ * `"install"` (refresh/index) may extract from the bundled ZIPs. Only a
132
+ * verified resolution is memoized, so a cached-mode miss never poisons the
133
+ * install-mode resolution that refresh depends on.
134
+ */
118
135
  private resolveBinaries;
119
136
  private ensureRunning;
120
137
  /** Exit code 0 only when the instance answered with its version. */
@@ -1,2 +1,2 @@
1
- export { type EnsureEverythingBinariesOptions, type EnsureEverythingBinariesResult, type EverythingArch, type EverythingArchAssets, type EverythingBundleManifest, ensureEverythingBinaries, everythingArch, everythingBinaryPaths, loadEverythingBundleManifest, resolveEverythingBundleDir, } from "./bundle.js";
1
+ export { type EnsureEverythingBinariesOptions, type EnsureEverythingBinariesResult, type EverythingArch, type EverythingArchAssets, type EverythingBinaryResolutionMode, type EverythingBundleManifest, ensureEverythingBinaries, everythingArch, everythingBinaryPaths, loadEverythingBundleManifest, resolveEverythingBundleDir, } from "./bundle.js";
2
2
  export { buildEverythingIni, buildEverythingSearchArgs, EverythingClient, type EverythingClientOptions, type EverythingEntry, type EverythingFailure, type EverythingFailureReason, type EverythingIndexResult, type EverythingLauncher, type EverythingOptions, type EverythingRunner, type EverythingRunResult, type EverythingSearchRequest, type EverythingSearchResult, type EverythingSort, everythingInstanceName, parseEverythingJson, } from "./client.js";
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Literal (never regex) file-name search over configured filesystem roots.
3
+ *
4
+ * This is a discovery-only backend: it walks directories directly and never
5
+ * consults a parsed mirror/index, so a name can be found before any refresh
6
+ * has run. It never opens file contents — only directory listings are read.
7
+ *
8
+ * Path safety is the whole point of this module:
9
+ * - configured roots are `realpath`-pinned; missing roots degrade to a
10
+ * diagnostic instead of an exception;
11
+ * - `request.root` may only select a configured root or a real subdirectory
12
+ * *inside* one (realpath containment), so it can never widen scope;
13
+ * - child symlinks are never followed, so a symlink inside a root cannot leak
14
+ * results from outside it;
15
+ * - when nothing can be searched, the result is an empty page plus a warning
16
+ * diagnostic, never an arbitrary global `/` scan.
17
+ */
18
+ /** A single matched entry, with its canonical absolute filesystem path. */
19
+ export interface FileNameSearchMatch {
20
+ readonly path: string;
21
+ readonly type: "file" | "folder";
22
+ }
23
+ /** A non-fatal problem encountered while resolving or walking roots. */
24
+ export interface FileNameSearchDiagnostic {
25
+ readonly code: string;
26
+ readonly severity: "warning";
27
+ readonly source: string;
28
+ readonly message: string;
29
+ }
30
+ export interface FileNameSearchRequest {
31
+ readonly query: string;
32
+ /** Configured root or subdirectory (absolute or root-relative) to limit the walk to. */
33
+ readonly root?: string;
34
+ /** Match the query against the path relative to the search root instead of the file name. */
35
+ readonly matchPath?: boolean;
36
+ /** Case-sensitive matching. Defaults to case-insensitive. */
37
+ readonly matchCase?: boolean;
38
+ readonly kind?: "files" | "folders";
39
+ readonly maxResults?: number;
40
+ readonly offset?: number;
41
+ readonly signal?: AbortSignal;
42
+ }
43
+ export interface FileNameSearchResult {
44
+ readonly ok: true;
45
+ readonly backend: "filesystem" | "everything";
46
+ readonly results: readonly FileNameSearchMatch[];
47
+ readonly truncated: boolean;
48
+ readonly diagnostics: readonly FileNameSearchDiagnostic[];
49
+ }
50
+ /** Resolve one requested root inside the configured roots for backend routing. */
51
+ export declare function resolveConfiguredFileSearchRoot(roots: readonly string[], requestRoot: string): Promise<string | undefined>;
52
+ /**
53
+ * Keep provider-returned file-name hits inside configured roots and exclusions.
54
+ * Revalidates lstat/realpath so an external index cannot widen MCP scope.
55
+ */
56
+ export declare function filterFileNameSearchMatches(roots: readonly string[], candidates: readonly FileNameSearchMatch[], excludePaths?: readonly string[]): Promise<FileNameSearchMatch[]>;
57
+ export declare function searchFileNames(roots: readonly string[], request: FileNameSearchRequest, excludePaths?: readonly string[]): Promise<FileNameSearchResult>;
@@ -90,6 +90,8 @@ export interface FSearchClientOptions extends FSearchOptions {
90
90
  readonly root: string;
91
91
  /** Folders FSearch indexes (the configured search paths). */
92
92
  readonly folders: readonly string[];
93
+ /** Additional configured folders omitted from the index. */
94
+ readonly excludeFolders?: readonly string[];
93
95
  readonly platform?: NodeJS.Platform;
94
96
  readonly run?: FSearchRunner;
95
97
  readonly launch?: FSearchLauncher;
@@ -144,7 +146,11 @@ export declare class FSearchClient {
144
146
  private operation;
145
147
  constructor(options: FSearchClientOptions);
146
148
  isSupported(): boolean;
147
- /** Search the workspace database, building it on first use; walks when fsearch-cli is missing. */
149
+ /**
150
+ * Search the prebuilt workspace database. Read-only: a missing database is
151
+ * never built here (refresh does that), so a query never pays for indexing.
152
+ * Without fsearch-cli or a database, it walks the configured folders.
153
+ */
148
154
  search(request: FSearchSearchRequest): Promise<FSearchSearchResult>;
149
155
  /** (Re)build the database over the configured folders and keep the watch daemon live. */
150
156
  index(): Promise<FSearchIndexResult>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AutoRAGAgent, type AutoRAGAgentOptions, type AutoRAGRefreshComponentStatus, type AutoRAGRefreshOptions, type AutoRAGRefreshResult, type AutoRAGRefreshStatus, type AutoRAGWatchRefreshHandle, type AutoRAGWatchRefreshOptions, type AutoRefreshOptions, type RefreshMethod, } from "./agent/agent.js";
2
- export { type AutoRAGResultsDetails, createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME, emitResultsSchema, type SearchDocumentDiagnostic, type SearchDocumentDiagnosticCode, type SearchDocumentDiagnosticSeverity, type SearchDocumentsResponse, type SearchDocumentsStreamEvent, type SearchDocumentWarning, } from "./agent/index.js";
2
+ export { type AutoRAGResultsDetails, createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME, emitResultsSchema, reportSchema, type SearchDocumentDiagnostic, type SearchDocumentDiagnosticCode, type SearchDocumentDiagnosticSeverity, type SearchDocumentsResponse, type SearchDocumentsStreamEvent, type SearchDocumentWarning, } from "./agent/index.js";
3
3
  export { buildSystemPrompt, type SystemPromptConfig } from "./agent/system-prompt.js";
4
4
  export { AutoRAGLite, type AutoRAGLiteOptions, buildAgentOptions, type CliConfig, createAutoRAGLite, type ResolveConfigInput, resolveConfig, resolveConfigReadOnly, writeConfigObject, writeDefaultConfig, } from "./core.js";
5
5
  export * from "./datasource/index.js";
@@ -8,6 +8,7 @@ export * from "./everything/index.js";
8
8
  export * from "./fsearch/index.js";
9
9
  export * from "./jikji/index.js";
10
10
  export * from "./manifest/index.js";
11
+ export { type AutoRAGMcpServerOptions, createAutoRAGMcpServer } from "./mcp/server.js";
11
12
  export * from "./memory/index.js";
12
13
  export * from "./minsync/index.js";
13
14
  export * from "./mirror/index.js";