@autorag/librarian 2.2.0 → 2.4.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 (106) hide show
  1. package/README.md +194 -47
  2. package/dist/agent/agent.d.ts +34 -47
  3. package/dist/agent/bash-tool.d.ts +2 -11
  4. package/dist/agent/dupey-tool.d.ts +15 -0
  5. package/dist/agent/emit-results-tool.d.ts +14 -0
  6. package/dist/agent/index.d.ts +1 -0
  7. package/dist/agent/local-model.d.ts +12 -0
  8. package/dist/agent/search-bm25-tool.d.ts +11 -3
  9. package/dist/agent/search-documents.d.ts +2 -2
  10. package/dist/agent/search-minsync-tool.d.ts +2 -2
  11. package/dist/agent/system-prompt.d.ts +1 -2
  12. package/dist/cli/commands/duplicates.d.ts +4 -0
  13. package/dist/cli/commands/health.d.ts +9 -65
  14. package/dist/cli/commands/index.d.ts +3 -3
  15. package/dist/cli/commands/init.d.ts +1 -1
  16. package/dist/cli/commands/search.d.ts +2 -2
  17. package/dist/cli/commands/tui.d.ts +36 -0
  18. package/dist/cli/commands/ui.d.ts +13 -0
  19. package/dist/cli/config.d.ts +27 -22
  20. package/dist/cli/index.js +14965 -12563
  21. package/dist/cli/tui-commands.d.ts +16 -0
  22. package/dist/cli/tui-session-store.d.ts +16 -0
  23. package/dist/datasource/access-context.d.ts +6 -12
  24. package/dist/datasource/aliased-skill.d.ts +28 -0
  25. package/dist/datasource/chunk-store.d.ts +2 -0
  26. package/dist/datasource/connector-skill.d.ts +3 -0
  27. package/dist/datasource/connector.d.ts +4 -0
  28. package/dist/datasource/crawler-skill.d.ts +6 -0
  29. package/dist/datasource/crawler-types.d.ts +2 -0
  30. package/dist/datasource/described-skill.d.ts +17 -0
  31. package/dist/datasource/index.d.ts +4 -2
  32. package/dist/datasource/result-filter.d.ts +2 -1
  33. package/dist/datasource/skills/clawgallery/client.d.ts +9 -0
  34. package/dist/datasource/skills/clawgallery/index.d.ts +5 -0
  35. package/dist/datasource/skills/clawgallery/methods.d.ts +19 -0
  36. package/dist/datasource/skills/clawgallery/paths.d.ts +7 -0
  37. package/dist/datasource/skills/clawgallery/skill.d.ts +35 -0
  38. package/dist/datasource/skills/clawgallery/types.d.ts +58 -0
  39. package/dist/datasource/skills/cloud-drive/index.d.ts +2 -0
  40. package/dist/datasource/skills/cloud-drive/rclone-connector.d.ts +47 -0
  41. package/dist/datasource/skills/cloud-drive/skill.d.ts +14 -0
  42. package/dist/datasource/skills/discrawl/skill.d.ts +3 -0
  43. package/dist/datasource/skills/discrawl/types.d.ts +4 -8
  44. package/dist/datasource/skills/factory.d.ts +9 -0
  45. package/dist/datasource/skills/gmail/himalaya-connector.d.ts +12 -1
  46. package/dist/datasource/skills/katok/methods.d.ts +6 -4
  47. package/dist/datasource/skills/katok/types.d.ts +8 -26
  48. package/dist/datasource/skills/mailcrawl/client.d.ts +15 -0
  49. package/dist/datasource/skills/mailcrawl/config.d.ts +2 -0
  50. package/dist/datasource/skills/mailcrawl/index.d.ts +4 -0
  51. package/dist/datasource/skills/mailcrawl/methods.d.ts +15 -0
  52. package/dist/datasource/skills/mailcrawl/skill.d.ts +34 -0
  53. package/dist/datasource/skills/mailcrawl/types.d.ts +71 -0
  54. package/dist/datasource/skills/obsidian/skill.d.ts +2 -0
  55. package/dist/datasource/skills/obsidian/types.d.ts +2 -0
  56. package/dist/datasource/types.d.ts +5 -2
  57. package/dist/dupey/cli.d.ts +40 -0
  58. package/dist/dupey/filter.d.ts +8 -0
  59. package/dist/dupey/index.d.ts +2 -0
  60. package/dist/filesystem/cloud-placeholder.d.ts +26 -0
  61. package/dist/index.d.ts +1 -0
  62. package/dist/index.js +8889 -9292
  63. package/dist/jikji/client.d.ts +1 -0
  64. package/dist/memory/check-memory-tool.d.ts +1 -0
  65. package/dist/memory/index.d.ts +2 -2
  66. package/dist/memory/memory.d.ts +33 -3
  67. package/dist/memory/renderer.d.ts +2 -1
  68. package/dist/minsync/client.d.ts +5 -1
  69. package/dist/minsync/embedder-config.d.ts +4 -1
  70. package/dist/minsync/index.d.ts +4 -4
  71. package/dist/minsync/installer.d.ts +1 -0
  72. package/dist/minsync/method.d.ts +22 -1
  73. package/dist/minsync/types.d.ts +5 -0
  74. package/dist/mirror/sync.d.ts +3 -1
  75. package/dist/observability/run-log.d.ts +1 -26
  76. package/dist/parser/defaults.d.ts +2 -0
  77. package/dist/parser/index.d.ts +2 -2
  78. package/dist/parser/opendataloader-pdf.d.ts +10 -0
  79. package/dist/parser/types.d.ts +7 -0
  80. package/dist/process/portable-spawn.d.ts +10 -0
  81. package/dist/retrieval/index.d.ts +2 -2
  82. package/dist/retrieval/methods/bm25.d.ts +7 -36
  83. package/dist/ui/browse.d.ts +11 -0
  84. package/dist/ui/catalog.d.ts +59 -0
  85. package/dist/ui/config-store.d.ts +43 -0
  86. package/dist/ui/discover.d.ts +19 -0
  87. package/dist/ui/html.d.ts +2 -0
  88. package/dist/ui/probe.d.ts +24 -0
  89. package/dist/ui/prompt.d.ts +21 -0
  90. package/dist/ui/server.d.ts +28 -0
  91. package/package.json +17 -15
  92. package/skills/autorag/SKILL.md +79 -108
  93. package/skills/autorag-setup/SKILL.md +170 -395
  94. package/dist/datasource/skills/discrawl/config.d.ts +0 -9
  95. package/dist/datasource/skills/gdrive/connector.d.ts +0 -30
  96. package/dist/datasource/skills/gdrive/index.d.ts +0 -3
  97. package/dist/datasource/skills/gdrive/rclone-connector.d.ts +0 -51
  98. package/dist/datasource/skills/gdrive/skill.d.ts +0 -24
  99. package/dist/subagents/contracts.d.ts +0 -90
  100. package/dist/subagents/dispatch-templates.d.ts +0 -104
  101. package/dist/subagents/dispatch-validation.d.ts +0 -169
  102. package/dist/subagents/explorer-tools-extension.d.ts +0 -4
  103. package/dist/subagents/explorer-tools-extension.js +0 -130
  104. package/dist/subagents/local-models.d.ts +0 -14
  105. package/dist/subagents/model-policy.d.ts +0 -31
  106. package/dist/subagents/runtime.d.ts +0 -52
