@autorag/librarian 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +3 -0
- package/README.md +229 -487
- package/dist/agent/agent.d.ts +52 -2
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/search-datasource-tool.d.ts +1 -0
- package/dist/agent/search-documents.d.ts +1 -1
- package/dist/agent/search-single-datasource-tool.d.ts +57 -0
- package/dist/agent/web-fetch-tool.d.ts +32 -0
- package/dist/agent/web-search-tool.d.ts +48 -0
- package/dist/cli/command-help.d.ts +1 -0
- package/dist/cli/commands/lite-retrieve.d.ts +24 -0
- package/dist/cli/commands/search.d.ts +6 -0
- package/dist/cli/config.d.ts +20 -0
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +22378 -15702
- package/dist/cli/setup.d.ts +2 -0
- package/dist/core.d.ts +3 -1
- package/dist/core.js +6709 -425
- package/dist/datasource/connector-skill.d.ts +6 -0
- package/dist/datasource/crawler-skill.d.ts +2 -0
- package/dist/datasource/errors.d.ts +26 -0
- package/dist/datasource/index.d.ts +1 -1
- package/dist/datasource/skills/discrawl/client.d.ts +6 -0
- package/dist/datasource/skills/discrawl/index.d.ts +1 -1
- package/dist/datasource/skills/discrawl/types.d.ts +7 -21
- package/dist/datasource/skills/slack/index.d.ts +8 -0
- package/dist/datasource/tool-naming.d.ts +11 -0
- package/dist/filesystem/source-paths.d.ts +6 -2
- package/dist/index.js +6721 -436
- package/dist/minsync/client.d.ts +1 -1
- package/dist/minsync/embedder-config.d.ts +3 -0
- package/dist/minsync/index.d.ts +1 -1
- package/dist/minsync/installer.d.ts +1 -1
- package/dist/minsync/method.d.ts +2 -0
- package/dist/minsync/types.d.ts +14 -1
- package/dist/minsync/workspace.d.ts +6 -0
- package/dist/mirror/index-store.d.ts +17 -0
- package/dist/mirror/sync.d.ts +7 -4
- package/dist/retrieval/engine.d.ts +14 -5
- package/dist/retrieval/index.d.ts +2 -1
- package/dist/retrieval/merger.d.ts +30 -5
- package/dist/retrieval/skip.d.ts +41 -0
- package/dist/retrieval/types.d.ts +23 -2
- package/dist/web/entities.d.ts +10 -0
- package/dist/web/fetch/convert.d.ts +35 -0
- package/dist/web/fetch/feeds.d.ts +37 -0
- package/dist/web/fetch/html-renderer.d.ts +54 -0
- package/dist/web/fetch/index.d.ts +12 -0
- package/dist/web/fetch/negotiate.d.ts +27 -0
- package/dist/web/fetch/page-loader.d.ts +60 -0
- package/dist/web/fetch/render.d.ts +23 -0
- package/dist/web/fetch/turndown/gfm.d.ts +11 -0
- package/dist/web/fetch/turndown/html.d.ts +5 -0
- package/dist/web/fetch/turndown/index.d.ts +10 -0
- package/dist/web/fetch/turndown/service.d.ts +21 -0
- package/dist/web/fetch/turndown/types.d.ts +73 -0
- package/dist/web/fetch/url-target.d.ts +29 -0
- package/dist/web/search/browser-headers.d.ts +17 -0
- package/dist/web/search/browser-loader.d.ts +56 -0
- package/dist/web/search/browser-page.d.ts +41 -0
- package/dist/web/search/credentials.d.ts +10 -0
- package/dist/web/search/format.d.ts +30 -0
- package/dist/web/search/index.d.ts +46 -0
- package/dist/web/search/model-auth.d.ts +36 -0
- package/dist/web/search/provider.d.ts +62 -0
- package/dist/web/search/providers/anthropic.d.ts +9 -0
- package/dist/web/search/providers/base.d.ts +106 -0
- package/dist/web/search/providers/codex.d.ts +9 -0
- package/dist/web/search/providers/duckduckgo.d.ts +22 -0
- package/dist/web/search/providers/ecosia.d.ts +29 -0
- package/dist/web/search/providers/gemini.d.ts +9 -0
- package/dist/web/search/providers/google.d.ts +22 -0
- package/dist/web/search/providers/mojeek.d.ts +24 -0
- package/dist/web/search/providers/parallel.d.ts +10 -0
- package/dist/web/search/providers/perplexity.d.ts +10 -0
- package/dist/web/search/providers/public.d.ts +15 -0
- package/dist/web/search/providers/responses-api.d.ts +26 -0
- package/dist/web/search/providers/searxng.d.ts +19 -0
- package/dist/web/search/providers/startpage.d.ts +25 -0
- package/dist/web/search/providers/utils.d.ts +39 -0
- package/dist/web/search/providers/xai.d.ts +9 -0
- package/dist/web/search/query.d.ts +193 -0
- package/dist/web/search/types.d.ts +198 -0
- package/dist/web/search/utils.d.ts +8 -0
- package/package.json +3 -2
- package/skills/autorag/SKILL.md +5 -2
- package/skills/autorag-doctor/SKILL.md +237 -0
- package/skills/autorag-lite-search/SKILL.md +53 -13
- package/skills/autorag-lite-setup/SKILL.md +28 -13
- package/skills/autorag-setup/SKILL.md +32 -14
package/dist/agent/agent.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ import { type ScanDuplicateDocumentsDetails } from "./dupey-tool.js";
|
|
|
16
16
|
import { type JikjiFindProviderResult } from "./jikji-find-tool.js";
|
|
17
17
|
import { type SearchDocumentDiagnostic, type SearchDocumentsResponse, type SearchDocumentsStreamEvent } from "./search-documents.js";
|
|
18
18
|
import { type WatcherFactory, type WatchRefreshHandle } from "./watch-refresh.js";
|
|
19
|
+
import { type WebFetchToolOptions } from "./web-fetch-tool.js";
|
|
20
|
+
import { type WebSearchToolOptions } from "./web-search-tool.js";
|
|
19
21
|
export interface AutoRefreshOptions {
|
|
20
22
|
readonly intervalMs: number;
|
|
21
23
|
readonly immediate?: boolean;
|
|
@@ -30,6 +32,9 @@ export interface AutoRAGMinSyncRefreshResult {
|
|
|
30
32
|
readonly ok: boolean;
|
|
31
33
|
readonly synced: number;
|
|
32
34
|
readonly reason?: string;
|
|
35
|
+
/** Count of parsed documents excluded from the MinSync index by file name. */
|
|
36
|
+
readonly stagingExcludedCount?: number;
|
|
37
|
+
readonly diagnostics?: readonly SearchDocumentDiagnostic[];
|
|
33
38
|
}
|
|
34
39
|
export interface AutoRAGRefreshResult extends Omit<ParsedMirrorSyncResult, "diagnostics"> {
|
|
35
40
|
readonly diagnostics: readonly SearchDocumentDiagnostic[];
|
|
@@ -111,6 +116,21 @@ export interface AutoRAGAgentOptions {
|
|
|
111
116
|
tools?: AgentTool[];
|
|
112
117
|
minSync?: Omit<MinSyncVectorMethodOptions, "root"> | false;
|
|
113
118
|
jikji?: JikjiOptions | false;
|
|
119
|
+
/**
|
|
120
|
+
* Internet web tools (`web_search` + `web_fetch`), ported from oh-my-pi's
|
|
121
|
+
* provider-chain web module. Default enabled and credential-free: the
|
|
122
|
+
* chain leads with providers that need no user-issued key — model-native
|
|
123
|
+
* search reusing the agent's own model credentials (Gemini grounding,
|
|
124
|
+
* Anthropic/OpenAI/xAI web_search), the anonymous Perplexity ask
|
|
125
|
+
* endpoint, and Parallel's keyless MCP — then scraped engines with
|
|
126
|
+
* headless-browser escalation for bot challenges. A self-hosted
|
|
127
|
+
* SEARXNG_ENDPOINT is the only env-gated option. `false` disables both
|
|
128
|
+
* tools. The `fetch` sub-option tunes or disables `web_fetch` alone.
|
|
129
|
+
* Web tools are always omitted for remote P2P sessions.
|
|
130
|
+
*/
|
|
131
|
+
webSearch?: (WebSearchToolOptions & {
|
|
132
|
+
fetch?: WebFetchToolOptions | false;
|
|
133
|
+
}) | false;
|
|
114
134
|
autoRefresh?: AutoRefreshOptions;
|
|
115
135
|
parserOptions?: DefaultParserRegistryOptions;
|
|
116
136
|
dupey?: DupeyCliOptions | false;
|
|
@@ -147,6 +167,8 @@ export type AutoRAGJikjiPrepareResult = {
|
|
|
147
167
|
export declare class AutoRAGAgent {
|
|
148
168
|
private readonly innerAgent;
|
|
149
169
|
private readonly tools;
|
|
170
|
+
/** Static SEARCH_TOOLS plus the generated per-datasource tool names. */
|
|
171
|
+
private readonly searchToolNames;
|
|
150
172
|
private readonly configuredModel;
|
|
151
173
|
private readonly apiKey;
|
|
152
174
|
private readonly providerApiKeys;
|
|
@@ -159,6 +181,8 @@ export declare class AutoRAGAgent {
|
|
|
159
181
|
private readonly sessions;
|
|
160
182
|
private activeRun;
|
|
161
183
|
private resultCapture;
|
|
184
|
+
/** This agent's model credential for model-native web search (per instance, never shared). */
|
|
185
|
+
private modelNativeSearchAuth;
|
|
162
186
|
private retrievalTrace;
|
|
163
187
|
private preliminaryCallback;
|
|
164
188
|
/** Per-phase thinking levels; undefined marks the legacy single-phase flow. */
|
|
@@ -197,14 +221,12 @@ export declare class AutoRAGAgent {
|
|
|
197
221
|
readonly remoteSession: boolean;
|
|
198
222
|
private activeRetrievalOptions;
|
|
199
223
|
private searchToolCallCount;
|
|
200
|
-
private readonly sourceSearchCallCounts;
|
|
201
224
|
constructor(options: AutoRAGAgentOptions);
|
|
202
225
|
scanDuplicateDocuments(): Promise<ScanDuplicateDocumentsDetails>;
|
|
203
226
|
private withMemoryContext;
|
|
204
227
|
private resolveSessionModel;
|
|
205
228
|
private createSearchSession;
|
|
206
229
|
private configureSearchSession;
|
|
207
|
-
private withPerSourceSearchLimit;
|
|
208
230
|
private recordSearchToolEvent;
|
|
209
231
|
private currentSystemPromptConfig;
|
|
210
232
|
subscribe(listener: Parameters<Agent["subscribe"]>[0]): () => void;
|
|
@@ -239,6 +261,13 @@ export declare class AutoRAGAgent {
|
|
|
239
261
|
* model-visible; unauthorized skills are omitted entirely (default-deny).
|
|
240
262
|
*/
|
|
241
263
|
private buildAuthorizedDatasourceSkills;
|
|
264
|
+
/**
|
|
265
|
+
* Per-connection tool specs for the generated `search_datasource_<id>`
|
|
266
|
+
* tools, built from the same trusted config and access context as
|
|
267
|
+
* {@link buildAuthorizedDatasourceSkills}. One spec per authorized
|
|
268
|
+
* datasource skill; duplicate ids collapse to the first registration.
|
|
269
|
+
*/
|
|
270
|
+
private singleDatasourceToolSpecs;
|
|
242
271
|
/**
|
|
243
272
|
* Resolve an authorized datasource agent skill by model-visible name for the
|
|
244
273
|
* `load_datasource_skill` tool. Returns `undefined` for unknown or
|
|
@@ -273,6 +302,11 @@ export declare class AutoRAGAgent {
|
|
|
273
302
|
/**
|
|
274
303
|
* Path-opaque snapshot of corpus freshness and the last refresh outcome. Runs
|
|
275
304
|
* a cheap parse-free staleness scan (stat only); never parses in this path.
|
|
305
|
+
*
|
|
306
|
+
* Freshness is read from disk, not from this instance's history: a separate CLI
|
|
307
|
+
* process (for example `autorag status` or `autorag lite status`) reports the
|
|
308
|
+
* corpus as current when the last refresh left parsed mirrors behind and no
|
|
309
|
+
* source has changed since.
|
|
276
310
|
*/
|
|
277
311
|
getRefreshStatus(): Promise<AutoRAGRefreshStatus>;
|
|
278
312
|
/**
|
|
@@ -367,6 +401,22 @@ export declare class AutoRAGAgent {
|
|
|
367
401
|
results: RetrievalResult[];
|
|
368
402
|
diagnostics: RetrievalDiagnostic[];
|
|
369
403
|
}>;
|
|
404
|
+
/**
|
|
405
|
+
* Search one datasource connection only. Unlike
|
|
406
|
+
* {@link searchDatasourceDocuments}, which fans out to every authorized
|
|
407
|
+
* datasource and filters afterwards, this registers only the target
|
|
408
|
+
* connection's retrieval methods with the retriever, so no other
|
|
409
|
+
* datasource CLI is spawned at all. Access is still gated by the trusted
|
|
410
|
+
* datasource context: an unknown or unauthorized `datasourceId` yields an
|
|
411
|
+
* empty result set.
|
|
412
|
+
*/
|
|
413
|
+
searchSingleDatasourceDocuments(datasourceId: string, query: string, options?: {
|
|
414
|
+
readonly topK?: number;
|
|
415
|
+
readonly scope?: string;
|
|
416
|
+
}): Promise<{
|
|
417
|
+
results: RetrievalResult[];
|
|
418
|
+
diagnostics: RetrievalDiagnostic[];
|
|
419
|
+
}>;
|
|
370
420
|
/** The retrieval method registry (posix, MinSync, and datasource methods). */
|
|
371
421
|
getMethodRegistry(): RetrievalMethodRegistry;
|
|
372
422
|
/**
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { createSearchAllDocumentsTool, SEARCH_ALL_DOCUMENTS_TOOL_NAME, type Sear
|
|
|
9
9
|
export { createSearchDatasourceDocumentsTool, type DatasourceSearchProvider, SEARCH_DATASOURCE_DOCUMENTS_TOOL_NAME, type SearchDatasourceDocumentsDetails, } from "./search-datasource-tool.js";
|
|
10
10
|
export type { SearchDocumentDiagnostic, SearchDocumentDiagnosticCode, SearchDocumentDiagnosticSeverity, SearchDocumentEvidence, SearchDocumentResult, SearchDocumentsResponse, SearchDocumentsStreamEvent, SearchDocumentWarning, } from "./search-documents.js";
|
|
11
11
|
export { createSearchMinSyncDocumentsTool, SEARCH_MINSYNC_DOCUMENTS_TOOL_NAME, type SearchMinSyncDocumentsDetails, } from "./search-minsync-tool.js";
|
|
12
|
+
export { createSingleDatasourceSearchTools, SEARCH_SINGLE_DATASOURCE_TOOL_PREFIX, type SearchSingleDatasourceDetails, type SingleDatasourceSearchProvider, type SingleDatasourceToolSpec, singleDatasourceToolName, } from "./search-single-datasource-tool.js";
|
|
12
13
|
export { buildSystemPrompt, type SystemPromptConfig } from "./system-prompt.js";
|
|
@@ -26,4 +26,5 @@ export interface DatasourceSearchProvider {
|
|
|
26
26
|
}>;
|
|
27
27
|
}
|
|
28
28
|
export declare function createSearchDatasourceDocumentsTool(provider: DatasourceSearchProvider): AgentTool<typeof searchDatasourceSchema, SearchDatasourceDocumentsDetails>;
|
|
29
|
+
export declare function formatDatasourceResults(results: readonly RetrievalResult[], diagnostics: readonly RetrievalDiagnostic[]): string;
|
|
29
30
|
export {};
|
|
@@ -10,7 +10,7 @@ export type SearchDocumentDiagnosticSeverity = "info" | "warning" | "error";
|
|
|
10
10
|
* (#21/#22) does not require another source-breaking type change; codes not yet
|
|
11
11
|
* emitted are still valid members.
|
|
12
12
|
*/
|
|
13
|
-
export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "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" | "missing-final-emit";
|
|
13
|
+
export type SearchDocumentDiagnosticCode = "empty-query" | "no-verified-results" | "unknown-warning" | "caller-tool-dropped" | "minsync-unavailable" | "minsync-staging-excluded" | "minsync-sync-failed" | "embedder-unavailable" | "embedding-identity-mismatch" | "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" | "missing-final-emit";
|
|
14
14
|
export interface SearchDocumentDiagnostic {
|
|
15
15
|
readonly code: SearchDocumentDiagnosticCode;
|
|
16
16
|
readonly severity: SearchDocumentDiagnosticSeverity;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { RetrievalDiagnostic, RetrievalResult } from "../retrieval/types.js";
|
|
4
|
+
import { type SearchDocumentRetrievalTraceResult } from "./search-documents.js";
|
|
5
|
+
/**
|
|
6
|
+
* Per-datasource search tools.
|
|
7
|
+
*
|
|
8
|
+
* `search_datasource_documents` always fans out to every authorized datasource:
|
|
9
|
+
* the retriever spawns every datasource CLI and only then filters results, so
|
|
10
|
+
* an agent that already knows which connection holds the answer (from memory or
|
|
11
|
+
* from the question itself) still pays for — and receives — every other
|
|
12
|
+
* datasource's hits. These generated tools fix that: one tool per authorized
|
|
13
|
+
* datasource connection (e.g. `search_datasource_discord`,
|
|
14
|
+
* `search_datasource_kakao_work` for a `kakao-work` account alias) whose
|
|
15
|
+
* execution spawns only that connection's retrieval methods.
|
|
16
|
+
*
|
|
17
|
+
* Tools are generated from the configured, access-authorized datasource skills
|
|
18
|
+
* at agent construction, so a datasource that is disabled in config or denied
|
|
19
|
+
* by the trusted access context never appears in the tool list.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SEARCH_SINGLE_DATASOURCE_TOOL_PREFIX = "search_datasource_";
|
|
22
|
+
/** Model-visible tool name for one datasource connection. */
|
|
23
|
+
export declare const singleDatasourceToolName: (datasourceId: string) => string;
|
|
24
|
+
/** Static per-connection descriptor used to generate one tool each. */
|
|
25
|
+
export interface SingleDatasourceToolSpec {
|
|
26
|
+
/** Trusted datasource id (alias-aware, e.g. `kakao-work`). */
|
|
27
|
+
readonly datasourceId: string;
|
|
28
|
+
/** Operator/descriptor-authored context shown in the tool description. */
|
|
29
|
+
readonly description: string;
|
|
30
|
+
/** Authorized instance roots (e.g. `/kakao/personal`) for the description. */
|
|
31
|
+
readonly instanceScopes: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
export interface SingleDatasourceSearchProvider {
|
|
34
|
+
searchSingleDatasourceDocuments(datasourceId: string, query: string, options?: {
|
|
35
|
+
readonly topK?: number;
|
|
36
|
+
readonly scope?: string;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
readonly results: readonly RetrievalResult[];
|
|
39
|
+
readonly diagnostics: readonly RetrievalDiagnostic[];
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export interface SearchSingleDatasourceDetails {
|
|
43
|
+
readonly method: "datasource";
|
|
44
|
+
readonly datasource: string;
|
|
45
|
+
readonly resultCount: number;
|
|
46
|
+
readonly sources: readonly string[];
|
|
47
|
+
readonly diagnostics: readonly RetrievalDiagnostic[];
|
|
48
|
+
/** Top candidates in traceable shape (additive; used for the run's retrieval trace). */
|
|
49
|
+
readonly results?: readonly SearchDocumentRetrievalTraceResult[];
|
|
50
|
+
}
|
|
51
|
+
export declare function createSingleDatasourceSearchTools(provider: SingleDatasourceSearchProvider, specs: readonly SingleDatasourceToolSpec[]): AgentTool<typeof searchSingleDatasourceSchema, SearchSingleDatasourceDetails>[];
|
|
52
|
+
declare const searchSingleDatasourceSchema: Type.TObject<{
|
|
53
|
+
query: Type.TString;
|
|
54
|
+
topK: Type.TOptional<Type.TInteger>;
|
|
55
|
+
scope: Type.TOptional<Type.TString>;
|
|
56
|
+
}>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `web_fetch` agent tool — read a public web page as text/markdown.
|
|
3
|
+
*
|
|
4
|
+
* LLM-facing wrapper around the oh-my-pi-style render pipeline in
|
|
5
|
+
* `src/web/fetch/`: content-negotiation (markdown alternates, `.md` suffix,
|
|
6
|
+
* llms.txt), feed/JSON/text handling, and HTML rendered to markdown through
|
|
7
|
+
* the reader-backend chain. Output is head-truncated like oh-my-pi's
|
|
8
|
+
* read-url integration so one page cannot flood the context.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
11
|
+
import { Type } from "typebox";
|
|
12
|
+
export declare const WEB_FETCH_TOOL_NAME = "web_fetch";
|
|
13
|
+
declare const webFetchSchema: Type.TObject<{
|
|
14
|
+
url: Type.TString;
|
|
15
|
+
raw: Type.TOptional<Type.TBoolean>;
|
|
16
|
+
}>;
|
|
17
|
+
export interface WebFetchToolOptions {
|
|
18
|
+
/** Total fetch/render timeout in seconds (default 30). */
|
|
19
|
+
readonly timeoutSeconds?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface WebFetchToolDetails {
|
|
22
|
+
readonly method: "web_fetch";
|
|
23
|
+
readonly url: string;
|
|
24
|
+
readonly finalUrl: string;
|
|
25
|
+
readonly contentType: string;
|
|
26
|
+
readonly fetchMethod: string;
|
|
27
|
+
readonly truncated: boolean;
|
|
28
|
+
readonly available: boolean;
|
|
29
|
+
readonly error?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function createWebFetchTool(options?: WebFetchToolOptions): AgentTool<typeof webFetchSchema, WebFetchToolDetails>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `web_search` agent tool — internet web search for the librarian agent.
|
|
3
|
+
*
|
|
4
|
+
* LLM-facing wrapper around the oh-my-pi-style provider chain in
|
|
5
|
+
* `src/web/search/`: credential-free end to end (model-native search on the
|
|
6
|
+
* agent's own model credential, the anonymous Perplexity ask endpoint,
|
|
7
|
+
* Parallel's keyless MCP, then the scraped engines), where quota/auth/bot
|
|
8
|
+
* failures automatically fall back down the chain. The model only supplies
|
|
9
|
+
* `query` plus optional hints; provider selection and credentials are never
|
|
10
|
+
* exposed through tool arguments.
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
13
|
+
import { Type } from "typebox";
|
|
14
|
+
import type { ModelNativeSearchAuth } from "../web/search/model-auth.js";
|
|
15
|
+
import type { SearchProviderId } from "../web/search/types.js";
|
|
16
|
+
export declare const WEB_SEARCH_TOOL_NAME = "web_search";
|
|
17
|
+
declare const webSearchSchema: Type.TObject<{
|
|
18
|
+
query: Type.TString;
|
|
19
|
+
recency: Type.TOptional<Type.TUnion<[Type.TLiteral<"day">, Type.TLiteral<"week">, Type.TLiteral<"month">, Type.TLiteral<"year">]>>;
|
|
20
|
+
limit: Type.TOptional<Type.TInteger>;
|
|
21
|
+
num_search_results: Type.TOptional<Type.TInteger>;
|
|
22
|
+
}>;
|
|
23
|
+
export interface WebSearchToolOptions {
|
|
24
|
+
/** Force one provider (default: walk the configured chain). */
|
|
25
|
+
readonly provider?: SearchProviderId;
|
|
26
|
+
/** Prioritize these providers; unlisted providers keep their built-in relative order. */
|
|
27
|
+
readonly order?: readonly SearchProviderId[];
|
|
28
|
+
/** Providers never used by web search, including fallbacks. */
|
|
29
|
+
readonly exclude?: readonly SearchProviderId[];
|
|
30
|
+
/** Per-provider transport hard timeout in seconds (default 60, max 300). */
|
|
31
|
+
readonly timeoutSeconds?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Agent model credential for the model-native providers, read per call so
|
|
34
|
+
* the tool follows its own agent's session model and never another
|
|
35
|
+
* agent's. Returning undefined leaves the env-key fallback in charge.
|
|
36
|
+
*/
|
|
37
|
+
readonly modelAuth?: () => ModelNativeSearchAuth | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface WebSearchToolDetails {
|
|
40
|
+
readonly method: "web_search";
|
|
41
|
+
readonly provider: string;
|
|
42
|
+
readonly resultCount: number;
|
|
43
|
+
readonly sources: readonly string[];
|
|
44
|
+
readonly available: boolean;
|
|
45
|
+
readonly error?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function createWebSearchTool(options?: WebSearchToolOptions): AgentTool<typeof webSearchSchema, WebSearchToolDetails>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function commandUsage(command: string | undefined): string | undefined;
|
|
@@ -2,9 +2,29 @@ import type { CommandContext } from "./types.js";
|
|
|
2
2
|
export interface LiteRetrieveEnvelope {
|
|
3
3
|
readonly ok: true;
|
|
4
4
|
readonly query: string;
|
|
5
|
+
/**
|
|
6
|
+
* True when the last refresh does not cover the current sources. Retrieval still
|
|
7
|
+
* runs; the caller decides whether to trust the result or refresh first.
|
|
8
|
+
*/
|
|
9
|
+
readonly stale: boolean;
|
|
5
10
|
readonly results: readonly LiteRetrieveResultItem[];
|
|
11
|
+
/**
|
|
12
|
+
* Retrieval surfaces that did not run for this query. A consumer that only
|
|
13
|
+
* reads `results` can check `unsearched.length > 0` to learn the answer is
|
|
14
|
+
* partial — for example local MinSync files skipped while an index sync holds
|
|
15
|
+
* the workspace lock, leaving only datasource hits.
|
|
16
|
+
*/
|
|
17
|
+
readonly unsearched: readonly LiteRetrieveUnsearched[];
|
|
6
18
|
readonly diagnostics: readonly LiteRetrieveDiagnostic[];
|
|
7
19
|
}
|
|
20
|
+
export interface LiteRetrieveUnsearched {
|
|
21
|
+
/** Surface label: "minsync" for local files, or the datasource id. */
|
|
22
|
+
readonly surface: string;
|
|
23
|
+
/** Retrieval method names on this surface that did not run. */
|
|
24
|
+
readonly methods: readonly string[];
|
|
25
|
+
/** The underlying failure verbatim, including CLI stderr and exit status. */
|
|
26
|
+
readonly reason: string;
|
|
27
|
+
}
|
|
8
28
|
export interface LiteRetrieveResultItem {
|
|
9
29
|
readonly number: number;
|
|
10
30
|
readonly source: string;
|
|
@@ -18,6 +38,10 @@ export interface LiteRetrieveDiagnostic {
|
|
|
18
38
|
readonly severity: string;
|
|
19
39
|
readonly message: string;
|
|
20
40
|
readonly source?: string;
|
|
41
|
+
/** Why a source is considered stale, e.g. `mtime-and-size-changed`. */
|
|
42
|
+
readonly reason?: string;
|
|
43
|
+
/** Suggested recovery action, e.g. `refresh`. */
|
|
44
|
+
readonly action?: string;
|
|
21
45
|
}
|
|
22
46
|
/**
|
|
23
47
|
* Run the `autorag lite retrieve` command.
|
|
@@ -26,6 +26,12 @@ export declare function classifySearchHealthHint(error: unknown): SearchHealthHi
|
|
|
26
26
|
export interface SearchDeps {
|
|
27
27
|
agentFactory?: (opts: AutoRAGAgentOptions) => Pick<AutoRAGAgent, "searchDocumentsStream">;
|
|
28
28
|
modelResolver?: (config: CliConfig) => ResolvedAgentModel;
|
|
29
|
+
/**
|
|
30
|
+
* Stops the on-demand embedding gateway so the process can exit. Without
|
|
31
|
+
* this the semantic MinSync path's loopback gateway keeps the event loop
|
|
32
|
+
* alive after the search completes and the CLI never exits.
|
|
33
|
+
*/
|
|
34
|
+
stopRuntime?: () => Promise<void>;
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
31
37
|
* Run the `autorag search` command. Returns exit code 0 on success, 2 for
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -31,6 +31,25 @@ export interface RawIndexingMethods {
|
|
|
31
31
|
export interface NormalizedIndexingConfig {
|
|
32
32
|
minSync: MinSyncMethodConfig;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Web tools (`web_search` + `web_fetch`) config. Secrets never appear here:
|
|
36
|
+
* the shipped chain is credential-free (model-native providers reuse the
|
|
37
|
+
* agent's resolved model credentials; perplexity/parallel need nothing), and
|
|
38
|
+
* the only env-gated option is a self-hosted SEARXNG_ENDPOINT.
|
|
39
|
+
*/
|
|
40
|
+
export interface WebSearchCliConfig {
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
provider?: string;
|
|
43
|
+
order?: string[];
|
|
44
|
+
exclude?: string[];
|
|
45
|
+
/** Per-provider transport hard timeout in seconds (1-300). */
|
|
46
|
+
timeoutSeconds?: number;
|
|
47
|
+
fetch?: {
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
/** Total page fetch/render timeout in seconds (1-300). */
|
|
50
|
+
timeoutSeconds?: number;
|
|
51
|
+
} | false;
|
|
52
|
+
}
|
|
34
53
|
export interface P2pConfig {
|
|
35
54
|
enabled?: boolean;
|
|
36
55
|
port?: number;
|
|
@@ -91,6 +110,7 @@ export interface CliConfig {
|
|
|
91
110
|
model?: AgentModelConfig;
|
|
92
111
|
minSync?: MinSyncMethodConfig;
|
|
93
112
|
jikji?: Record<string, unknown> | false;
|
|
113
|
+
webSearch?: WebSearchCliConfig;
|
|
94
114
|
parserOptions?: Record<string, unknown>;
|
|
95
115
|
dupey?: {
|
|
96
116
|
enabled?: boolean;
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
declare const COMMANDS: readonly ["init", "setup", "refresh", "status", "search", "feedback", "evidence", "memory", "index", "watch", "health", "duplicates", "tui", "ui", "serve", "p2p", "lite", "models", "gateway"];
|
|
3
|
+
type CommandName = (typeof COMMANDS)[number];
|
|
4
|
+
export type { CommandName };
|
|
2
5
|
interface ParsedArgs {
|
|
3
6
|
positionals: string[];
|
|
4
7
|
flags: Record<string, string | boolean>;
|
|
@@ -7,4 +10,3 @@ export declare function parseArgs(argv: readonly string[]): ParsedArgs | {
|
|
|
7
10
|
error: string;
|
|
8
11
|
};
|
|
9
12
|
export declare function main(argv: readonly string[]): Promise<number>;
|
|
10
|
-
export {};
|