@autorag/librarian 2.8.0 → 2.10.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 (97) hide show
  1. package/NOTICE +4 -4
  2. package/README.md +120 -24
  3. package/dist/agent/agent.d.ts +147 -78
  4. package/dist/agent/answer-citations.d.ts +22 -0
  5. package/dist/agent/answer-guidelines.d.ts +9 -9
  6. package/dist/agent/citations.d.ts +42 -7
  7. package/dist/agent/datasource-skill.d.ts +30 -16
  8. package/dist/agent/evidence-judgment.d.ts +58 -0
  9. package/dist/agent/evidence-ledger.d.ts +54 -0
  10. package/dist/agent/evidence-origins.d.ts +49 -0
  11. package/dist/agent/index.d.ts +2 -2
  12. package/dist/agent/jikji-find-tool.d.ts +2 -1
  13. package/dist/agent/pi-session.d.ts +8 -1
  14. package/dist/agent/query-peer-tool.d.ts +3 -0
  15. package/dist/agent/query-routing.d.ts +71 -10
  16. package/dist/agent/{emit-results-tool.d.ts → results.d.ts} +11 -11
  17. package/dist/agent/search-all-tool.d.ts +5 -5
  18. package/dist/agent/search-documents.d.ts +14 -27
  19. package/dist/agent/search-minsync-tool.d.ts +5 -5
  20. package/dist/agent/search-single-datasource-tool.d.ts +9 -8
  21. package/dist/agent/self-config.d.ts +40 -0
  22. package/dist/agent/system-prompt.d.ts +2 -3
  23. package/dist/agent/web-fetch-tool.d.ts +2 -1
  24. package/dist/agent/web-search-tool.d.ts +2 -1
  25. package/dist/cli/commands/evidence.d.ts +2 -2
  26. package/dist/cli/commands/memory.d.ts +1 -1
  27. package/dist/cli/commands/report.d.ts +2 -2
  28. package/dist/cli/commands/tui.d.ts +3 -2
  29. package/dist/cli/config.d.ts +16 -8
  30. package/dist/cli/index.d.ts +1 -1
  31. package/dist/cli/index.js +11133 -10103
  32. package/dist/cli/output.d.ts +2 -6
  33. package/dist/cloud/authorize.d.ts +12 -0
  34. package/dist/cloud/callback-server.d.ts +33 -0
  35. package/dist/cloud/callback.d.ts +23 -0
  36. package/dist/cloud/config.d.ts +23 -0
  37. package/dist/cloud/errors.d.ts +46 -0
  38. package/dist/cloud/index.d.ts +12 -0
  39. package/dist/cloud/models.d.ts +32 -0
  40. package/dist/cloud/oauth-login.d.ts +22 -0
  41. package/dist/cloud/pkce.d.ts +20 -0
  42. package/dist/cloud/provider.d.ts +40 -0
  43. package/dist/cloud/token.d.ts +22 -0
  44. package/dist/config/home.d.ts +6 -0
  45. package/dist/core.d.ts +10 -21
  46. package/dist/core.js +15272 -14207
  47. package/dist/datasource/chunk-store.d.ts +2 -6
  48. package/dist/datasource/connector-skill.d.ts +2 -3
  49. package/dist/datasource/index.d.ts +2 -4
  50. package/dist/datasource/registry.d.ts +11 -13
  51. package/dist/datasource/scope.d.ts +19 -0
  52. package/dist/datasource/skills/github-gist/index.d.ts +1 -1
  53. package/dist/datasource/skills/github-gist/semantic.d.ts +3 -44
  54. package/dist/datasource/skills/github-gist/skill.d.ts +3 -3
  55. package/dist/datasource/types.d.ts +14 -28
  56. package/dist/embedding-runtime/gateway-embedder.d.ts +41 -0
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.js +15488 -14359
  59. package/dist/language.d.ts +2 -1
  60. package/dist/mcp/index.js +15413 -14341
  61. package/dist/memory/check-memory-tool.d.ts +8 -4
  62. package/dist/memory/context.d.ts +51 -0
  63. package/dist/memory/index.d.ts +8 -1
  64. package/dist/memory/judged-evidence.d.ts +32 -0
  65. package/dist/memory/memory.d.ts +36 -120
  66. package/dist/memory/renderer.d.ts +16 -7
  67. package/dist/memory/similar-queries.d.ts +40 -0
  68. package/dist/minsync/client.d.ts +1 -1
  69. package/dist/minsync/errors.d.ts +14 -0
  70. package/dist/minsync/index.d.ts +1 -0
  71. package/dist/minsync/installer.d.ts +1 -1
  72. package/dist/minsync/method.d.ts +3 -3
  73. package/dist/mirror/sync.d.ts +5 -2
  74. package/dist/observability/run-log.d.ts +1 -1
  75. package/dist/parser/defaults.d.ts +16 -5
  76. package/dist/parser/index.d.ts +1 -1
  77. package/dist/parser/kordoc.d.ts +8 -1
  78. package/dist/parser/ocr-engines.d.ts +19 -0
  79. package/dist/retrieval/bm25.d.ts +19 -0
  80. package/dist/retrieval/engine.d.ts +17 -58
  81. package/dist/retrieval/index.d.ts +3 -2
  82. package/dist/retrieval/merger.d.ts +6 -0
  83. package/dist/retrieval/rerank.d.ts +2 -2
  84. package/dist/retrieval/selection.d.ts +33 -41
  85. package/dist/retrieval/types.d.ts +1 -26
  86. package/dist/web/search/format.d.ts +5 -2
  87. package/dist/web/search/index.d.ts +7 -1
  88. package/package.json +5 -5
  89. package/skills/autorag/SKILL.md +21 -22
  90. package/skills/autorag-doctor/SKILL.md +20 -15
  91. package/skills/autorag-lite-setup/SKILL.md +22 -19
  92. package/skills/autorag-setup/SKILL.md +34 -21
  93. package/dist/agent/fast-answer-tool.d.ts +0 -46
  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
