@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
@@ -14,7 +14,7 @@ Use `autorag-setup` instead when the model-backed librarian must be configured.
14
14
  ## Safety
15
15
 
16
16
  - Inspect only non-secret config metadata: `searchPaths`, `workspacePath`,
17
- `memoryPath`, `minSync`, `jikji`, `datasources`, `datasourceAccess`.
17
+ `memoryPath`, `minSync`, `jikji`, `datasources`.
18
18
  - Never print, copy, migrate, compare, or persist credential values. Store only
19
19
  environment-variable names such as `tokenEnv` or `apiKeyEnv`.
20
20
  - Never move, rename, edit, or delete source documents. Lite commands write
@@ -98,7 +98,7 @@ integrated datasources add their own search tools; do not assume a fixed count.
98
98
  Run `autorag.status` and `autorag.datasources.list` through MCP, then refresh
99
99
  and search a known phrase from an approved document. Registration alone is
100
100
  not proof of a connected or searchable server. After config changes, restart
101
- the server so datasource tools and authorization are rebuilt.
101
+ the server so datasource tools are rebuilt.
102
102
 
103
103
  `AUTORAG_MCP_READ_ONLY=1` omits refresh; build indexes with the CLI before
104
104
  connecting that mode. `AUTORAG_MCP_TOOLS` is an optional comma-separated exact
@@ -120,7 +120,7 @@ setup. Configure datasources directly in trusted config, wizard-style:
120
120
  (such as `github`) require their credential environment variable
121
121
  (`GITHUB_TOKEN`).
122
122
  2. Auto-configure every datasource that probes feasible — write its trusted
123
- `datasources` / `datasourceAccess` entries without asking. For example,
123
+ `datasources` entries without asking. For example,
124
124
  when Slack (`slacrawl`) and Discord (`discrawl`) are installed with local
125
125
  stores present, set both up automatically. Discord uses discrawl's local
126
126
  desktop wiretap archive; no Discord bot token is configured or needed.
@@ -133,15 +133,17 @@ setup. Configure datasources directly in trusted config, wizard-style:
133
133
  users — always probe them and report their status, even when they end up
134
134
  skipped.
135
135
 
136
- Datasource skills belong in trusted config and remain default-deny.
136
+ Datasource skills belong in trusted config.
137
137
 
138
138
  Config keys may be builtin template names (`kakao`, `whatsapp`, `telegram`,
139
139
  `slack`, `discord`, `clawgallery`, `notion`, `github`, `cloud-drive`,
140
140
  `mail-export`, `mailcrawl`, `obsidian`, `rss`, `spotlight`, `lark`) or connection
141
141
  aliases with `"type": "<template>"`. Unknown names are skipped with an
142
142
  `unknown-datasource-skill` warning; they do not fail config resolution.
143
- `datasourceAccess.allowedTags` and `allowedScopes` narrow trusted access and
144
- can never grant it. Store only env-var names such as `tokenEnv` or
143
+ `scope` narrows a query to a sub-path as ordinary filtering. Tags are
144
+ descriptive metadata only, not search filters. Use MCP `datasourceIds` to
145
+ select configured connections before retrieval; discover their IDs with
146
+ `autorag.datasources.list`. Store only env-var names such as `tokenEnv` or
145
147
  `apiKeyEnv`, never credential values.
146
148
 
147
149
  ## Build and refresh indexes
@@ -167,7 +169,7 @@ AUTORAG_CONFIG=/absolute/path/to/.autorag/config.json autorag lite refresh --jso
167
169
  are missing or broken, run a full refresh or return to setup rather than
168
170
  silently degrading to lexical-only search.
169
171
  - MinSync's default embedder is in-process native Qwen3 embeddings
170
- (`native:Qwen/Qwen3-Embedding-0.6B`, 1024 dimensions, MinSync 0.4.5+): no
172
+ (`native:Qwen/Qwen3-Embedding-0.6B`, 1024 dimensions, MinSync 0.4.6): no
171
173
  embedder flags, no API key, and no external daemon (such as Ollama) are
172
174
  needed, and no corpus text leaves the machine. For gateway-profiled
173
175
  embeddings, prefetch with `autorag models prefetch --profile qwen3-embedding-0.6b`.