@@ -0,0 +1,15 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ import { Type } from "typebox";
3
+ import type { DupeyScanResult } from "../dupey/index.js";
4
+ export declare const SCAN_DUPLICATE_DOCUMENTS_TOOL_NAME = "scan_duplicate_documents";
5
+ export interface ScanDuplicateDocumentsDetails {
6
+ readonly scans: readonly DupeyScanResult[];
7
+ readonly familyCount: number;
8
+ readonly exactDuplicateCount: number;
9
+ }
10
+ export interface ScanDuplicateDocumentsProvider {
11
+ scanDuplicateDocuments(): Promise<ScanDuplicateDocumentsDetails>;
12
+ }
13
+ declare const scanDuplicateDocumentsSchema: Type.TObject<{}>;
14
+ export declare function createScanDuplicateDocumentsTool(provider: ScanDuplicateDocumentsProvider): AgentTool<typeof scanDuplicateDocumentsSchema, ScanDuplicateDocumentsDetails>;
15
+ export {};
@@ -27,6 +27,13 @@ declare const emitResultsSchema: Type.TObject<{
27
27
  chunkIndex: Type.TOptional<Type.TInteger>;
28
28
  lineNumber: Type.TOptional<Type.TInteger>;
29
29
  stableEvidenceId: Type.TOptional<Type.TString>;
30
+ retrieverMix: Type.TOptional<Type.TArray<Type.TString>>;
31
+ parserType: Type.TOptional<Type.TString>;
32
+ documentType: Type.TOptional<Type.TString>;
33
+ documentArea: Type.TOptional<Type.TString>;
34
+ evidenceType: Type.TOptional<Type.TString>;
35
+ evidenceLocation: Type.TOptional<Type.TString>;
36
+ confidence: Type.TOptional<Type.TNumber>;
30
37
  }>>>;