@@ -2,29 +2,20 @@
2
2
  * RetrievalEngine — standalone typed seam for model-free retrieval.
3
3
  *
4
4
  * Wraps the existing retrieval pipeline (registry, parallel retriever,
5
- * datasource result filter, and merger) into a single public entry point.
5
+ * datasource scope filter, and merger) into a single public entry point.
6
6
  * Exposes a deterministic, self-contained retrieval API with diagnostics.
7
7
  *
8
- * Security invariants (delegated to {@link DatasourceAccessContext} and
9
- * {@link DatasourceResultFilter}):
10
- * - Access is default-deny: when no trusted allow-tags are configured,
11
- * every datasource method result is dropped.
12
- * - Deny is always an explicit empty result array, never `undefined`.
13
- * - Model/tool arguments (`allowedTags`, `allowedScopes`) cannot widen the
14
- * trusted access context constructed during engine creation.
8
+ * Every configured/connected datasource is searchable without permission
9
+ * setup. The ordinary query `scope` narrows scope-capable datasource results
10
+ * after retrieval; local (non-datasource) methods and datasources without
11
+ * source-scope support pass through untouched.
15
12
  */
16
- import { DatasourceAccessContext, type DatasourceAccessContextOptions } from "../datasource/access-context.js";
17
13
  import { RetrievalMethodRegistry } from "./registry.js";
18
14
  import { type Reranker } from "./rerank.js";
19
15
  import { type RetrievalSelection } from "./selection.js";
20
16
  import type { RetrievalDiagnostic, RetrievalMethod, RetrievalOptions, RetrievalResult, RetrievalUnsearchedSurface } from "./types.js";
21
17
  /** Options for constructing a standalone {@link RetrievalEngine}. */
22
18
  export interface RetrievalEngineOptions {
23
- /**
24
- * Datasource access configuration. Default-deny when omitted.
25
- * @default { allowedTags: undefined, allowedScopes: undefined }
26
- */
27
- readonly datasourceAccess?: DatasourceAccessContextOptions;
28
19
  /**
29
20
  * Default `topK` when the caller omits it. This is a safety ceiling on
30
21
  * merged evidence, not a relevance cut: the merger returns every distinct
@@ -35,21 +26,13 @@ export interface RetrievalEngineOptions {
35
26
  /** Default deduplication flag. @default true */
36
27
  readonly defaultDedup?: boolean;
37
28
  /**
38
- * Optional predicate that returns `true` when the MinSync binary is missing.
39
- * When set, the engine checks every method named `"minsync"`: if the binary
40
- * is unavailable the method returns empty results without throwing, the engine
41
- * emits a `minsync-unavailable` diagnostic with full method-agnostic path
42
- * preservation — matching the existing {@link AutoRAGAgent} behavior.
43
- */
44
- readonly isMinSyncBinaryMissing?: () => boolean;
45
- /**
46
- * Authorized datasource ids from the skill catalog, including datasources
29
+ * Configured datasource ids from the skill catalog, including datasources
47
30
  * that expose no retrieval methods. {@link retrieveSelected} uses this to
48
- * tell an unknown datasource id from an unauthorized one. When omitted, the
49
- * engine derives ids from its authorized registered methods; method-less
50
- * datasources are then treated as unknown.
31
+ * tell an unknown datasource id from a known one. When omitted, the engine
32
+ * derives ids from its registered methods; method-less datasources are then
33
+ * treated as unknown.
51
34
  */
52
- readonly authorizedDatasourceIds?: () => readonly string[];
35
+ readonly datasourceIds?: () => readonly string[];
53
36
  /**
54
37
  * Optional post-merge reranker. When set, merged results are reordered by
55
38
  * the reranker after dedup and score normalization. A reranker failure is
@@ -70,7 +53,7 @@ export interface RetrievalEngineOptions {
70
53
  * ```
71
54
  * methods = registry.list()
72
55
  * byMethod = retriever.retrieveWithDiagnostics(methods, query, options)
73
- * filtered = filter.filter(byMethod, methods, ctx, options.scope)
56
+ * filtered = filterDatasourceScope(byMethod, methods, options.scope)
74
57
  * merged = merger.merge(filtered, { topK, dedup: true }) // distinct chunks, pure duplicates dropped
75
58
  * → { results: merged, diagnostics }
76
59
  * ```
@@ -87,20 +70,15 @@ export interface RetrievalEngineOptions {
87
70
  export declare class RetrievalEngine {
88
71
  private readonly registry;
89
72
  private readonly retriever;
90
- private readonly filter;
91
73
  private readonly merger;
92
- private readonly accessContext;
93
74
  private readonly defaultTopK;
94
75
  private readonly defaultDedup;
95
- private readonly isMinSyncBinaryMissing;
96
- private readonly authorizedDatasourceIdsProvider;
76
+ private readonly datasourceIdsProvider;
97
77
  private readonly reranker;
98
78
  private readonly rerankTopN;
99
79
  constructor(options?: RetrievalEngineOptions);
100
80
  /** The underlying method registry. Intentionally public for tooling. */
101
81
  getMethodRegistry(): RetrievalMethodRegistry;
102
- /** The underlying datasource access context. Read-only for inspection. */
103
- getAccessContext(): DatasourceAccessContext;
104
82
  /**
105
83
  * Register a retrieval method. Overrides the registered-once check from
106
84
  * {@link RetrievalMethodRegistry} per caller requirement.
@@ -142,36 +120,17 @@ export declare class RetrievalEngine {
142
120
  }>;
143
121
  /**
144
122
  * Run a selected subset of the registered methods — parallel retrieve,
145
- * datasource filter, merge — and return merged results with diagnostics.
123
+ * scope filter, merge — and return merged results with diagnostics.
146
124
  *
147
125
  * Unlike {@link retrieve}, selection happens BEFORE any backend is invoked:
148
- * the eligible method list is reduced first, so an unselected or
149
- * unauthorized datasource backend is never spawned. Unknown or unauthorized
150
- * method/datasource selections throw {@link RetrievalSelectionError}. The
151
- * trusted access context still narrows results/tags/scopes after retrieval.
126
+ * the eligible method list is reduced first, so an unselected datasource
127
+ * backend is never spawned. Unknown method or datasource selections throw
128
+ * {@link RetrievalSelectionError}. The ordinary query `scope` still narrows
129
+ * results after retrieval.
152
130
  */
153
131
  retrieveSelected(query: string, selection?: RetrievalSelection, options?: RetrievalOptions): Promise<{
154
132
  results: RetrievalResult[];
155
133
  diagnostics: RetrievalDiagnostic[];
156
134
  unsearched: RetrievalUnsearchedSurface[];
157
135
  }>;
158
- /**
159
- * Post-check for MinSync binary-missing diagnostic.
160
- *
161
- * When a registered method named `"minsync"` fails to throw (the method returns
162
- * `[]` because the binary is missing), {@link ParallelRetriever} cannot record
163
- * a diagnostic. This method checks whether the minsync binary is unavailable
164
- * and emits a `minsync-unavailable` diagnostic when every minsync method's
165
- * result set is empty, exactly matching the existing {@link AutoRAGAgent}
166
- * behavior (see `agent.src/agent/agent.ts` `retrieveWithDiagnostics`). The
167
- * same check reports the MinSync surface as unsearched, so a caller reading
168
- * only the skip report still learns that local sources were not queried.
169
- */
170
- private appendMinSyncUnavailable;
171
- /**
172
- * Build a datasource access context scoped to the caller's options.
173
- * Model/tool arguments (allowedTags, allowedScopes) from options can only
174
- * further restrict the trusted context, never widen it.
175
- */
176
- private accessContextFor;
177
136
  }