@@ -224,23 +226,24 @@ AUTORAG_CONFIG=/absolute/path/to/.autorag/config.json autorag lite index reset -
224
226
  Inspect MCP `isError`, `errorCode`, `diagnostics`, and `unsearched` before
225
227
  trusting results. `ok: true` with skipped surfaces is partial coverage, not
226
228
  proof that the whole corpus was searched. Preserve the underlying error text
227
- when reporting unavailable components such as `minsync-unavailable` or
228
- `retrieval-method-failed`. Repair the component rather than silently accepting
229
- degraded search.
229
+ when reporting unavailable components such as `retrieval-method-failed`.
230
+ MinSync is required: when its binary is missing the call fails with an
231
+ `MinSync is required ...` error rather than returning partial results, so
232
+ install it (`cargo install minsync`) instead of working around it. Repair the
233
+ component rather than silently accepting degraded search.
230
234
 
231
235
  ## Normal MCP workflow and curation lifecycle
232
236
 
233
237
  MCP results carry source, method, and content directly. After a search, the
234
238
  optional curation lifecycle is also exposed through MCP: `autorag.report`
235
- records a curated answer, `autorag.evidence` returns the exact chunks behind
236
- numbered results, and `autorag.feedback` records which numbers were useful or
237
- not. These accept and return JSON matching the CLI's report/evidence/feedback
238
- contracts; discover the exact schemas with MCP `tools/list` rather than
239
- restating them here. Every bracketed `[n]` citation in a report `answer` must
240
- be a `results[].number`; an unmatched citation is removed from the persisted
241
- answer and returned as a `citation-without-result` diagnostic. The CLI
242
- `autorag report`, `autorag evidence`, and `autorag feedback` commands remain
243
- available for terminal maintenance.
239
+ records a curated answer, and `autorag.evidence` returns the exact chunks behind
240
+ numbered results. These accept and return JSON matching the CLI's
241
+ report/evidence contracts; discover the exact schemas with MCP `tools/list`
242
+ rather than restating them here. Every bracketed `[n]` citation in a report
243
+ `answer` must be a `results[].number`; an unmatched citation is removed from
244
+ the persisted answer and returned as a `citation-without-result` diagnostic.
245
+ The CLI `autorag report` and `autorag evidence` commands remain available for
246
+ terminal maintenance.
244
247
 
245
248
  ## Completion condition
246
249
 
@@ -46,7 +46,7 @@ Check `--config`, `AUTORAG_CONFIG`, `$AUTORAG_HOME/config.json`, or
46
46
  - `model.provider`, `model.id`, `model.api`, `model.baseUrl`, `model.apiKeyEnv`
47
47
  - `bm25`, `minSync`, and `jikji`
48
48
  - `limits` (retrieval, baseline-prefetch, and model-facing candidate caps)
49
- - `datasources`, `datasourceAccess`, and `ui`
49
+ - `datasources` and `ui`
50
50
 
51
51
  Preserve explicit user choices and a working config unless the user asks to
52
52
  replace them or health checks fail.
@@ -131,7 +131,7 @@ For a custom endpoint, add `api`, `baseUrl`, and `apiKeyEnv` to the single
131
131
  "searchPaths": ["/path/to/documents"],