31
38
  }>>;
32
39
  warnings: Type.TOptional<Type.TArray<Type.TString>>;
@@ -51,6 +58,13 @@ export interface AutoRAGEvidenceRef {
51
58
  readonly chunkIndex?: number;
52
59
  readonly lineNumber?: number;
53
60
  readonly stableEvidenceId?: string;
61
+ readonly retrieverMix?: readonly string[];
62
+ readonly parserType?: string;
63
+ readonly documentType?: string;
64
+ readonly documentArea?: string;
65
+ readonly evidenceType?: string;
66
+ readonly evidenceLocation?: string;
67
+ readonly confidence?: number;
54
68
  }
55
69
  export interface AutoRAGMappingEntry {
56
70
  readonly number: number;
@@ -1,6 +1,7 @@
1
1
  export type { AutoRAGAgentOptions, AutoRefreshOptions } from "./agent.js";
2
2
  export { AutoRAGAgent } from "./agent.js";
3
3
  export { buildDatasourceSkillsPrompt, createLoadDatasourceSkillTool, type DatasourceSkillProvider, datasourceSkillLocation, formatDatasourceSkillInvocation, LOAD_DATASOURCE_SKILL_TOOL_NAME, type LoadDatasourceSkillDetails, toDatasourceAgentSkill, } from "./datasource-skill.js";
4
+ export { createScanDuplicateDocumentsTool, SCAN_DUPLICATE_DOCUMENTS_TOOL_NAME, type ScanDuplicateDocumentsDetails, type ScanDuplicateDocumentsProvider, } from "./dupey-tool.js";
4
5
  export type { AutoRAGEmittedResult, AutoRAGMappingEntry, AutoRAGResultsDetails, } from "./emit-results-tool.js";
5
6
  export { createEmitResultsTool, EMIT_AUTORAG_RESULTS_TOOL_NAME } from "./emit-results-tool.js";
6
7
  export { createJikjiFindTool, JIKJI_FIND_TOOL_NAME, type JikjiFindDetails, type JikjiFindPerRootPolicy, type JikjiFindProvider, type JikjiFindProviderResult, type MergedJikjiPolicy, } from "./jikji-find-tool.js";
@@ -0,0 +1,12 @@
1
+ import type { Model } from "@earendil-works/pi-ai";
2
+ export interface LocalAutoRAGModel {
3
+ readonly provider: string;
4
+ readonly apiKey: string;
5
+ readonly model: Model<"openai-responses">;
6
+ }
7
+ export interface LoadLocalAutoRAGModelOptions {
8
+ readonly configPath?: string;
9
+ readonly env?: Readonly<Record<string, string | undefined>>;
10
+ readonly modelId?: string;
11
+ }
12
+ export declare function loadLocalAutoRAGModel(options?: LoadLocalAutoRAGModelOptions): LocalAutoRAGModel;
@@ -1,7 +1,8 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
2
  import { Type } from "typebox";
3
- import type { BM25Method, BM25Status } from "../retrieval/methods/bm25.js";
4
- export declare const SEARCH_BM25_DOCUMENTS_TOOL_NAME = "search_bm25_documents";
3
+ import type { BM25Status } from "../retrieval/methods/bm25.js";
4
+ import type { RetrievalResult } from "../retrieval/types.js";
5
+ export declare const SEARCH_BM25_DOCUMENTS_TOOL_NAME = "lexical_search_local_docs";
5
6
  declare const searchBM25Schema: Type.TObject<{
6
7
  query: Type.TString;
7
8
  topK: Type.TOptional<Type.TInteger>;
@@ -14,5 +15,12 @@ export interface SearchBM25DocumentsDetails {
14
15
  readonly readiness: BM25Status["readiness"];
15
16
  readonly engine: BM25Status["engine"];
16
17
  }
17
- export declare function createSearchBM25DocumentsTool(getMethod: () => BM25Method | undefined, resolveScope?: (scope: string | undefined) => string | undefined): AgentTool<typeof searchBM25Schema, SearchBM25DocumentsDetails>;
18
+ export interface BM25SearchMethod {
19
+ getStatus(): BM25Status;
20
+ retrieve(query: string, options: {
21
+ topK?: number;
22
+ scope?: string;
23
+ }): Promise<RetrievalResult[]>;
24
+ }
25
+ export declare function createSearchBM25DocumentsTool(getMethod: () => BM25SearchMethod | undefined, resolveScope?: (scope: string | undefined) => string | undefined): AgentTool<typeof searchBM25Schema, SearchBM25DocumentsDetails>;
18
26
  export {};
@@ -9,7 +9,7 @@ export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
9
9
  * (#21/#22) does not require another source-breaking type change; codes not yet
10
10
  * emitted are still valid members.
11
11
  */
12
- export type SearchDocumentDiagnosticCode = "empty-query" | "unknown-warning" | "caller-tool-dropped" | "bm25-unavailable" | "bm25-degraded-fallback" | "minsync-unavailable" | "parser-skipped" | "parser-failed" | "unsupported-file" | "stale-index" | "deleted-mirror" | "retrieval-method-failed" | "jikji-unavailable" | "jikji-prepare-failed" | "jikji-find-failed" | "refresh-failed" | "watch-failed" | "watch-limited";
12
+ export type SearchDocumentDiagnosticCode = "empty-query" | "unknown-warning" | "caller-tool-dropped" | "bm25-unavailable" | "bm25-degraded-fallback" | "minsync-unavailable" | "parser-skipped" | "parser-failed" | "pdf-java-version" | "duplicate-excluded" | "unsupported-file" | "stale-index" | "deleted-mirror" | "pdf-extract-thin" | "pdf-hybrid-unavailable" | "retrieval-method-failed" | "jikji-unavailable" | "jikji-prepare-failed" | "jikji-find-failed" | "refresh-failed" | "watch-failed" | "watch-limited" | "unknown-datasource-skill";
13
13
  export interface SearchDocumentDiagnostic {
14
14
  readonly code: SearchDocumentDiagnosticCode;
15
15
  readonly severity: SearchDocumentDiagnosticSeverity;
@@ -51,7 +51,7 @@ type ReadonlySearchSessions = ReadonlyMap<string, {
51
51
  query: string;
52
52
  registry: ReadonlyMap<number, CuratedResult>;
53
53
  }>;
54
- export declare function createEmptySearchDocumentsResponse(sessionId: string, query: string, sessions: SearchSessions): SearchDocumentsResponse;
54
+ export declare function createEmptySearchDocumentsResponse(sessionId: string, query: string, sessions: SearchSessions, diagnostics?: readonly SearchDocumentDiagnostic[]): SearchDocumentsResponse;
55
55
  export declare function recordStructuredResultsSession(sessionId: string, query: string, details: AutoRAGResultsDetails, sessions: SearchSessions, memory: RetrievalMemory, componentDiagnostics?: readonly SearchDocumentDiagnostic[]): SearchDocumentsResponse;
56
56
  export declare function recordNumberedFeedback(sessions: ReadonlySearchSessions, memory: RetrievalMemory, sessionId: string, usefulNumbers: readonly number[], notUsefulNumbers: readonly number[]): void;
57
57
  export {};
@@ -1,14 +1,14 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
2
  import { Type } from "typebox";
3
3
  import type { MinSyncVectorMethod } from "../minsync/method.js";
4
- export declare const SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME = "search_minsync_documents";
4
+ export declare const SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME = "semantic_search_local_docs";
5
5
  declare const searchMinSyncSchema: Type.TObject<{
6
6
  query: Type.TString;
7
7
  topK: Type.TOptional<Type.TInteger>;
8
8
  scope: Type.TOptional<Type.TString>;
9
9
  }>;
10
10
  export interface SearchMinSyncDocumentsDetails {
11
- readonly method: "search_minsync_documents";
11
+ readonly method: "semantic_search_local_docs";
12
12
  readonly resultCount: number;
13
13
  readonly sources: readonly string[];
14
14
  readonly available: boolean;
@@ -2,8 +2,7 @@ import type { Skill } from "@earendil-works/pi-agent-core";
2
2
  import type { StoreManifest } from "../manifest/types.js";
3
3
  export interface SystemPromptConfig {
4
4
  toolNames: string[];
5
- orchestratorModelId?: string;
6
- explorerModelId?: string;
5
+ modelId?: string;
7
6
  memorySignalCount?: number;
8
7
  memoryEntries?: readonly unknown[];
9
8
  manifests: StoreManifest[];
@@ -0,0 +1,4 @@
1
+ import type { DupeyScanResult } from "../../dupey/index.js";
2
+ import type { CommandContext } from "./types.js";
3
+ export type DuplicateScanner = (path: string) => Promise<DupeyScanResult>;
4
+ export declare function runDuplicates(ctx: CommandContext, scanner?: DuplicateScanner): Promise<number>;
@@ -1,12 +1,10 @@
1
1
  import type { Api, Model } from "@earendil-works/pi-ai";
2
- import type { LoadLocalAutoRAGModelsOptions } from "../../subagents/local-models.js";
3
- import { type CliConfig } from "../config.js";
2
+ import type { LoadLocalAutoRAGModelOptions } from "../../agent/local-model.js";
3
+ import { type CliConfig, type ResolvedAgentModelDetailed } from "../config.js";
4
4
  import type { CommandContext } from "./types.js";
5
- export type HealthCategory = "config" | "model_resolution" | "auth_missing" | "provider_unreachable" | "completion_failed" | "subagent_failed" | "timeout" | "ok";
6
- export type HealthRole = "orchestrator" | "explorer";
5
+ export type HealthCategory = "config" | "model_resolution" | "auth_missing" | "provider_unreachable" | "completion_failed" | "timeout" | "ok";
7
6
  export interface HealthCoverage {
8
7
  modelProvider: boolean;
9
- subagentDispatch: boolean;
10
8
  retrievalTools: false;
11
9
  searchCuration: false;
12
10
  indexHealth: false;
@@ -17,12 +15,10 @@ export interface HealthRoleAuth {
17
15
  envName?: string;
18
16
  }
19
17
  export interface HealthRoleReport {
20
- role: HealthRole;
21
18
  provider: string;
22
19
  modelId: string;
23
20
  displayName?: string;
24
21
  api: string;
25
- routeFamily?: string;
26
22
  baseUrl?: string;
27
23
  contextWindow?: number;
28
24
  maxTokens?: number;
@@ -35,7 +31,6 @@ export interface HealthRoleReport {
35
31
  resolutionSource: "config" | "flags" | "env" | "local_runtime" | "catalog" | "configured_alias" | "mixed";
36
32
  }
37
33
  export interface HealthProbeReport {
38
- role: HealthRole;
39
34
  skipped: boolean;
40
35
  ok: boolean;
41
36
  category: HealthCategory;
@@ -55,75 +50,32 @@ export interface HealthReportV1 {
55
50
  probesSkipped: boolean;
56
51
  coverage: HealthCoverage;
57
52
  config: HealthConfigReport;
58
- models: {
59
- orchestrator?: HealthRoleReport;
60
- explorer?: HealthRoleReport;
61
- };
62
- probes: {
63
- orchestrator?: HealthProbeReport;
64
- explorer?: HealthProbeReport;
65
- };
53
+ model?: HealthRoleReport;
54
+ probe?: HealthProbeReport;
66
55
  indexHealth: {
67
56
  separate: true;
68
57
  command: "autorag status";
69
58
  included: false;
70
59
  };
71
60
  }
72
- /**
73
- * Probe input passed to injected orchestrator/explorer probes. Credential
74
- * values are present for the probe to use but must never be surfaced in
75
- * rendered output.
76
- */
77
61
  export interface ProbeInput {
78
- role: HealthRole;
79
62
  model: Model<Api>;
80
63
  apiKey?: string;
81
64
  providerApiKeys?: Readonly<Record<string, string>>;
82
65
  timeoutMs: number;
83
66
  cwd: string;
84
67
  }
85
- /**
86
- * Probe outcome returned by injected probes. `category` is the per-role
87
- * health category; `message` is already sanitized (no secrets/paths/stacks).
88
- */
89
68
  export interface ProbeOutput {
90
69
  ok: boolean;
91
70
  category: HealthCategory;
92
71
  message?: string;
93
72
  }
94
- /**
95
- * Detailed role metadata produced by the model resolver. The default
96
- * adapter derives this from {@link resolveAgentModel}; when config exports a
97
- * dedicated `resolveAgentModelDetailed`, the health command prefers it.
98
- */
99
- export interface ResolvedHealthRole {
100
- readonly provider: string;
101
- readonly modelId: string;
102
- readonly displayName?: string;
103
- readonly api: Api;
104
- readonly baseUrl?: string;
105
- readonly contextWindow?: number;
106
- readonly maxTokens?: number;
107
- readonly capabilities: {
108
- input: readonly string[];
109
- reasoning: boolean;
110
- };
111
- readonly auth: {
112
- present: boolean;
113
- source: "env" | "local_runtime" | "pi_auth" | "catalog" | "none" | "unknown";
114
- envName?: string;
115
- };
116
- readonly resolutionSource: "config" | "flags" | "env" | "local_runtime" | "catalog" | "configured_alias" | "mixed";
117
- }
73
+ export type ResolvedHealthRole = ResolvedAgentModelDetailed["role"];
118
74
  export interface ResolvedHealthModel {
119
75
  readonly model: Model<Api>;
120
- readonly explorerModel: Model<Api>;
121
76
  readonly apiKey?: string;
122
77
  readonly providerApiKeys?: Readonly<Record<string, string>>;
123
- readonly roles: {
124
- orchestrator: ResolvedHealthRole;
125
- explorer: ResolvedHealthRole;
126
- };
78
+ readonly role: ResolvedHealthRole;
127
79
  }
128
80
  export interface HealthDeps {
129
81
  configResolver?: (input: {
@@ -131,16 +83,8 @@ export interface HealthDeps {
131
83
  cwd?: string;
132
84
  env?: NodeJS.ProcessEnv;
133
85
  }) => CliConfig;
134
- modelResolver?: (config: CliConfig, localOptions?: LoadLocalAutoRAGModelsOptions) => ResolvedHealthModel;
135
- orchestratorProbe?: (input: ProbeInput, signal: AbortSignal) => Promise<ProbeOutput>;
136
- explorerProbe?: (input: ProbeInput, signal: AbortSignal) => Promise<ProbeOutput>;
86
+ modelResolver?: (config: CliConfig, localOptions?: LoadLocalAutoRAGModelOptions) => ResolvedHealthModel;
87
+ probe?: (input: ProbeInput, signal: AbortSignal) => Promise<ProbeOutput>;
137
88
  now?: () => number;
138
89
  }
139
- /**
140
- * Run the `autorag health` command. Returns an exit code and writes the
141
- * rendered health report to `ctx.stdout` (or an error to `ctx.stderr`).
142
- *
143
- * All network/runtime behavior is injectable via `deps`; unit tests inject
144
- * fake resolvers/probes and never touch live networks.
145
- */
146
90
  export declare function runHealth(ctx: CommandContext, deps?: HealthDeps): Promise<number>;
@@ -1,8 +1,8 @@
1
1
  import type { CommandContext } from "./types.js";
2
2
  /**
3
- * Run the `autorag index` command. `reset` removes the parsed mirror, BM25,
4
- * and MinSync index directories under `.autorag` (preserving `bin`,
5
- * `datasources`, and the memory file). `rebuild` resets then re-runs a forced
3
+ * Run the `autorag index` command. `reset` removes the parsed mirror
4
+ * MinSync, and leftover legacy BM25 index directories under `.autorag`
5
+ * (preserving `bin`, `datasources`, and the memory file). `rebuild` resets then re-runs a forced
6
6
  * refresh. Returns 0 on success, 2 for usage/decline errors, 1 for runtime
7
7
  * errors including path-escape guard violations.
8
8
  */
@@ -1,7 +1,7 @@
1
1
  import type { CommandContext } from "./types.js";
2
2
  /**
3
3
  * `autorag init` writes the default config to `~/.autorag/config.json`.
4
- * Role-specific model flags are folded into the generated config. A legacy
4
+ * Model flags are folded into the generated config. A legacy
5
5
  * `autorag.config.json` in the current working directory may be migrated
6
6
  * non-destructively. An existing home config is not overwritten without
7
7
  * `--force`.
@@ -4,12 +4,12 @@ import type { CommandContext } from "./types.js";
4
4
  /**
5
5
  * A recoverable health hint surfaced when `autorag search` fails for a reason
6
6
  * that `autorag health` can diagnose. The classifier only produces hints for
7
- * model/provider/subagent failures — never for retrieval, index, datasource,
7
+ * model/provider failures — never for retrieval, index, datasource,
8
8
  * or empty-query errors.
9
9
  */
10
10
  export interface SearchHealthHint {
11
11
  command: "autorag health";
12
- reason: "model_resolution" | "subagent_failed" | "auth_missing" | "provider_unreachable" | "timeout";
12
+ reason: "model_resolution" | "auth_missing" | "provider_unreachable" | "timeout";
13
13
  message: string;
14
14
  }
15
15
  /**
@@ -0,0 +1,36 @@
1
+ import type { AgentEvent } from "@earendil-works/pi-agent-core";
2
+ import { AutoRAGAgent, type AutoRAGAgentOptions } from "../../agent/agent.js";
3
+ import { type CliConfig, type ResolvedAgentModel } from "../config.js";
4
+ import { type TuiSessionRecord, type TuiSessionStore } from "../tui-session-store.js";
5
+ import type { CommandContext } from "./types.js";
6
+ export { parseSlashCommand } from "../tui-commands.js";
7
+ export interface TuiDriver {
8
+ submissions: string[];
9
+ rendered: string[];
10
+ started: boolean;
11
+ stopped: boolean;
12
+ onSubmit?: (text: string) => void | Promise<void>;
13
+ onExit?: () => void;
14
+ onEvent?: (event: AgentEvent) => void;
15
+ onInput?: (data: string) => void;
16
+ }
17
+ export interface TuiPresenter {
18
+ handle(event: AgentEvent): void;
19
+ lines(): readonly string[];
20
+ working(): boolean;
21
+ setWorking(active: boolean): void;
22
+ beginRun(): void;
23
+ interrupt(): void;
24
+ status(): string;
25
+ reset(): void;
26
+ }
27
+ type TuiAgent = Pick<AutoRAGAgent, "searchDocuments"> & Partial<Pick<AutoRAGAgent, "subscribe" | "abort">>;
28
+ export interface TuiDeps {
29
+ agentFactory?: (opts?: AutoRAGAgentOptions) => TuiAgent;
30
+ modelResolver?: (config: CliConfig) => ResolvedAgentModel;
31
+ tuiFactory?: (ctx: CommandContext) => TuiDriver;
32
+ sessionStore?: TuiSessionStore;
33
+ }
34
+ export declare function createTuiPresenter(): TuiPresenter;
35
+ export declare function renderTuiSessionView(session: TuiSessionRecord | undefined, input: string): string;
36
+ export declare function runTui(ctx: CommandContext, deps?: TuiDeps): Promise<number>;
@@ -0,0 +1,13 @@
1
+ import { startUiServer, type UiServer } from "../../ui/server.js";
2
+ import type { CommandContext } from "./types.js";
3
+ export interface UiCommandDeps {
4
+ readonly startServer?: typeof startUiServer;
5
+ readonly openBrowser?: (url: string) => Promise<void>;
6
+ readonly waitUntilStopped?: (server: UiServer) => Promise<void>;
7
+ readonly createToken?: () => string;
8
+ }
9
+ /**
10
+ * `autorag ui` — local loopback dashboard for folders and datasource connections.
11
+ */
12
+ export declare function runUi(ctx: CommandContext, deps?: UiCommandDeps): Promise<number>;
13
+ export declare function openBrowser(url: string): Promise<void>;
@@ -1,10 +1,9 @@
1
1
  import type { Api, Model } from "@earendil-works/pi-ai";
2
2
  import type { AutoRAGAgentOptions } from "../agent/agent.js";
3
+ import { type LoadLocalAutoRAGModelOptions } from "../agent/local-model.js";
3
4
  import type { DatasourceAccessContextOptions } from "../datasource/access-context.js";
4
5
  import { type DatasourcesConfig } from "../datasource/skills/factory.js";
5
6
  import type { EnsureMinSyncBinaryOptions, MinSyncEmbedderConfig } from "../minsync/index.js";
6
- import type { BM25Engine, BM25FallbackMode } from "../retrieval/methods/bm25.js";
7
- import { type LoadLocalAutoRAGModelsOptions } from "../subagents/local-models.js";
8
7
  export declare const DEFAULT_CONFIG_FILENAME = "config.json";
9
8
  export declare const LEGACY_CONFIG_FILENAME = "autorag.config.json";
10
9
  export { AUTORAG_HOME_ENV, resolveAutoRAGHome } from "../config/home.js";
@@ -17,14 +16,10 @@ export declare class ConfigError extends Error {
17
16
  */
18
17
  export interface Bm25MethodConfig {
19
18
  enabled?: boolean;
20
- indexPath?: string;
21
- fallback?: BM25FallbackMode;
22
- forceEngine?: Exclude<BM25Engine, "none">;
23
- importBinding?: () => Promise<typeof import("@pngwasi/node-tantivy-binding")>;
24
19
  }
25
20
  /**
26
21
  * Typed MinSync method config persisted in `config.json`. Missing `enabled`
27
- * means enabled (true); `autoInstall` defaults to false. `embedder` carries
22
+ * means enabled (true); `autoInstall` defaults to true. `embedder` carries
28
23
  * the MinSync vector embedder settings validated by {@link normalizeEmbedder}.
29
24
  */
30
25
  export interface MinSyncMethodConfig {
@@ -32,6 +27,7 @@ export interface MinSyncMethodConfig {
32
27
  autoInstall?: boolean;
33
28
  binaryPath?: string;
34
29
  workspacePath?: string;
30
+ maxChunkSize?: number;
35
31
  installer?: Omit<EnsureMinSyncBinaryOptions, "root">;
36
32
  embedder?: MinSyncEmbedderConfig;
37
33
  }
@@ -45,6 +41,14 @@ export interface NormalizedIndexingConfig {
45
41
  bm25: Bm25MethodConfig;
46
42
  minSync: MinSyncMethodConfig;
47
43
  }
44
+ export interface UiConfig {
45
+ host?: string;
46
+ port?: number;
47
+ allowRemote?: boolean;
48
+ publicOrigin?: string;
49
+ corsOrigins?: string[];
50
+ tokenEnv?: string;
51
+ }
48
52
  export interface AgentModelConfig {
49
53
  /** Provider identity used for auth lookup and Model.provider (e.g. openrouter, fireworks, ollama). */
50
54
  provider: string;
@@ -76,20 +80,23 @@ export interface CliConfig {
76
80
  searchPaths: string[];
77
81
  workspacePath: string;
78
82
  memoryPath: string;
79
- /** @deprecated Prefer agents.orchestrator. Kept for legacy single-model configs. */
80
83
  model?: AgentModelConfig;
81
- agents?: {
82
- orchestrator?: AgentModelConfig;
83
- explorer?: AgentModelConfig;
84
- };
85
84
  minSync?: MinSyncMethodConfig;
86
85
  bm25?: Bm25MethodConfig;
87
- jikji?: Record<string, unknown>;
86
+ jikji?: Record<string, unknown> | false;
88
87
  parserOptions?: Record<string, unknown>;
88
+ dupey?: {
89
+ enabled?: boolean;
90
+ binaryPath?: string;
91
+ timeoutMs?: number;
92
+ };
93
+ excludeExactDuplicates?: boolean;
89
94
  /** Trusted datasource skill configuration (skill name → config). */
90
95
  datasources?: DatasourcesConfig;
91
96
  /** Trusted datasource allow-tags/allow-scopes. Absent ⇒ default-deny. */
92
97
  datasourceAccess?: DatasourceAccessContextOptions;
98
+ /** Optional local/deployment settings for the datasource UI. */
99
+ ui?: UiConfig;
93
100
  }
94
101
  export interface ResolveConfigInput {
95
102
  flags: Record<string, string | boolean | undefined>;
@@ -114,7 +121,7 @@ export declare function normalizeEmbedder(raw: unknown, path: string): MinSyncEm
114
121
  /**
115
122
  * Normalize raw indexing method config into a fully-populated shape.
116
123
  *
117
- * - `undefined` / missing key => `{ enabled: true }` (minSync `autoInstall: false`)
124
+ * - `undefined` / missing key => `{ enabled: true, autoInstall: true }`
118
125
  * - `false` => `{ enabled: false }` (disabled marker)
119
126
  * - object merges with `enabled: true` default and is validated
120
127
  *
@@ -133,7 +140,6 @@ export declare function buildAgentOptions(config: CliConfig): Omit<AutoRAGAgentO
133
140
  export declare function resolveModel(config: CliConfig): Model<Api>;
134
141
  export interface ResolvedAgentModel {
135
142
  readonly model: Model<Api>;
136
- readonly explorerModel: Model<Api>;
137
143
  readonly apiKey?: string;
138
144
  readonly providerApiKeys?: Readonly<Record<string, string>>;
139
145
  }
@@ -160,16 +166,15 @@ export interface ResolvedAgentModelRole {
160
166
  }
161
167
  export interface ResolvedAgentModelDetailed {
162
168
  readonly model: Model<Api>;
163
- readonly explorerModel: Model<Api>;
164
169
  readonly apiKey?: string;
165
170
  readonly providerApiKeys?: Readonly<Record<string, string>>;
166
- readonly roles: {
167
- readonly orchestrator: ResolvedAgentModelRole;
168
- readonly explorer: ResolvedAgentModelRole;
169
- };
171
+ readonly role: ResolvedAgentModelRole;
170
172
  }
171
- export declare function resolveAgentModel(config: CliConfig, localOptions?: LoadLocalAutoRAGModelsOptions): ResolvedAgentModel;
172
- export declare function resolveAgentModelDetailed(config: CliConfig, localOptions?: LoadLocalAutoRAGModelsOptions): ResolvedAgentModelDetailed;
173
+ export declare function resolveAgentModel(config: CliConfig, localOptions?: LoadLocalAutoRAGModelOptions): ResolvedAgentModel;
174
+ export declare function resolveAgentModelDetailed(config: CliConfig, localOptions?: LoadLocalAutoRAGModelOptions): ResolvedAgentModelDetailed;
175
+ export declare function readRawConfigObject(path: string): Record<string, unknown>;
176
+ /** Atomically replace a config file, preserving the caller's JSON object. */
177
+ export declare function writeConfigObject(path: string, config: unknown): void;
173
178
  export declare function writeDefaultConfig(path: string, partial: Partial<CliConfig>, opts?: {
174
179
  force?: boolean;
175
180
  atomicCreate?: boolean;