@@ -1,9 +1,10 @@
1
+ export { bm25Scores, tokenize } from "./bm25.js";
1
2
  export { RetrievalEngine, type RetrievalEngineOptions } from "./engine.js";
2
3
  export type { MergeOptions } from "./merger.js";
3
4
  export { ParallelRetriever, ResultMerger } from "./merger.js";
4
5
  export { RetrievalMethodRegistry } from "./registry.js";
5
6
  export { type CreateRerankerOptions, createReranker, DEFAULT_RERANK_API_KEY_ENV, DEFAULT_RERANK_MODEL, DEFAULT_RERANK_PROVIDER, DEFAULT_RERANK_TOP_N, OpenRouterReranker, type OpenRouterRerankerOptions, type Reranker, type RerankerDescriptor, type RerankOptions, SUPPORTED_RERANK_PROVIDERS, } from "./rerank.js";
6
7
  export { matchesVirtualPathScope, normalizeVirtualPath, normalizeVirtualPathScope, virtualPathScopeToRegExp, } from "./scope.js";
7
- export { type DatasourceCatalogEntry, derivedAuthorizedDatasourceIds, type RetrievalSelection, RetrievalSelectionError, type RetrievalSelectionErrorCode, resolveSelectedMethods, } from "./selection.js";
8
+ export { type DatasourceCatalogEntry, derivedDatasourceIds, type RetrievalSelection, RetrievalSelectionError, type RetrievalSelectionErrorCode, resolveSelectedMethods, } from "./selection.js";
8
9
  export { describeRetrievalError, groupUnsearchedSurfaces, MINSYNC_SURFACE, type RetrievalSkip, retrievalSurfaceFor, } from "./skip.js";