132
132
  "model": {
133
133
  "provider": "openrouter",
134
- "id": "anthropic/claude-sonnet-4",
134
+ "id": "anthropic/claude-sonnet-5.5",
135
135
  "api": "openai-completions",
136
136
  "baseUrl": "https://openrouter.ai/api/v1",
137
137
  "apiKeyEnv": "OPENROUTER_API_KEY"
@@ -184,7 +184,7 @@ told duplicate exclusion is off. Set `"excludeExactDuplicates": false` to
184
184
  index every copy.
185
185
 
186
186
  MinSync's default embedder is in-process native Qwen3 embeddings
187
- (`native:Qwen/Qwen3-Embedding-0.6B`, 1024 dimensions, MinSync 0.4.5+). The
187
+ (`native:Qwen/Qwen3-Embedding-0.6B`, 1024 dimensions, MinSync 0.4.6). The
188
188
  default needs no embedder flags, no API key, and no external daemon (such as
189
189
  Ollama) — all embeddings run in-process locally and privately. For workspaces
190
190
  using the loopback llama-server gateway, prefetch the verified model with
@@ -200,16 +200,16 @@ remote, provider:
200
200
 
201
201
  ```bash
202
202
  autorag init \
203
- --embedder-id "text-embedding-3-small" \
204
- --embedder-base-url "https://api.openai.com/v1" \
205
- --embedder-api-key-env "OPENAI_API_KEY" \
206
- --embedder-dimension 1536 \
203
+ --embedder-id "voyageai/voyage-4-lite" \
204
+ --embedder-base-url "https://openrouter.ai/api/v1" \
205
+ --embedder-api-key-env "OPENROUTER_API_KEY" \
206
+ --embedder-dimension 1024 \
207
207
  --embedder-batch-size 64
208
208
  ```
209
209
 
210
210
  Only store the environment-variable name, never its value. Dimension and batch
211
211
  size must be positive integers, and the dimension must match the embedder
212
- (default Qwen3 is 1024; legacy EmbeddingGemma is 768; text-embedding-3-small is 1536).
212
+ (default Qwen3 is 1024; legacy EmbeddingGemma is 768; `voyageai/voyage-4-lite` via OpenRouter is 1024).
213
213
 
214
214
  ### Jev routing and question decomposition (on by default)
215
215
 
@@ -218,10 +218,19 @@ fast and multi-part questions thorough.
218
218
 
219
219
  - **Jev** (`jev`, default `{ "backend": "openrouter" }`, model
220
220
  `typesafe/jev-1.13`) runs before the fast answer. It routes each question to
221
- local search, web search, or a direct answer (general knowledge or small
222
- talk skips retrieval entirely), and decides whether to decompose it. After
223
- the fast answer it decides whether verification is needed, so a complete,
224
- evidence-backed fast answer ends the run.
221
+ local search, web search, a direct answer (general knowledge or small
222
+ talk skips retrieval entirely), or the `config` branch, and decides whether
223
+ to decompose it. On
224
+ local search it also decides, per registered datasource, whether to search
225
+ it before the fast answer, using each datasource's `description` and where
226
+ similar past questions were answered (retrieval memory). When setting up a
227
+ datasource, always write a `description` from what it actually holds:
228
+ channels or rooms, people, topics, time range (for example `"Team Slack,
229
+ 2024-2026: #release and #on-call channels, dependabot notifications"`).
230
+ Jev is told descriptions are short, non-exhaustive summaries, so list the
231
+ main content and do not try to list everything. After the fast answer it
232
+ decides whether verification is needed, so a complete, evidence-backed fast
233
+ answer ends the run.
225
234
  - **Question decomposition** (`queryDecomposition`, default model
226
235
  `openrouter/qwen/qwen3.7-flash`) splits a multi-part question into at most
227
236
  five search queries that run in parallel.
@@ -250,6 +259,14 @@ always verifies, so searches still work. A `query-route-fallback` diagnostic
250
259
  explicitly opts out, for example because questions must never leave the
251
260
  machine (Jev and decomposition send the question text to OpenRouter).
252
261
 
262
+ When a user asks the running agent itself to change its settings (switch the
263
+ default model, add a provider, check that a provider works), Jev's `config`
264
+ branch loads this whole skill into that turn. The agent edits only the active
265
+ config file (and `models.json` for a custom provider), verifies with
266
+ `autorag health --json` and `autorag models list --available`, and reports each
267
+ change as old → new in its final message. It never prints a
268
+ credential value and never uses `init --force`.
269
+
253
270
  ### Retrieval and ingest caps
254
271
 
255
272
  `limits` bounds retrieval, baseline prefetch, and the candidate lists handed to
@@ -313,7 +330,7 @@ setup. Configure datasources directly in trusted config, wizard-style:
313
330
  (such as `github`) require their credential environment variable
314
331
  (`GITHUB_TOKEN`).
315
332
  2. Auto-configure every datasource that probes feasible — write its trusted
316
- `datasources` / `datasourceAccess` entries without asking. For example,
333
+ `datasources` entries without asking. For example,
317
334
  when Slack (`slacrawl`) and Discord (`discrawl`) are installed with local
318
335
  stores present, set both up automatically. Discord uses discrawl's local
319
336
  desktop wiretap archive; no Discord bot token is configured or needed.
@@ -326,13 +343,13 @@ setup. Configure datasources directly in trusted config, wizard-style:
326
343
  users — always probe them and report their status, even when they end up
327
344
  skipped.
328
345
 
329
- Datasource skills belong in trusted config and remain default-deny. Builtin
346
+ Datasource skills belong in trusted config. Builtin
330
347
  template names are `kakao`, `whatsapp`, `telegram`, `slack`, `discord`,
331
348
  `clawgallery`, `notion`, `github`, `github-gist`, `cloud-drive`, `mail-export`,
332
349
  `mailcrawl`, `obsidian`, `rss`, `spotlight`, and `lark`. Config keys may be connection
333
350
  aliases with `"type": "<template>"`. Unknown names are skipped with an
334
351
  `unknown-datasource-skill` warning; they do not fail config resolution.
335
- `scope` and tags can narrow trusted access but cannot grant it.
352
+ `scope` narrows a query to a sub-path as ordinary filtering. Tags are descriptive metadata only, not search filters. MCP `datasourceIds` selects configured connections before retrieval; discover their IDs with `autorag.datasources.list`.
336
353
 
337
354
  ```jsonc
338
355
  {
@@ -344,10 +361,6 @@ aliases with `"type": "<template>"`. Unknown names are skipped with an
344
361
  "mailcrawl": { "instanceId": "personal", "connector": { "account": "personal", "mailbox": "INBOX", "binaryPath": "mailcrawl" } },
345
362
  "obsidian": { "connector": { "vaultPath": "/path/to/vault" } },
346
363
  "rss": { "connector": { "feeds": [{ "url": "https://example.com/feed.xml" }] } }
347
- },
348
- "datasourceAccess": {
349
- "allowedTags": ["github", "cloud-drive", "mailcrawl", "obsidian", "rss"],
350
- "allowedScopes": ["/github/**", "/google-drive/**", "/archive-drive/**", "/mailcrawl/**", "/obsidian/**", "/rss/**"]
351
364
  }
352
365
  }
353
366
  ```
@@ -383,7 +396,7 @@ autorag search "summarize the collection" --top-k 3 --json --debug
383
396
  performs one live completion probe.
384
397
  - `health --skip-probes` is only for intentionally offline validation and does
385
398
  not prove live provider access.
386
- - `refresh` syncs parsed mirrors, MinSync, Jikji, authorized datasources, and
399
+ - `refresh` syncs parsed mirrors, MinSync, Jikji, configured datasources, and
387
400
  on Windows the bundled Everything file-name index. `--method <csv>` may
388
401
  deliberately narrow it (`parsed,minsync,datasources,jikji,everything,all`).
389
402
  - Use `refresh --force` for a full resync only when incremental refresh is not
@@ -404,7 +417,7 @@ reload/reconnect, discover schemas with `tools/list`, and exercise
404
417
  `autorag.search` through MCP. Restart the MCP server after config changes.
405
418
  The MCP server returns model-free source chunks; the calling agent curates
406
419
  them. It does not invoke the configured librarian model. The same server also
407
- exposes `autorag.report`, `autorag.evidence`, and `autorag.feedback` for the
420
+ exposes `autorag.report` and `autorag.evidence` for the
408
421
  curation lifecycle; the matching CLI commands remain a maintenance path.
409
422
  Discover the exact schemas with MCP `tools/list`. Keep the full `autorag` skill
410
423
  only when model-backed curated search is also wanted. For MCP-only setup, use
@@ -1,46 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { Type } from "typebox";
3
- export declare const EMIT_FAST_ANSWER_TOOL_NAME = "emit_fast_answer";
4
- declare const fastAnswerSchema: Type.TObject<{
5
- answer: Type.TString;
6
- results: Type.TArray<Type.TObject<{
7
- number: Type.TInteger;
8
- title: Type.TString;
9
- summary: Type.TString;
10
- evidence: Type.TOptional<Type.TArray<Type.TObject<{
11
- excerpt: Type.TString;
12
- lineNumber: Type.TOptional<Type.TInteger>;
13
- }>>>;
14
- confidence: Type.TOptional<Type.TNumber>;
15
- }>>;
16
- sources: Type.TOptional<Type.TArray<Type.TObject<{
17
- number: Type.TInteger;
18
- source: Type.TString;
19
- }>>>;
20
- }>;
21
- export interface AutoRAGFastAnswerResult {
22
- readonly number: number;
23
- readonly title: string;
24
- readonly summary: string;
25
- readonly evidence: readonly {
26
- readonly excerpt: string;
27
- readonly lineNumber?: number;
28
- }[];
29
- readonly confidence?: number;
30
- }
31
- export interface AutoRAGFastAnswerDetails {
32
- readonly answer: string;
33
- readonly results: readonly AutoRAGFastAnswerResult[];
34
- readonly sources: readonly {
35
- readonly number: number;
36
- readonly source: string;
37
- }[];
38
- }
39
- /**
40
- * Builds the non-terminating fast-answer tool used by the two-phase search
41
- * flow. The model calls this exactly once during the thinking-off fast phase
42
- * to deliver an immediate, complete first answer; the run then continues into
43
- * the verification phase, which ends with emit_autorag_results.
44
- */
45
- export declare function createEmitFastAnswerTool(capture: (details: AutoRAGFastAnswerDetails) => void): AgentTool<typeof fastAnswerSchema, AutoRAGFastAnswerDetails>;
46
- export {};
@@ -1,8 +0,0 @@
1
- import type { CommandContext } from "./types.js";
2
- /**
3
- * Run the `autorag feedback` command. Records per-result useful/not-useful
4
- * signals against an existing curated-results session. Returns 0 when at least
5
- * one feedback signal was applied, 2 for usage errors or an unknown session,
6
- * 1 for runtime/IO errors.
7
- */
8
- export declare function runFeedback(ctx: CommandContext): Promise<number>;
@@ -1,43 +0,0 @@
1
- /**
2
- * Trusted, server-bound access context for the datasource layer.
3
- *
4
- * Constructed from server-supplied allow-tags and allow-scopes ONLY — never
5
- * from model or tool arguments. Tags authorize datasource skills; scopes are
6
- * applied only to skills that advertise the `scoped` capability.
7
- */
8
- import type { DatasourceAccessible } from "./types.js";
9
- export interface DatasourceAccessContextOptions {
10
- /** Trusted allow-tags. Undefined or empty ⇒ default-deny (isDenyAll). */
11
- readonly allowedTags?: readonly string[];
12
- /** Trusted allow-scopes as slash-hierarchical paths or globs. */
13
- readonly allowedScopes?: readonly string[];
14
- }
15
- /**
16
- * Access context for gating datasource descriptors and sources.
17
- *
18
- * Non-datasource descriptors (those without a `datasourceId`) are NOT gated
19
- * by this context: {@link isAccessible} returns `true` for them so plain
20
- * retrieval methods (e.g. `posix`) pass through unchanged.
21
- */
22
- export declare class DatasourceAccessContext {
23
- readonly allowedTags: readonly string[];
24
- readonly allowedScopes: readonly string[];
25
- private readonly denyAll;
26
- constructor(options?: DatasourceAccessContextOptions);
27
- /** True when the context denies everything (no trusted allow-tags). */
28
- get isDenyAll(): boolean;
29
- /**
30
- * Whether a descriptor is accessible.
31
- *
32
- * Non-datasource descriptors (no `datasourceId`) pass through (`true`) —
33
- * they are not gated by this context. Datasource descriptors require at
34
- * least one tag intersecting the trusted allow-tags.
35
- */
36
- isAccessible(descriptor: DatasourceAccessible): boolean;
37
- /**
38
- * Scope-capable datasource results are filtered by trusted and user scopes.
39
- * Datasources without the `scoped` capability bypass this predicate and
40
- * are authorized only at the skill/tag level.
41
- */
42
- allowedSourcesPredicate(_userScope?: string, userScopes?: readonly string[]): (source: string) => boolean;
43
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * Result filter that applies datasource access gating to the shared retrieval
3
- * result stream.
4
- *
5
- * The filter sits *after* {@link ParallelRetriever} and *before* merging: it
6
- * takes the per-method result map and the {@link RetrievalMethod}s that
7
- * produced it, then for every datasource-backed method either drops all of
8
- * its results (when the trusted access context denies the descriptor) or
9
- * keeps only the sources the context allows for the current user scope when
10
- * the method advertises the `scoped` capability.
11
- *
12
- * Non-datasource methods (those whose descriptor has no `datasourceId`) pass
13
- * through completely untouched — they are gated by their own retrieval
14
- * pipeline, not by the datasource access context.
15
- *
16
- * Security invariants:
17
- * - Deny is always an explicit `false` (an empty result array), never
18
- * `undefined`-as-deny. {@link DatasourceAccessContext} itself returns
19
- * explicit booleans from its predicate; this filter never passes
20
- * `undefined` to `matchesVirtualPathScope` as a deny signal.
21
- * - The filter never grants access. It only narrows results using the
22
- * trusted, server-supplied {@link DatasourceAccessContext}; model/tool
23
- * arguments (such as `userScope`) can only *further restrict* the trusted
24
- * allow-scopes, never widen them.
25
- */
26
- import type { RetrievalMethod, RetrievalResult } from "../retrieval/types.js";
27
- import type { DatasourceAccessContext } from "./access-context.js";
28
- /** Per-method retrieval results keyed by method name. */
29
- export type ResultsByMethod = Map<string, RetrievalResult[]>;
30
- /**
31
- * Applies datasource access gating to a per-method result map.
32
- *
33
- * The instance form lets callers wire a {@link DatasourceSkillRegistry} for
34
- * future descriptor enrichment; the v1 filter only needs the
35
- * {@link RetrievalMethodDescriptor} carried by each method, which already
36
- * satisfies {@link DatasourceAccessible} structurally (`datasourceId?` +
37
- * `tags?`).
38
- */
39
- export declare class DatasourceResultFilter {
40
- /**
41
- * Filter `byMethod` according to datasource access rules.
42
- *
43
- * For each method present in both `byMethod` and `methods`:
44
- * - non-datasource methods (`descriptor.datasourceId` unset) are passed
45
- * through with their result array unchanged;
46
- * - datasource methods whose descriptor is denied by `ctx` are reduced to
47
- * an empty result array (`[]` — explicit deny, never `undefined`);
48
- * - datasource methods whose descriptor is allowed are filtered so only
49
- * sources matching `ctx.allowedSourcesPredicate(userScope)` survive.
50
- *
51
- * Result entries for methods not present in `methods` are passed through
52
- * unchanged (the filter cannot classify them and must not fabricate a
53
- * descriptor). A new {@link ResultsByMethod} is returned; the input map is
54
- * not mutated.
55
- *
56
- * @param byMethod Per-method results from the retriever.
57
- * @param methods The {@link RetrievalMethod}s that produced them.
58
- * @param ctx Trusted, server-supplied access context.
59
- * @param userScope Optional user/model-requested scope; when provided it
60
- * is intersected with the trusted allow-scopes and can only narrow
61
- * results. `undefined` means "no extra user restriction".
62
- */
63
- filter(byMethod: ResultsByMethod, methods: readonly RetrievalMethod[], ctx: DatasourceAccessContext, userScope?: string, userScopes?: readonly string[]): ResultsByMethod;
64
- }
@@ -1,31 +0,0 @@
1
- import { type ParseInput, type ParseOutput, Parser } from "./types.js";
2
- export interface OcrEngineInput {
3
- readonly bytes: Uint8Array;
4
- readonly languages: readonly string[];
5
- readonly timeoutMs: number;
6
- readonly signal: AbortSignal;
7
- }
8
- export type OcrEngine = (input: OcrEngineInput) => Promise<string>;
9
- export type OcrOperation = {
10
- readonly result: Promise<string>;
11
- readonly cleanup: Promise<void>;
12
- };
13
- export interface OcrParserOptions {
14
- readonly enabled: boolean;
15
- readonly languages?: readonly string[];
16
- readonly timeoutMs?: number;
17
- readonly maxBytes?: number;
18
- readonly engine?: OcrEngine;
19
- }
20
- export declare class ImageOcrParser extends Parser {
21
- readonly name = "image-ocr";
22
- readonly extensions: readonly [".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".webp"];
23
- private readonly languages;
24
- private readonly timeoutMs;
25
- private readonly maxBytes;
26
- private readonly engine;
27
- constructor(options: OcrParserOptions);
28
- parse(input: ParseInput): Promise<ParseOutput>;
29
- }
30
- export declare function createTesseractOcrOperation(input: OcrEngineInput): OcrOperation;
31
- export declare function withTimeout(operation: OcrOperation, timeoutMs: number, onTimeout: () => void): Promise<string>;