9
- export type { CuratedResult, NumberedResult, RetrievalDiagnostic, RetrievalDiagnosticCode, RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult, RetrievalUnsearchedSurface, RetrievalWithDiagnostics, } from "./types.js";
10
+ export type { RetrievalDiagnostic, RetrievalDiagnosticCode, RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult, RetrievalUnsearchedSurface, RetrievalWithDiagnostics, } from "./types.js";
@@ -30,6 +30,12 @@ export interface MergeOptions {
30
30
  export declare class ResultMerger {
31
31
  merge(results: Map<string, RetrievalResult[]>, options: MergeOptions): RetrievalResult[];
32
32
  }
33
+ /**
34
+ * Runs every method in parallel. A method that throws is skipped and the
35
+ * others still answer, with one exception: {@link MinSyncRequiredError} means
36
+ * the required MinSync is absent, so the whole retrieval fails instead of
37
+ * returning an answer that silently lacks its content search.
38
+ */
33
39
  export declare class ParallelRetriever {
34
40
  retrieve(methods: RetrievalMethod[], query: string, options: RetrievalOptions): Promise<Map<string, RetrievalResult[]>>;
35
41
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Reranker seam — a post-retrieval reordering stage over merged evidence.
3
3
  *
4
- * The retrieval pipeline (registry → ParallelRetriever → DatasourceResultFilter
4
+ * The retrieval pipeline (registry → ParallelRetriever → filterDatasourceScope
5
5
  * → ResultMerger) produces a scored candidate list. A reranker reorders that
6
6
  * list with a dedicated relevance model. The default implementation talks to
7
7
  * OpenRouter's rerank router through the OpenRouter TypeScript SDK.
@@ -28,7 +28,7 @@ export interface RerankerDescriptor {
28
28
  readonly name: string;
29
29
  /** Provider id (e.g. `openrouter`). */
30
30
  readonly provider: string;
31
- /** Wire model id (e.g. `cohere/rerank-4-fast`). */
31
+ /** Wire model id (e.g. `voyageai/rerank-3`). */
32
32
  readonly model: string;
33
33
  /** Whether the reranker has everything it needs to run (credentials, config). */
34
34
  readonly available: boolean;
@@ -4,26 +4,20 @@
4
4
  * `searchSelected` lets a caller narrow a search to specific datasources,
5
5
  * specific methods, or the local (non-datasource) surfaces *before* any backend
6
6
  * is invoked. This module owns that narrowing so the engine can reuse its
7
- * existing parallel-retrieve / datasource-filter / merge chain on the reduced
7
+ * existing parallel-retrieve / scope-filter / merge chain on the reduced
8
8
  * method list instead of fanning out to every backend and filtering afterwards.
9
9
  *
10
- * Security invariants:
11
- * - Unauthorized datasource methods are never selected, whether or not the
12
- * caller passed a selection — an unselected search still excludes them, so
13
- * no denied backend is executed.
14
- * - A caller-supplied selection can only *narrow* the trusted method set; it
15
- * can never widen it. Unknown or unauthorized method/datasource names are
16
- * rejected with a typed error, never silently resolved.
17
- * - The trusted {@link DatasourceAccessContext} remains the sole authority:
18
- * the `authorizedDatasourceIds` catalog is itself built from that context.
10
+ * Every configured datasource is searchable without permission setup. A
11
+ * caller-supplied selection can only *narrow* the registered method set: it can
12
+ * never add a method that is not registered. Unknown method or datasource names
13
+ * are rejected with a typed error, never silently resolved.
19
14
  */
20
- import type { DatasourceAccessContext } from "../datasource/access-context.js";
21
15
  import type { RetrievalMethod } from "./types.js";
22
16
  /**
23
- * Model-free, credential-free descriptor of one authorized configured
24
- * datasource, for catalog/listing surfaces. Carries no credentials, config
25
- * paths, or raw instance metadata — only the identity, capability tags, and
26
- * the opaque source scope strings the access context authorizes.
17
+ * Model-free, credential-free descriptor of one configured datasource, for
18
+ * catalog/listing surfaces. Carries no credentials, config paths, or raw
19
+ * instance metadata — only the identity, descriptive tags, and the opaque
20
+ * source scope strings the datasource exposes.
27
21
  */
28
22
  export interface DatasourceCatalogEntry {
29
23
  /** Stable datasource id, e.g. `"kakao"`. */
@@ -34,39 +28,39 @@ export interface DatasourceCatalogEntry {
34
28
  readonly type: string;
35
29
  /** Human-readable description. */
36
30
  readonly description: string;
37
- /** Authorization tags that made this datasource accessible. */
31
+ /** Descriptive tags (metadata only). */
38
32
  readonly tags: readonly string[];
39
33
  /** Capability names such as `"keyword"`, `"scoped"`, `"polling"`. */
40
34
  readonly capabilities: readonly string[];
41
35
  readonly status: "active" | "stub";
42
36
  /**
43
- * Authorized slash-hierarchical source scope strings discovered for this
44
- * datasource. Scope-capable datasources expose only sources allowed by the
45
- * trusted scope predicate; unscoped datasources expose their opaque sources.
37
+ * Slash-hierarchical source scope strings discovered for this datasource.
38
+ * Scope-capable datasources expose their instance source scopes; unscoped
39
+ * datasources expose their opaque sources.
46
40
  */
47
41
  readonly sourceScopes: readonly string[];
48
42
  }
49
43
  /**
50
44
  * Caller request narrowing which retrieval methods run.
51
45
  *
52
- * Semantics (unambiguous, deny-widening):
53
- * - `datasourceIds` omitted ⇒ every authorized datasource method is eligible.
46
+ * Semantics (unambiguous, narrowing-only):
47
+ * - `datasourceIds` omitted ⇒ every datasource method is eligible.
54
48
  * - `datasourceIds` present ⇒ ONLY methods of those datasources are eligible,
55
49
  * plus the local (non-datasource) methods only when `local === true`.
56
50
  * - `local === false` ⇒ no local method is ever eligible.
57
51
  * - `methods` present ⇒ intersected with the eligible set; every named method
58
- * must exist and (for datasource methods) be authorized.
52
+ * must exist.
59
53
  */
60
54
  export interface RetrievalSelection {
61
- /** Datasource ids to run. Omit to run all authorized datasources. */
55
+ /** Datasource ids to run. Omit to run all configured datasources. */
62
56
  readonly datasourceIds?: readonly string[];
63
57
  /** Method names to run, intersected with the datasource/local selection. */
64
58
  readonly methods?: readonly string[];
65
59
  /** Whether local (non-datasource) methods run. See the semantics above. */
66
60
  readonly local?: boolean;
67
61
  }
68
- export type RetrievalSelectionErrorCode = "unknown-method" | "unauthorized-method" | "unknown-datasource" | "unauthorized-datasource";
69
- /** Thrown when a caller selection names an unknown or unauthorized target. */
62
+ export type RetrievalSelectionErrorCode = "unknown-method" | "unknown-datasource";
63
+ /** Thrown when a caller selection names an unknown method or datasource. */
70
64
  export declare class RetrievalSelectionError extends Error {
71
65
  readonly code: RetrievalSelectionErrorCode;
72
66
  constructor(code: RetrievalSelectionErrorCode, message: string);
@@ -75,23 +69,21 @@ export declare class RetrievalSelectionError extends Error {
75
69
  * Reduce the registered methods to the ones a selection authorizes to run.
76
70
  *
77
71
  * The returned list is built entirely from `methods`; a caller cannot conjure a
78
- * method that is not registered. Datasource methods denied by `ctx` are dropped
79
- * from the eligible set unconditionally, so they are never invoked. Explicit
80
- * selections that name an unknown method or an unauthorized/unknown datasource
81
- * throw {@link RetrievalSelectionError} rather than degrading silently.
72
+ * method that is not registered. Explicit selections that name an unknown
73
+ * method or an unknown datasource throw {@link RetrievalSelectionError} rather
74
+ * than degrading silently.
82
75
  *
83
- * @param methods Every registered retrieval method.
84
- * @param ctx Trusted, server-supplied access context.
85
- * @param selection Caller narrowing request.
86
- * @param authorizedDatasourceIds Authorized datasource ids from the catalog;
87
- * used to distinguish an unknown id from an unauthorized one. Method-less
88
- * authorized datasources belong here and select cleanly (yielding nothing).
76
+ * @param methods Every registered retrieval method.
77
+ * @param selection Caller narrowing request.
78
+ * @param datasourceIds Configured datasource ids (from the catalog), used to
79
+ * distinguish a known datasource from an unknown one. Method-less
80
+ * datasources belong here and select cleanly (yielding nothing).
89
81
  */
90
- export declare function resolveSelectedMethods(methods: readonly RetrievalMethod[], ctx: DatasourceAccessContext, selection: RetrievalSelection, authorizedDatasourceIds: readonly string[]): RetrievalMethod[];
82
+ export declare function resolveSelectedMethods(methods: readonly RetrievalMethod[], selection: RetrievalSelection, datasourceIds: readonly string[]): RetrievalMethod[];
91
83
  /**
92
- * Authorized datasource ids derived directly from a method set and access
93
- * context. Used as the fallback catalog for a standalone engine that has no
94
- * datasource-skill catalog wired in; method-less datasources are unknowable
95
- * here and therefore treated as unknown.
84
+ * Configured datasource ids derived directly from a method set. Used as the
85
+ * fallback catalog for a standalone engine that has no datasource-skill catalog
86
+ * wired in; method-less datasources are unknowable here and therefore treated
87
+ * as unknown.
96
88
  */
97
- export declare function derivedAuthorizedDatasourceIds(methods: readonly RetrievalMethod[], ctx: DatasourceAccessContext): string[];
89
+ export declare function derivedDatasourceIds(methods: readonly RetrievalMethod[]): string[];
@@ -18,15 +18,13 @@ export interface RetrievalOptions {
18
18
  topK?: number;
19
19
  scope?: string;
20
20
  filters?: Record<string, unknown>;
21
- allowedTags?: readonly string[];
22
- allowedScopes?: readonly string[];
23
21
  signal?: AbortSignal;
24
22
  }
25
23
  export interface RetrievalMethod {
26
24
  describe(): RetrievalMethodDescriptor;
27
25
  retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
28
26
  }
29
- export type RetrievalDiagnosticCode = "retrieval-method-failed" | "minsync-unavailable" | "rerank-failed";
27
+ export type RetrievalDiagnosticCode = "retrieval-method-failed" | "rerank-failed";
30
28
  /**
31
29
  * A retrieval surface (local MinSync files or one datasource) that was not
32
30
  * searched for this query. Reported next to partial results so a caller that
@@ -60,26 +58,3 @@ export interface RetrievalWithDiagnostics {
60
58
  /** Surfaces that were not searched for this query. Empty when every method ran. */
61
59
  unsearched: RetrievalUnsearchedSurface[];
62
60
  }
63
- export interface NumberedResult {
64
- index: number;
65
- source: string;
66
- content: string;
67
- method: string;
68
- }
69
- export interface EvidenceReference {
70
- method: string;
71
- source: string;
72
- excerpt?: string;
73
- content?: string;
74
- retrievalResultId?: string;
75
- chunkIndex?: number;
76
- lineNumber?: number;
77
- stableEvidenceId: string;
78
- }
79
- export interface CuratedResult {
80
- index: number;
81
- content: string;
82
- source: string;
83
- method: string;
84
- evidenceRefs?: readonly EvidenceReference[];
85
- }
@@ -18,8 +18,11 @@ export declare const WEB_SEARCH_SYSTEM_PROMPT = "Web research assistant: accurat
18
18
  export declare const WEB_SEARCH_TOOL_DESCRIPTION = "Web search: current information beyond knowledge cutoff.\n\n- SHOULD prefer primary sources (papers, official docs); corroborate key claims with multiple sources.\n- MUST link cited sources in final response.\n- NEVER use for programmatically accessible content or known URLs (GitHub repos/issues, known arXiv papers, Wikipedia pages, official docs) \u2014 use web_fetch on the URL directly.\n- `query`: every provider supports Google-style `site:`/`-site:`, `after:`/`before:` (YYYY-MM-DD), `inurl:`, `intitle:`, `filetype:`, `\"exact phrase\"`, `-term`, `OR`. Map constraints to native filters when available; otherwise results are filtered leniently. If a constraint matches nothing, it is relaxed and reported; zero results are never forced.";
19
19
  /** Format an age in seconds as a compact relative string ("45s", "2h", "3d"). */
20
20
  export declare function formatAge(ageSeconds: number | undefined): string;
21
- /** Format response for LLM consumption. `notes` lead the output (e.g. relaxed-constraint warnings). */
22
- export declare function formatForLLM(response: SearchResponse, notes?: readonly string[]): string;
21
+ /**
22
+ * Format response for LLM consumption. `notes` lead the output (e.g. relaxed-constraint warnings).
23
+ * `sourceLabels` replaces the positional `[n]` of each source (e.g. `e3`) so the model can cite it by id.
24
+ */
25
+ export declare function formatForLLM(response: SearchResponse, notes?: readonly string[], sourceLabels?: readonly string[]): string;
23
26
  /**
24
27
  * `true` when the response carries an actual result the caller can read: an
25
28
  * answer, a source, or a citation. Search-attempt metadata (`searchQueries`,
@@ -1,5 +1,5 @@
1
1
  import type { ModelNativeSearchAuth } from "./model-auth.js";
2
- import { type SearchProviderId, type SearchResponse } from "./types.js";
2
+ import { type SearchProviderId, type SearchResponse, type SearchSource } from "./types.js";
3
3
  export interface WebSearchQueryParams {
4
4
  query: string;
5
5
  recency?: "day" | "week" | "month" | "year";
@@ -38,6 +38,12 @@ export interface WebSearchExecuteOptions {
38
38
  modelAuth?: ModelNativeSearchAuth;
39
39
  /** Transport injection for tests/proxies; forwarded to providers that accept it. */
40
40
  fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
41
+ /**
42
+ * Called with the sources that survived filtering, just before formatting.
43
+ * Returns one label per source (e.g. an evidence id) that replaces its
44
+ * positional `[n]` in the output the model reads.
45
+ */
46
+ labelSources?: (sources: readonly SearchSource[]) => readonly string[];
41
47
  }
42
48
  /** Execute a web search through the provider fallback chain. */
43
49
  export declare function executeWebSearch(params: WebSearchQueryParams, options?: WebSearchExecuteOptions): Promise<WebSearchExecuteResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorag/librarian",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "Self-evolving librarian agent on Pi framework with pluggable retrieval methods",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -51,10 +51,10 @@
51
51
  "node": ">=24.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "@earendil-works/pi-agent-core": "^0.86.1",
55
- "@earendil-works/pi-ai": "^0.86.1",
56
- "@earendil-works/pi-coding-agent": "0.86.1",
57
- "@earendil-works/pi-tui": "0.86.1",
54
+ "@earendil-works/pi-agent-core": "^1.1.0",
55
+ "@earendil-works/pi-ai": "^1.1.0",
56
+ "@earendil-works/pi-coding-agent": "1.1.0",
57
+ "@earendil-works/pi-tui": "1.1.0",
58
58
  "@modelcontextprotocol/server": "^2.3.0",
59
59
  "@openrouter/sdk": "^1.4.21",
60
60
  "chardet": "^2.2.0",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: autorag
3
- description: Search, summarize, compare, and answer questions from an already configured AutoRAG librarian over local documents and authorized datasources. Use when the user asks AutoRAG to search PDFs, wikis, notes, or a knowledge base. Use autorag-setup for install, model, roots, indexing, or datasource changes.
3
+ description: Search, summarize, compare, and answer questions from an already configured AutoRAG librarian over local documents and configured datasources. Use when the user asks AutoRAG to search PDFs, wikis, notes, or a knowledge base. Use autorag-setup for install, model, roots, indexing, or datasource changes.
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -8,7 +8,7 @@ license: MIT
8
8
 
9
9
  Use this skill when AutoRAG is already configured and the user asks to search,
10
10
  summarize, compare, or answer questions from local PDFs, wikis, notes, research
11
- papers, knowledge bases, or authorized datasources.
11
+ papers, knowledge bases, or configured datasources.
12
12
 
13
13
  AutoRAG is the specialized librarian agent. One configured model plans the
14
14
  search, calls MinSync, Jikji, datasource, and filesystem tools, reads
@@ -66,17 +66,17 @@ lexical-only search.
66
66
 
67
67
  ## Search
68
68
 
69
- Prefer `--json --debug` when another agent will consume the result or record
70
- feedback. `--json` alone omits `sessionId`. `--debug` adds session/diagnostics
71
- fields and does not print filesystem paths.
69
+ Prefer `--json --debug` when another agent will consume the result.
70
+ `--json` alone omits `sessionId`. `--debug` adds session/diagnostics fields and
71
+ does not print filesystem paths.
72
72
 
73
73
  ```bash
74
74
  autorag search "what were the key findings in the Q3 report" --top-k 5 --json --debug
75
75
  ```
76
76
 
77
77
  `--json --debug` includes `answer`, numbered `results` (`number`, `title`,
78
- `summary`, optional `source`), and `sessionId`. Use that `sessionId` for
79
- feedback. `--json` without `--debug` is only `answer` plus `results`. Every
78
+ `summary`, optional `source`), and `sessionId`. `--json` without `--debug` is
79
+ only `answer` plus `results`. Every
80
80
  bracketed `[n]` citation in `answer` resolves to a `results[].number` of the
81
81
  same response; an unmatched citation is removed and reported as a
82
82
  `citation-without-result` diagnostic.
@@ -93,10 +93,8 @@ ID, raw excerpt/content, and any available `chunkIndex`, `lineNumber`,
93
93
  the session. Prefer this command whenever the caller wants detailed chunk text
94
94
  rather than only the curated summary.
95
95
 
96
- - `--scope` narrows datasource retrieval to a requested sub-path; it cannot
97
- grant access.
98
- - `--tags` further narrows already-authorized datasource results and never
99
- grants new access.
96
+ - `--scope` narrows datasource retrieval to a requested sub-path (ordinary
97
+ per-query filtering).
100
98
  - `--json` is required for programmatic consumption.
101
99
  - `--debug` is required for `sessionId` and diagnostics in search output.
102
100
  - `autorag evidence` is the detailed source/chunk inspection path.
@@ -110,22 +108,24 @@ Every search is two-phase: a fast answer, then verification. With Jev on (the
110
108
  default, OpenRouter), Jev first routes the question:
111
109
 
112
110
  - General knowledge or small talk is answered directly.
111
+ - A request to view or change AutoRAG's own settings (model, providers,
112
+ datasources) is handled by the agent itself: it loads the setup skill, edits
113
+ the active config, verifies it, and reports what changed. The running agent
114
+ keeps its startup model; changes apply to the next `autorag` launch.
113
115
  - Private-data questions use local search; public current facts use web search.
114
116
  - A multi-part question is split into up to five parallel search queries.
117
+ - On local search, Jev also picks which registered datasources (Slack,
118
+ Discord, KakaoTalk, email, ...) to search before the fast answer, from each
119
+ datasource's description and where similar past questions were answered;
120
+ their chunks are reranked together with local file evidence.
115
121
 
116
122
  After the fast answer, Jev ends the run if the answer is complete and
117
123
  evidence-backed. So `results` may come straight from the fast answer, with no
118
124
  verification phase. `--debug` diagnostics show the decision: `query-routed`
119
- (branch and queries), `follow-up-skipped` (fast answer final), or
125
+ (branch and queries), `datasources-selected` (datasources searched or skipped,
126
+ with probabilities), `follow-up-skipped` (fast answer final), or
120
127
  `query-route-fallback` (Jev unavailable, single local search).
121
128
 
122
- Record feedback so retrieval memory can learn. Numbers refer to the returned
123
- knowledge units. Supply at least one feedback list:
124
-
125
- ```bash
126
- autorag feedback <sessionId> --useful 1,3 --not-useful 2 --json
127
- ```
128
-
129
129
  ## Maintenance
130
130
 
131
131
  ```bash
@@ -165,9 +165,8 @@ Never target source documents. `memory inspect` is read-only and path-opaque.
165
165
  - Never expose provider credentials or authentication payloads.
166
166
  - Never invent provider identities or model ids.
167
167
  - A Pi-usable subscription is valid; a subscription Pi cannot invoke is not.
168
- - Preserve real source mapping and numbered feedback identifiers.
169
- - Prefer `--json --debug` when another agent consumes search output or will
170
- call `autorag feedback`.
168
+ - Preserve real source mapping.
169
+ - Prefer `--json --debug` when another agent consumes search output.
171
170
  - Do not invent CLI commands. `autorag --help` is the command list of record,
172
171
  including the shipped `setup`, `gateway`, `models`, `serve`, `p2p`, `tui`, and `lite`
173
172
  commands. `autorag <command> --help` prints that command's own flags, and
@@ -43,7 +43,7 @@ autorag gateway status --format json
43
43
 
44
44
  Config lives at `--config`, `AUTORAG_CONFIG`, `$AUTORAG_HOME/config.json`, or
45
45
  `~/.autorag/config.json`. Read `searchPaths`, `workspacePath`, `minSync`,
46
- `jikji`, `datasources`, and `datasourceAccess` before changing anything.
46
+ `jikji`, and `datasources` before changing anything.
47
47
 
48
48
  If the CLI itself is missing or the config does not exist, stop and run the
49
49
  `autorag-setup` skill first — doctor repairs an existing install, it does not
@@ -93,7 +93,7 @@ through the model-free MCP tools, then once end to end:
93
93
  ```text
94
94
  autorag.status {}
95
95
  autorag.search {"query":"a word that certainly appears","topK":3}
96
- autorag.search {"query":"recent topic","tags":["discord"],"topK":3}
96
+ autorag.search {"query":"recent topic","datasourceIds":["discord"],"topK":3}
97
97
  autorag.search {"query":"recent mail subject","scope":"/mailcrawl/**","topK":3}
98
98
  ```
99
99
 
@@ -103,8 +103,8 @@ autorag search "summarize the collection" --top-k 3 --json --debug
103
103
 
104
104
  - **Always read the `diagnostics` returned by MCP `autorag.search`.** A run
105
105
  that silently dropped a whole retrieval method still looks successful, just
106
- with fewer results; only the diagnostics name it (`minsync-unavailable`,
107
- `retrieval-method-failed`). The model-backed CLI `autorag search --json`
106
+ with fewer results; only the diagnostics name it (`retrieval-method-failed`).
107
+ The model-backed CLI `autorag search --json`
108
108
  hides `diagnostics`, `sessionId`, and per-result evidence unless `--debug` is
109
109
  set, so pass `--debug` when diagnosing that path.
110
110
  - A method missing from the returned `method` values means that method
@@ -114,10 +114,11 @@ autorag search "summarize the collection" --top-k 3 --json --debug
114
114
  treating it as a failure, and never kill a running sync to "fix" it.
115
115
  - MCP `autorag.search` needs no model, so it isolates retrieval from model
116
116
  failures.
117
- - Use the MCP `tags` / `scope` arguments to force one datasource; they can only
118
- narrow trusted access, never grant it. A datasource absent from
119
- `datasourceAccess` returns nothing no matter how healthy its store is — fix
120
- the config, not the store.
117
+ - Use MCP `datasourceIds` to select configured connections before retrieval;
118
+ `scope` narrows results within scope-capable datasources. Discover connection
119
+ IDs with `autorag.datasources.list`; descriptor tags are metadata only, not
120
+ search filters. Every configured connection is searchable — if one returns
121
+ nothing, investigate its native store, connector, or the query itself.
121
122
  - `autorag.evidence {"sessionId":"...","resultNumber":N}` shows the exact chunk
122
123
  behind a numbered result; use it to confirm a hit is real and its source is
123
124
  readable. The CLI `autorag evidence SESSION --json` remains for terminal
@@ -197,13 +198,16 @@ timer, or Task Scheduler).
197
198
  no `"type"`. It is skipped, not fatal — fix the name or add `"type"`.
198
199
  - `datasource-index-failed` / `sync-failed`: the backing CLI errored. Run that
199
200
  CLI's own check from the table above and fix it there.
200
- - `minsync-unavailable` / `jikji-unavailable`: the binary is missing and
201
- auto-install failed. Both install through cargo; verify the Rust toolchain,
202
- then `autorag refresh --method minsync` to retry.
201
+ - A missing MinSync binary is not a diagnostic: `autorag search`, `autorag refresh`
202
+ and MCP tools fail with `MinSync is required ...` and a non-zero exit. Install it
203
+ (`cargo install minsync`) or leave `minSync.autoInstall` on, then retry.
204
+ - `jikji-unavailable`: the binary is missing and auto-install failed. It
205
+ installs through cargo; verify the Rust toolchain, then `autorag refresh --method jikji` to retry.
203
206
  - `auth-error` / `rate-limited`: model or datasource credentials. Report the
204
207
  missing environment-variable **name** and let the user supply it.
205
- - A datasource configured but not listed in `datasourceAccess.allowedTags` /
206
- `allowedScopes` is default-denied and invisible to search. Add it there.
208
+ - A configured datasource that returns nothing is a native store, connector, or
209
+ query problem — every configured connection is searchable. Run its native
210
+ check from the table above and fix it there.
207
211
 
208
212
  ## Diagnostic codes
209
213
 
@@ -211,7 +215,7 @@ timer, or Task Scheduler).
211
215
  |---|---|---|
212
216
  | `stale-index` | Sources changed since last refresh | `autorag refresh --method parsed,minsync` |
213
217
  | `index-not-ready` | Index missing or never built | `autorag refresh --json` |
214
- | `minsync-unavailable` | MinSync binary missing or install failed | Check cargo, retry refresh |
218
+ | `minsync-sync-failed` | MinSync indexing failed; the message carries MinSync's own reason | Fix the reported cause, then `autorag refresh --method minsync` |
215
219
  | `jikji-unavailable` | Jikji binary missing or install failed | Check cargo, retry refresh |
216
220
  | `everything-index-failed` | Windows Everything instance could not start or index; message carries ES exit code and stderr | Fix the reported cause, `autorag refresh --method everything --json` |
217
221
  | `embedding-identity-mismatch` | Indexed vectors use a different embedder | `autorag index rebuild --method minsync` |
@@ -225,7 +229,8 @@ timer, or Task Scheduler).
225
229
  | `query-route-fallback` | Jev routing unavailable (often `OPENROUTER_API_KEY` unset); searched local with the original question | `test -n "$OPENROUTER_API_KEY"`; report the env var name, never its value |
226
230
  | `query-decomposition-failed` | Decomposition model call failed; searched the original question | Check `queryDecomposition.model` resolves (`autorag models list --provider openrouter`) |
227
231
  | `follow-up-check-fallback` | Jev post-fast-answer check unavailable; the run verified | Same as `query-route-fallback` |
228
- | `query-routed` / `follow-up-skipped` | Info: Jev's branch and queries / fast answer judged final | None; working as intended |
232
+ | `datasource-selection-fallback` | Jev datasource check unavailable; no datasource was searched before the fast answer | Same as `query-route-fallback` |
233
+ | `query-routed` / `datasources-selected` / `follow-up-skipped` | Info: Jev's branch and queries / datasources searched and skipped / fast answer judged final | None; working as intended. A datasource that is never selected usually needs a clearer `description` in the config |
229
234
 
230
235
  ## Report
231
236