@autorag/librarian 2.13.0 → 2.13.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 +9 -9
- package/README.md +25 -9
- package/dist/agent/agent.d.ts +12 -6
- package/dist/agent/answer-guidelines.d.ts +3 -3
- package/dist/agent/refresh-progress.d.ts +4 -0
- package/dist/agent/search-documents.d.ts +3 -1
- package/dist/agent/search-progress.d.ts +5 -0
- package/dist/cli/commands/attachments.d.ts +13 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +8688 -6851
- package/dist/convert/installer.d.ts +1 -1
- package/dist/core.js +5969 -4248
- package/dist/datasource/connector-skill.d.ts +1 -2
- package/dist/datasource/connector.d.ts +2 -3
- package/dist/datasource/index.d.ts +1 -2
- package/dist/datasource/sidecar/descriptors.d.ts +14 -1
- package/dist/datasource/sidecar/index.d.ts +4 -0
- package/dist/datasource/sidecar/methods.d.ts +5 -2
- package/dist/datasource/skills/discrawl/attachments.d.ts +139 -0
- package/dist/datasource/skills/discrawl/client.d.ts +11 -1
- package/dist/datasource/skills/discrawl/index.d.ts +2 -1
- package/dist/datasource/skills/discrawl/ranked-method.d.ts +19 -0
- package/dist/datasource/skills/discrawl/sidecar.d.ts +21 -0
- package/dist/datasource/skills/discrawl/skill.d.ts +18 -2
- package/dist/datasource/skills/discrawl/types.d.ts +41 -0
- package/dist/datasource/skills/factory.d.ts +12 -1
- package/dist/datasource/skills/hister/client.d.ts +5 -5
- package/dist/datasource/skills/hister/setup.d.ts +5 -0
- package/dist/datasource/skills/mailcrawl/types.d.ts +18 -0
- package/dist/datasource/skills/spotlight/connector.d.ts +16 -24
- package/dist/datasource/skills/spotlight/index.d.ts +2 -2
- package/dist/datasource/skills/spotlight/skill.d.ts +26 -13
- package/dist/index.js +6027 -4305
- package/dist/mcp/index.js +6021 -4293
- package/dist/minsync/client.d.ts +2 -2
- package/dist/minsync/index.d.ts +1 -1
- package/dist/minsync/installer.d.ts +1 -1
- package/dist/minsync/method.d.ts +3 -3
- package/dist/minsync/process.d.ts +1 -0
- package/dist/minsync/stage.d.ts +361 -0
- package/dist/minsync/types.d.ts +4 -0
- package/dist/minsync/workspace.d.ts +2 -1
- package/dist/mirror/index-store.d.ts +16 -15
- package/dist/mirror/index.d.ts +2 -2
- package/dist/mirror/paths.d.ts +0 -2
- package/dist/mirror/sync.d.ts +6 -15
- package/dist/parser/types.d.ts +2 -2
- package/dist/process/lifecycle.d.ts +10 -0
- package/dist/profiles.js +6525 -4804
- package/dist/retrieval/scope.d.ts +1 -1
- package/package.json +14 -15
- package/skills/autorag-lite-setup/SKILL.md +27 -3
- package/skills/autorag-setup/SKILL.md +32 -8
- package/dist/datasource/skills/mail-export/connector.d.ts +0 -21
- package/dist/datasource/skills/mail-export/index.d.ts +0 -2
- package/dist/datasource/skills/mail-export/skill.d.ts +0 -20
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared {@link DatasourceSkill} implementation for connector-backed
|
|
3
|
-
* datasources (
|
|
4
|
-
* local mail exports, RSS/news).
|
|
3
|
+
* datasources (GitHub, cloud drives, RSS/news, Spotlight).
|
|
5
4
|
*
|
|
6
5
|
* Composition: a trusted {@link DatasourceConnector} fetches documents, a
|
|
7
6
|
* {@link DatasourceChunkStore} persists and lexically indexes them, and this
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Connector contract shared by the built-in datasource skills (
|
|
3
|
-
*
|
|
4
|
-
* RSS/news).
|
|
2
|
+
* Connector contract shared by the built-in datasource skills (GitHub,
|
|
3
|
+
* cloud drives, RSS/news, Spotlight).
|
|
5
4
|
*
|
|
6
5
|
* A *connector* is the trusted, server-configured bridge to one external
|
|
7
6
|
* system. It fetches documents for indexing and NEVER throws — every failure
|
|
@@ -14,13 +14,12 @@ export { HISTER_SKILL_TYPE, HisterClient, type HisterClientOptions, HisterSkill,
|
|
|
14
14
|
export { LarkClient, type LarkClientOptions, LarkSkill, type LarkSkillOptions } from "./skills/lark/index.js";
|
|
15
15
|
export type { LazykatokFailureReason, LazykatokHit, LazykatokOptions, LazykatokSearchMode, LazykatokSearchOptions, LazykatokSearchResult, LazykatokSkillClient, LazykatokSkillOptions, } from "./skills/lazykatok/index.js";
|
|
16
16
|
export { LazykatokBm25Method, LazykatokClient, LazykatokHybridMethod, LazykatokSkill, } from "./skills/lazykatok/index.js";
|
|
17
|
-
export { MailExportConnector, type MailExportConnectorOptions, MailExportSkill, type MailExportSkillOptions, } from "./skills/mail-export/index.js";
|
|
18
17
|
export { MAILCRAWL_MODES, MailcrawlClient, type MailcrawlFailure, type MailcrawlFailureReason, type MailcrawlIndexInfo, MailcrawlMethod, type MailcrawlOptions, type MailcrawlSearchHit, type MailcrawlSearchMode, type MailcrawlSearchResult, MailcrawlSkill, type MailcrawlSyncInfo, type MailcrawlSyncResult, } from "./skills/mailcrawl/index.js";
|
|
19
18
|
export { NotcrawlClient, type NotcrawlOptions, NotionSkill, type NotionSkillOptions, } from "./skills/notion/index.js";
|
|
20
19
|
export { ObsidianBm25Method, type ObsidianMethodOptions, ObsidianSemanticMethod, ObsidianSkill, type ObsidianSkillOptions, } from "./skills/obsidian/index.js";
|
|
21
20
|
export { RssConnector, type RssConnectorOptions, type RssFeedConfig, RssSkill, type RssSkillOptions, } from "./skills/rss/index.js";
|
|
22
21
|
export { SlackSkill, type SlackSkillOptions, SlacrawlClient, type SlacrawlOptions, } from "./skills/slack/index.js";
|
|
23
|
-
export { SpotlightConnector, type SpotlightConnectorOptions, SpotlightSkill, type SpotlightSkillOptions, } from "./skills/spotlight/index.js";
|
|
22
|
+
export { SpotlightConnector, type SpotlightConnectorFailure, type SpotlightConnectorOptions, type SpotlightConnectorResult, SpotlightSkill, type SpotlightSkillOptions, } from "./skills/spotlight/index.js";
|
|
24
23
|
export { TelecrawlClient, type TelecrawlOptions, TelecrawlSkill, type TelecrawlSkillOptions, } from "./skills/telecrawl/index.js";
|
|
25
24
|
export { WacrawlClient, type WacrawlOptions, WacrawlSkill, type WacrawlSkillOptions } from "./skills/wacrawl/index.js";
|
|
26
25
|
export type { DatasourceDiagnostic, DatasourceDiagnosticCode, DatasourceIndexFail, DatasourceIndexOk, DatasourceIndexOptions, DatasourceIndexResult, DatasourceInstance, DatasourceSkill, DatasourceSkillDescriptor, DatasourceSkillManifest, PollingMetadata, SourceDescription, } from "./types.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Declarative description of a crawler's read-only SQLite schema. The sidecar
|
|
3
3
|
* engine (index.ts) is crawler-agnostic: everything that differs between
|
|
4
|
-
* slacrawl, telecrawl, wacrawl and
|
|
4
|
+
* slacrawl, telecrawl, wacrawl and discrawl is expressed here as SQL fragments.
|
|
5
5
|
*
|
|
6
6
|
* Every SQL fragment is a trusted constant authored in this file. User input
|
|
7
7
|
* (the search query, workspace id) is only ever bound as a parameter.
|
|
@@ -44,6 +44,16 @@ export interface CrawlerDescriptor {
|
|
|
44
44
|
readonly fts: {
|
|
45
45
|
readonly table: string;
|
|
46
46
|
readonly joinOn: string;
|
|
47
|
+
/**
|
|
48
|
+
* Optional tokenizer-specific FTS tables the crawler maintains alongside the base index
|
|
49
|
+
* (discrawl's `message_fts_<lang>`). Each table that exists in the attached archive is
|
|
50
|
+
* searched and reciprocal-rank fused with the base table, so rows only the language
|
|
51
|
+
* tokenizer can match still reach the lexical candidate list. Absent tables are ignored.
|
|
52
|
+
*/
|
|
53
|
+
readonly extraTables?: readonly {
|
|
54
|
+
readonly table: string;
|
|
55
|
+
readonly joinOn: string;
|
|
56
|
+
}[];
|
|
47
57
|
};
|
|
48
58
|
/** Extra result columns mapped into hit metadata: a SQL expression and the metadata key it fills. */
|
|
49
59
|
readonly metadata: readonly {
|
|
@@ -59,10 +69,13 @@ export interface CrawlerDescriptor {
|
|
|
59
69
|
/** Path-opaque label for the hierarchy: ["workspaces", ws, "channels", name] etc. */
|
|
60
70
|
readonly hierarchy: (metadata: Readonly<Record<string, unknown>>) => readonly string[];
|
|
61
71
|
}
|
|
72
|
+
/** discrawl's FTS row refers to the stable Discord message id, independent of SQLite rowid. */
|
|
73
|
+
export declare const discordDescriptor: CrawlerDescriptor;
|
|
62
74
|
export declare const CRAWLER_DESCRIPTORS: {
|
|
63
75
|
readonly slack: CrawlerDescriptor;
|
|
64
76
|
readonly telegram: CrawlerDescriptor;
|
|
65
77
|
readonly whatsapp: CrawlerDescriptor;
|
|
78
|
+
readonly discord: CrawlerDescriptor;
|
|
66
79
|
readonly kakao: CrawlerDescriptor;
|
|
67
80
|
};
|
|
68
81
|
export type SidecarCrawlerId = keyof typeof CRAWLER_DESCRIPTORS;
|
|
@@ -66,6 +66,8 @@ export declare class CrawlerSidecar {
|
|
|
66
66
|
private opened;
|
|
67
67
|
/** Identity of the attached crawler file; a crawler that replaces or deletes its archive forces a re-attach. */
|
|
68
68
|
private attached;
|
|
69
|
+
/** Base FTS table plus any language-specific tables present in the attached archive. */
|
|
70
|
+
private ftsTables;
|
|
69
71
|
/**
|
|
70
72
|
* The last query's embedding and ranking. The semantic and hybrid methods of one search ask for the same
|
|
71
73
|
* query, so they share one embedding call and one vector scan. Short-lived, and dropped on any write.
|
|
@@ -90,6 +92,8 @@ export declare class CrawlerSidecar {
|
|
|
90
92
|
private whereParams;
|
|
91
93
|
/** BM25-ranked lexical search. Natural-language queries are OR-ed term by term. */
|
|
92
94
|
searchLexical(query: string, topK: number): SidecarHit[];
|
|
95
|
+
/** Descriptor-declared FTS tables that the attached archive actually defines. */
|
|
96
|
+
private presentExtraTables;
|
|
93
97
|
/** Cosine search over embedded messages. Empty when there is no embedder or the query embedding fails. */
|
|
94
98
|
searchSemantic(query: string, topK: number): Promise<SidecarHit[]>;
|
|
95
99
|
/** Best `pool` stored vectors for `query`, reusing the previous ranking when it already covers `pool`. */
|
|
@@ -8,7 +8,8 @@ import type { CrawlerDescriptor } from "./descriptors.js";
|
|
|
8
8
|
import type { CrawlerSidecar } from "./index.js";
|
|
9
9
|
export type SidecarMode = "bm25" | "hybrid";
|
|
10
10
|
export interface SidecarMethodOptions {
|
|
11
|
-
|
|
11
|
+
/** Resolve lazily when the native CLI owns the archive location. */
|
|
12
|
+
readonly sidecar: CrawlerSidecar | ((signal?: AbortSignal) => Promise<CrawlerSidecar>);
|
|
12
13
|
readonly descriptor: CrawlerDescriptor;
|
|
13
14
|
readonly mode: SidecarMode;
|
|
14
15
|
readonly datasourceId: string;
|
|
@@ -31,4 +32,6 @@ export declare class SidecarRetrievalMethod implements RetrievalMethod {
|
|
|
31
32
|
* answers next and the crawler's CLI search last, so the datasource still searches when the embedder or
|
|
32
33
|
* the sidecar index is down. A leader that answers with no hits is final.
|
|
33
34
|
*/
|
|
34
|
-
export declare function sidecarFirstMethod(options: Omit<SidecarMethodOptions, "mode"
|
|
35
|
+
export declare function sidecarFirstMethod(options: Omit<SidecarMethodOptions, "mode" | "sidecar"> & {
|
|
36
|
+
readonly sidecar: CrawlerSidecar;
|
|
37
|
+
}, cli: RetrievalMethod): RetrievalMethod;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { DiscrawlAttachmentFetchResult, DiscrawlAttachmentListResult, DiscrawlStatusResult } from "./types.js";
|
|
2
|
+
/** Per-connection status file kept at the top of the attachments folder. */
|
|
3
|
+
export declare const DISCORD_ATTACHMENT_STATUS_FILENAME = "download-status.json";
|
|
4
|
+
/**
|
|
5
|
+
* Where a Discord connection's attachments are saved: `<AUTORAG_HOME>/attachments/discord/<connection>`.
|
|
6
|
+
* That is `~/.autorag/attachments/discord/<connection>` for every user on macOS, Linux, and Windows, unless
|
|
7
|
+
* `AUTORAG_HOME` moves the whole AutoRAG home.
|
|
8
|
+
*/
|
|
9
|
+
export declare function discordAttachmentsRoot(connection: string, env?: NodeJS.ProcessEnv): string;
|
|
10
|
+
/**
|
|
11
|
+
* - `downloaded`: the saved file is still byte-identical to what Discord served.
|
|
12
|
+
* - `not-downloaded`: never saved.
|
|
13
|
+
* - `changed`: the saved file was edited. It stays as the user's own file; the original is fetched again.
|
|
14
|
+
* - `missing`: the saved file was deleted, moved, or renamed; the original is fetched again.
|
|
15
|
+
* - `failed`: the last download attempt failed (`error` says why).
|
|
16
|
+
* - `skipped`: discrawl refused the file (for example `too_large`) and it is not retried.
|
|
17
|
+
*/
|
|
18
|
+
export type DiscordAttachmentState = "downloaded" | "not-downloaded" | "changed" | "missing" | "failed" | "skipped";
|
|
19
|
+
export interface DiscordAttachmentRecord {
|
|
20
|
+
readonly attachmentId: string;
|
|
21
|
+
readonly messageId: string;
|
|
22
|
+
readonly guildId: string;
|
|
23
|
+
readonly guildName?: string;
|
|
24
|
+
readonly channelId: string;
|
|
25
|
+
readonly channelName?: string;
|
|
26
|
+
readonly authorName?: string;
|
|
27
|
+
readonly createdAt?: string;
|
|
28
|
+
readonly filename: string;
|
|
29
|
+
readonly contentType?: string;
|
|
30
|
+
readonly size: number;
|
|
31
|
+
readonly state: DiscordAttachmentState;
|
|
32
|
+
/** True when the file is not saved intact and Discord's signed link still works. */
|
|
33
|
+
readonly downloadable: boolean;
|
|
34
|
+
/** When the signed link stops working (Discord signs attachment links for 24 hours). */
|
|
35
|
+
readonly linkExpiresAt?: string;
|
|
36
|
+
/** Saved file, relative to the attachments folder, with `/` separators. */
|
|
37
|
+
readonly path?: string;
|
|
38
|
+
readonly sha256?: string;
|
|
39
|
+
readonly bytes?: number;
|
|
40
|
+
readonly mtimeMs?: number;
|
|
41
|
+
readonly downloadedAt?: string;
|
|
42
|
+
readonly error?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface DiscordAttachmentSummary {
|
|
45
|
+
readonly total: number;
|
|
46
|
+
readonly downloaded: number;
|
|
47
|
+
readonly notDownloaded: number;
|
|
48
|
+
readonly changed: number;
|
|
49
|
+
readonly missing: number;
|
|
50
|
+
readonly failed: number;
|
|
51
|
+
readonly skipped: number;
|
|
52
|
+
/** Not saved intact and still downloadable now. */
|
|
53
|
+
readonly downloadable: number;
|
|
54
|
+
/** Not saved intact and the link already expired: these can no longer be downloaded. */
|
|
55
|
+
readonly expired: number;
|
|
56
|
+
}
|
|
57
|
+
/** What one sync downloaded. */
|
|
58
|
+
export interface DiscordAttachmentRun {
|
|
59
|
+
readonly attempted: number;
|
|
60
|
+
readonly fetched: number;
|
|
61
|
+
readonly failed: number;
|
|
62
|
+
readonly skipped: number;
|
|
63
|
+
readonly bytes: number;
|
|
64
|
+
}
|
|
65
|
+
export interface DiscordAttachmentSyncOk {
|
|
66
|
+
readonly ok: true;
|
|
67
|
+
readonly root: string;
|
|
68
|
+
readonly statusPath: string;
|
|
69
|
+
readonly summary: DiscordAttachmentSummary;
|
|
70
|
+
readonly run: DiscordAttachmentRun;
|
|
71
|
+
readonly records: readonly DiscordAttachmentRecord[];
|
|
72
|
+
}
|
|
73
|
+
export interface DiscordAttachmentSyncFail {
|
|
74
|
+
readonly ok: false;
|
|
75
|
+
readonly reason: "busy" | "discrawl-failed";
|
|
76
|
+
readonly message: string;
|
|
77
|
+
}
|
|
78
|
+
export type DiscordAttachmentSyncResult = DiscordAttachmentSyncOk | DiscordAttachmentSyncFail;
|
|
79
|
+
export interface DiscordAttachmentSyncOptions {
|
|
80
|
+
/** Download every attachment that is not saved intact and whose link still works. */
|
|
81
|
+
readonly download: boolean;
|
|
82
|
+
readonly signal?: AbortSignal;
|
|
83
|
+
}
|
|
84
|
+
/** The discrawl calls the store needs; `DiscrawlClient` implements them. */
|
|
85
|
+
export interface DiscordAttachmentClient {
|
|
86
|
+
status(signal?: AbortSignal): Promise<DiscrawlStatusResult>;
|
|
87
|
+
listAttachments(configPath: string, guildId?: string, signal?: AbortSignal): Promise<DiscrawlAttachmentListResult>;
|
|
88
|
+
fetchAttachments(configPath: string, messageId: string, signal?: AbortSignal): Promise<DiscrawlAttachmentFetchResult>;
|
|
89
|
+
}
|
|
90
|
+
/** What the Discord skill calls after each import; `DiscordAttachmentStore` implements it. */
|
|
91
|
+
export interface DiscordAttachmentSyncer {
|
|
92
|
+
readonly root: string;
|
|
93
|
+
sync(options: DiscordAttachmentSyncOptions): Promise<DiscordAttachmentSyncResult>;
|
|
94
|
+
}
|
|
95
|
+
export interface DiscordAttachmentStoreOptions {
|
|
96
|
+
readonly client: DiscordAttachmentClient;
|
|
97
|
+
/** Attachments folder; see {@link discordAttachmentsRoot}. */
|
|
98
|
+
readonly root: string;
|
|
99
|
+
readonly guildId?: string;
|
|
100
|
+
readonly channelIds?: readonly string[];
|
|
101
|
+
readonly channelNames?: readonly string[];
|
|
102
|
+
readonly now?: () => number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Saves Discord attachments into one folder and keeps `download-status.json` beside them.
|
|
106
|
+
*
|
|
107
|
+
* discrawl does the downloading; AutoRAG never talks to Discord itself. AutoRAG hands discrawl a private
|
|
108
|
+
* config whose `cache_dir` is `.discrawl/` inside the folder, asks it to fetch one message's attachments at a
|
|
109
|
+
* time, and then moves each file to `<server>/<channel>/<original name>`. A saved file is identified by its
|
|
110
|
+
* SHA-256: when the file at the recorded path is gone or its bytes differ, it no longer counts as the
|
|
111
|
+
* attachment. An edited file is left in place as the user's own and the original is saved again beside it
|
|
112
|
+
* under a free name, as long as Discord's signed link still works. Nothing in the folder is ever overwritten
|
|
113
|
+
* or deleted.
|
|
114
|
+
*/
|
|
115
|
+
export declare class DiscordAttachmentStore implements DiscordAttachmentSyncer {
|
|
116
|
+
readonly root: string;
|
|
117
|
+
private readonly client;
|
|
118
|
+
private readonly guildId;
|
|
119
|
+
private readonly channelIds;
|
|
120
|
+
private readonly channelNames;
|
|
121
|
+
private readonly now;
|
|
122
|
+
constructor(options: DiscordAttachmentStoreOptions);
|
|
123
|
+
get statusPath(): string;
|
|
124
|
+
sync(options: DiscordAttachmentSyncOptions): Promise<DiscordAttachmentSyncResult>;
|
|
125
|
+
private syncLocked;
|
|
126
|
+
/** discrawl keeps reading the operator's archive but stores downloads in this folder's private cache. */
|
|
127
|
+
private writeDiscrawlConfig;
|
|
128
|
+
private channelAllowed;
|
|
129
|
+
private isDownloadable;
|
|
130
|
+
/** Re-checks a saved file. Unchanged size and mtime is trusted; anything else is hashed. */
|
|
131
|
+
private verify;
|
|
132
|
+
private download;
|
|
133
|
+
/** Puts a downloaded file at `<server>/<channel>/<name>`, never over an existing file. */
|
|
134
|
+
private place;
|
|
135
|
+
}
|
|
136
|
+
/** Discord signs attachment links with `ex=<hex unix seconds>`. */
|
|
137
|
+
export declare function signedLinkExpiry(url: string | undefined): string | undefined;
|
|
138
|
+
/** The original Discord file name, made safe for macOS, Linux, and Windows. */
|
|
139
|
+
export declare function safeFilename(name: string, attachmentId: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DiscrawlDoctorResult, DiscrawlEmbeddingConfigResult, DiscrawlEmbeddingRuntime, DiscrawlEmbedResult, DiscrawlMetadataResult, DiscrawlOptions, DiscrawlSearchMode, DiscrawlSearchOptions, DiscrawlSearchResult, DiscrawlStatusResult, DiscrawlSyncResult } from "./types.js";
|
|
1
|
+
import type { DiscrawlAttachmentFetchResult, DiscrawlAttachmentListResult, DiscrawlDoctorResult, DiscrawlEmbeddingConfigResult, DiscrawlEmbeddingRuntime, DiscrawlEmbedResult, DiscrawlMetadataResult, DiscrawlOptions, DiscrawlSearchMode, DiscrawlSearchOptions, DiscrawlSearchResult, DiscrawlStatusResult, DiscrawlSyncResult } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Thin external `discrawl` CLI wrapper. Every method spawns the `discrawl`
|
|
4
4
|
* binary as a child process, parses JSON from stdout, and returns a
|
|
@@ -27,8 +27,18 @@ export declare class DiscrawlClient {
|
|
|
27
27
|
sync(signal?: AbortSignal): Promise<DiscrawlSyncResult>;
|
|
28
28
|
embed(limit?: number, rebuild?: boolean, signal?: AbortSignal): Promise<DiscrawlEmbedResult>;
|
|
29
29
|
search(mode: DiscrawlSearchMode, query: string, options?: DiscrawlSearchOptions): Promise<DiscrawlSearchResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Lists every archived attachment with discrawl's fetch bookkeeping. `configPath` is the
|
|
32
|
+
* attachments-only config that points discrawl's `cache_dir` at AutoRAG's attachments folder; it
|
|
33
|
+
* replaces the operator/managed config for this call only.
|
|
34
|
+
*/
|
|
35
|
+
listAttachments(configPath: string, guildId?: string, signal?: AbortSignal): Promise<DiscrawlAttachmentListResult>;
|
|
36
|
+
/** Downloads the attachments of one message into the config's `cache_dir` while their signed links live. */
|
|
37
|
+
fetchAttachments(configPath: string, messageId: string, signal?: AbortSignal): Promise<DiscrawlAttachmentFetchResult>;
|
|
30
38
|
private runJson;
|
|
31
39
|
private run;
|
|
40
|
+
/** Runs with an explicit `--config` and no embedding runtime: attachment commands never embed. */
|
|
41
|
+
private runWithConfig;
|
|
32
42
|
}
|
|
33
43
|
export declare function discrawlWorkspace(options: DiscrawlOptions): string | undefined;
|
|
34
44
|
export declare function nativeGatewayBaseUrl(baseUrl: string): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export { DISCORD_ATTACHMENT_STATUS_FILENAME, type DiscordAttachmentClient, type DiscordAttachmentRecord, type DiscordAttachmentRun, type DiscordAttachmentState, DiscordAttachmentStore, type DiscordAttachmentStoreOptions, type DiscordAttachmentSummary, type DiscordAttachmentSyncer, type DiscordAttachmentSyncOptions, type DiscordAttachmentSyncResult, discordAttachmentsRoot, } from "./attachments.js";
|
|
1
2
|
export { DiscrawlClient, discrawlWorkspace } from "./client.js";
|
|
2
3
|
export { DiscrawlFtsMethod, DiscrawlHybridMethod, type DiscrawlMethodOptions, type DiscrawlSearchClient, DiscrawlSemanticMethod, } from "./methods.js";
|
|
3
4
|
export { DISCRAWL_SOURCE_KIND, discrawlConfigPath, discrawlDatabasePath, discrawlDatasourceRoot, discrawlSourcePath, parseDiscrawlSourcePath, } from "./paths.js";
|
|
4
5
|
export { DiscrawlSkill, type DiscrawlSkillClient, type DiscrawlSkillOptions } from "./skill.js";
|
|
5
|
-
export { DEFAULT_DISCRAWL_BINARY, DEFAULT_DISCRAWL_EMBEDDING_MODEL, DEFAULT_DISCRAWL_EMBEDDING_PROVIDER, DEFAULT_DISCRAWL_MAX_BUFFER_BYTES, DEFAULT_DISCRAWL_MODE, DEFAULT_DISCRAWL_TIMEOUT_MS, type DiscrawlDoctorInfo, type DiscrawlDoctorResult, type DiscrawlEmbeddingConfigResult, type DiscrawlEmbeddingRuntime, type DiscrawlEmbedInfo, type DiscrawlEmbedResult, type DiscrawlFailure, type DiscrawlFailureReason, type DiscrawlMessage, type DiscrawlMetadataInfo, type DiscrawlMetadataResult, type DiscrawlOptions, type DiscrawlSearchHit, type DiscrawlSearchMode, type DiscrawlSearchOptions, type DiscrawlSearchResult, type DiscrawlStatusInfo, type DiscrawlStatusResult, type DiscrawlSyncInfo, type DiscrawlSyncResult, ENGLISH_ONLY_EMBEDDING_MODELS, } from "./types.js";
|
|
6
|
+
export { DEFAULT_DISCRAWL_BINARY, DEFAULT_DISCRAWL_EMBEDDING_MODEL, DEFAULT_DISCRAWL_EMBEDDING_PROVIDER, DEFAULT_DISCRAWL_MAX_BUFFER_BYTES, DEFAULT_DISCRAWL_MODE, DEFAULT_DISCRAWL_TIMEOUT_MS, type DiscrawlAttachmentFetchResult, type DiscrawlAttachmentFetchStats, type DiscrawlAttachmentListResult, type DiscrawlAttachmentRow, type DiscrawlDoctorInfo, type DiscrawlDoctorResult, type DiscrawlEmbeddingConfigResult, type DiscrawlEmbeddingRuntime, type DiscrawlEmbedInfo, type DiscrawlEmbedResult, type DiscrawlFailure, type DiscrawlFailureReason, type DiscrawlMessage, type DiscrawlMetadataInfo, type DiscrawlMetadataResult, type DiscrawlOptions, type DiscrawlSearchHit, type DiscrawlSearchMode, type DiscrawlSearchOptions, type DiscrawlSearchResult, type DiscrawlStatusInfo, type DiscrawlStatusResult, type DiscrawlSyncInfo, type DiscrawlSyncResult, ENGLISH_ONLY_EMBEDDING_MODELS, } from "./types.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../../../retrieval/types.js";
|
|
2
|
+
import type { DiscrawlSearchMode } from "./types.js";
|
|
3
|
+
export interface DiscrawlRankedMethodOptions {
|
|
4
|
+
readonly mode: DiscrawlSearchMode;
|
|
5
|
+
readonly lexical: RetrievalMethod;
|
|
6
|
+
readonly nativeFts: RetrievalMethod;
|
|
7
|
+
readonly semantic: RetrievalMethod;
|
|
8
|
+
readonly workspaceId?: string;
|
|
9
|
+
readonly channelIds?: readonly string[];
|
|
10
|
+
readonly channelNames?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
/** One Discord ranking boundary: native FTS supplements BM25 rather than voting for the same messages again. */
|
|
13
|
+
export declare class DiscrawlRankedMethod implements RetrievalMethod {
|
|
14
|
+
private readonly options;
|
|
15
|
+
constructor(options: DiscrawlRankedMethodOptions);
|
|
16
|
+
describe(): RetrievalMethodDescriptor;
|
|
17
|
+
retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
|
|
18
|
+
private matchesScope;
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ResolveSidecarInput } from "../../sidecar/config.js";
|
|
2
|
+
import { CrawlerSidecar, type CrawlerSidecarOptions } from "../../sidecar/index.js";
|
|
3
|
+
import type { DiscrawlStatusResult } from "./types.js";
|
|
4
|
+
export interface DiscrawlStatusClient {
|
|
5
|
+
status?(signal?: AbortSignal): Promise<DiscrawlStatusResult>;
|
|
6
|
+
}
|
|
7
|
+
export interface DiscrawlSidecarOptions extends Omit<CrawlerSidecarOptions, "crawlerDbPath" | "embedder"> {
|
|
8
|
+
/** Explicit archive path; omitted to discover it through the native client's status command. */
|
|
9
|
+
readonly crawlerDbPath?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Discord reuses its native embeddings; its sidecar provides lexical ranking only. */
|
|
12
|
+
export declare function resolveDiscrawlSidecarOptions(input: Omit<ResolveSidecarInput, "descriptor" | "defaultCrawlerDb">): DiscrawlSidecarOptions | undefined;
|
|
13
|
+
/** Resolves the native archive on first search, without requiring indexing or a second vector store. */
|
|
14
|
+
export declare class DiscrawlSidecar {
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly client;
|
|
17
|
+
private sidecar;
|
|
18
|
+
constructor(options: DiscrawlSidecarOptions, client: DiscrawlStatusClient);
|
|
19
|
+
get(signal?: AbortSignal): Promise<CrawlerSidecar>;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { RetrievalMethod } from "../../../retrieval/types.js";
|
|
2
2
|
import type { DatasourceIndexOptions, DatasourceIndexResult, DatasourceSkill, DatasourceSkillDescriptor, DatasourceSkillManifest, PollingMetadata, SourceDescription } from "../../types.js";
|
|
3
|
+
import type { DiscordAttachmentSyncer } from "./attachments.js";
|
|
3
4
|
import { type DiscrawlSearchClient } from "./methods.js";
|
|
5
|
+
import { type DiscrawlSidecarOptions, type DiscrawlStatusClient } from "./sidecar.js";
|
|
4
6
|
import type { DiscrawlDoctorResult, DiscrawlEmbedResult, DiscrawlSearchMode, DiscrawlSyncResult } from "./types.js";
|
|
5
|
-
export interface DiscrawlSkillClient extends DiscrawlSearchClient {
|
|
7
|
+
export interface DiscrawlSkillClient extends DiscrawlSearchClient, DiscrawlStatusClient {
|
|
6
8
|
doctor(signal?: AbortSignal): Promise<DiscrawlDoctorResult>;
|
|
7
9
|
sync(signal?: AbortSignal): Promise<DiscrawlSyncResult>;
|
|
8
10
|
embed(limit?: number, rebuild?: boolean, signal?: AbortSignal): Promise<DiscrawlEmbedResult>;
|
|
@@ -22,12 +24,19 @@ export interface DiscrawlSkillOptions {
|
|
|
22
24
|
readonly embedLimit?: number;
|
|
23
25
|
readonly channelIds?: readonly string[];
|
|
24
26
|
readonly channelNames?: readonly string[];
|
|
27
|
+
/** Optional lexical-only sidecar. Its archive path is discovered through native status when omitted. */
|
|
28
|
+
readonly sidecar?: DiscrawlSidecarOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Saves attachments right after each successful import, while Discord's 24-hour signed links still work.
|
|
31
|
+
* Built by default (`connector.downloadAttachments: false` disables it); absent means attachments are not downloaded.
|
|
32
|
+
*/
|
|
33
|
+
readonly attachments?: DiscordAttachmentSyncer;
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
36
|
* Discord datasource skill backed by the external `discrawl` CLI.
|
|
28
37
|
*
|
|
29
38
|
* Mirrors the lazykatok model: the CLI owns the archive, the FTS5 index, and the
|
|
30
|
-
* vector index;
|
|
39
|
+
* vector index; an optional read-only sidecar adds BM25 lexical ranking. AutoRAG never calls
|
|
31
40
|
* the Discord API itself and never reads the Discord Desktop cache directly.
|
|
32
41
|
*
|
|
33
42
|
* `index()` runs the CLI's two-phase pipeline — `sync` (incremental, cursor
|
|
@@ -43,6 +52,9 @@ export declare class DiscrawlSkill implements DatasourceSkill {
|
|
|
43
52
|
private readonly embeddingModel;
|
|
44
53
|
private readonly defaultMode;
|
|
45
54
|
private readonly embedLimit;
|
|
55
|
+
private readonly sidecar;
|
|
56
|
+
private readonly retrievalScope;
|
|
57
|
+
private readonly attachments;
|
|
46
58
|
private lastIndexedAt;
|
|
47
59
|
constructor(options: DiscrawlSkillOptions);
|
|
48
60
|
describe(): DatasourceSkillDescriptor;
|
|
@@ -54,8 +66,12 @@ export declare class DiscrawlSkill implements DatasourceSkill {
|
|
|
54
66
|
* beside it; an operator who pins `defaultMode` to `fts` or `semantic` gets exactly that mode.
|
|
55
67
|
*/
|
|
56
68
|
retrievalMethods(): readonly RetrievalMethod[];
|
|
69
|
+
/** Release the optional sidecar without changing the native archive. */
|
|
70
|
+
close(): void;
|
|
57
71
|
describeSources(): readonly SourceDescription[];
|
|
58
72
|
skillManifest(): DatasourceSkillManifest;
|
|
73
|
+
/** Best effort: a failed or expired download never fails the index, and messages stay searchable. */
|
|
74
|
+
private downloadAttachments;
|
|
59
75
|
private runEmbed;
|
|
60
76
|
/**
|
|
61
77
|
* English-only embedders map non-English text into one narrow similarity
|
|
@@ -101,6 +101,11 @@ export interface DiscrawlOptions {
|
|
|
101
101
|
* issue #1413.
|
|
102
102
|
*/
|
|
103
103
|
readonly defaultMode?: DiscrawlSearchMode;
|
|
104
|
+
/**
|
|
105
|
+
* Spawn timeout for `discrawl attachments fetch`. Defaults to the shared connector sync budget, because a
|
|
106
|
+
* burst of attachments downloads far longer than one wiretap import.
|
|
107
|
+
*/
|
|
108
|
+
readonly attachmentTimeoutMs?: number;
|
|
104
109
|
/** Environment overrides merged on top of `process.env` for the child. */
|
|
105
110
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
106
111
|
}
|
|
@@ -203,6 +208,42 @@ export type DiscrawlMetadataResult = DiscrawlOk<DiscrawlMetadataInfo> | Discrawl
|
|
|
203
208
|
export type DiscrawlSyncResult = DiscrawlOk<DiscrawlSyncInfo> | DiscrawlFailure;
|
|
204
209
|
export type DiscrawlEmbedResult = DiscrawlOk<DiscrawlEmbedInfo> | DiscrawlFailure;
|
|
205
210
|
export type DiscrawlSearchResult = DiscrawlSearchOk | DiscrawlFailure;
|
|
211
|
+
/** One row of `discrawl --json attachments`: metadata plus discrawl's own fetch bookkeeping. */
|
|
212
|
+
export interface DiscrawlAttachmentRow {
|
|
213
|
+
readonly attachmentId: string;
|
|
214
|
+
readonly messageId: string;
|
|
215
|
+
readonly guildId: string;
|
|
216
|
+
readonly guildName?: string;
|
|
217
|
+
readonly channelId: string;
|
|
218
|
+
readonly channelName?: string;
|
|
219
|
+
readonly authorName?: string;
|
|
220
|
+
readonly filename: string;
|
|
221
|
+
readonly contentType?: string;
|
|
222
|
+
readonly size: number;
|
|
223
|
+
readonly url?: string;
|
|
224
|
+
readonly proxyUrl?: string;
|
|
225
|
+
/** Path relative to `<cache_dir>/media`, set once discrawl stored the file. */
|
|
226
|
+
readonly mediaPath?: string;
|
|
227
|
+
readonly contentSha256?: string;
|
|
228
|
+
readonly contentSize?: number;
|
|
229
|
+
/** `fetched`, `failed`, a skip reason such as `too_large`, or empty when never attempted. */
|
|
230
|
+
readonly fetchStatus?: string;
|
|
231
|
+
readonly fetchError?: string;
|
|
232
|
+
/** When discrawl last attempted the download (RFC 3339). */
|
|
233
|
+
readonly fetchedAt?: string;
|
|
234
|
+
readonly createdAt?: string;
|
|
235
|
+
}
|
|
236
|
+
/** Result of `discrawl --json attachments fetch`. */
|
|
237
|
+
export interface DiscrawlAttachmentFetchStats {
|
|
238
|
+
readonly attachments: number;
|
|
239
|
+
readonly fetched: number;
|
|
240
|
+
readonly reused: number;
|
|
241
|
+
readonly skipped: number;
|
|
242
|
+
readonly failed: number;
|
|
243
|
+
readonly bytes: number;
|
|
244
|
+
}
|
|
245
|
+
export type DiscrawlAttachmentListResult = DiscrawlOk<readonly DiscrawlAttachmentRow[]> | DiscrawlFailure;
|
|
246
|
+
export type DiscrawlAttachmentFetchResult = DiscrawlOk<DiscrawlAttachmentFetchStats> | DiscrawlFailure;
|
|
206
247
|
/**
|
|
207
248
|
* Search-specific options. Reuses the shared {@link RetrievalOptions} so the
|
|
208
249
|
* retrieval methods can pass their options straight through.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import type { Embedder } from "../../embedding/embedder.js";
|
|
11
11
|
import type { EmbeddingEndpointSource } from "../embedding-env.js";
|
|
12
12
|
import type { DatasourceSkill } from "../types.js";
|
|
13
|
-
import { type DiscrawlEmbeddingRuntime } from "./discrawl/index.js";
|
|
13
|
+
import { DiscordAttachmentStore, type DiscrawlEmbeddingRuntime } from "./discrawl/index.js";
|
|
14
14
|
import { type ObsidianMinSyncOptions } from "./obsidian/index.js";
|
|
15
15
|
/** One configured datasource entry (the trusted `datasources.<name>` value). */
|
|
16
16
|
export interface DatasourceSkillConfig {
|
|
@@ -50,6 +50,17 @@ export interface DatasourceEmbeddingOptions {
|
|
|
50
50
|
/** MinSync binary, embedder and chunking shared with the local-file index; vault indexes run on it too. */
|
|
51
51
|
readonly minSync?: ObsidianMinSyncOptions;
|
|
52
52
|
}
|
|
53
|
+
export interface DiscordAttachmentConnection {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
/** Whether refreshes download automatically (`connector.downloadAttachments !== false`, default on). */
|
|
56
|
+
readonly autoDownload: boolean;
|
|
57
|
+
readonly store: DiscordAttachmentStore;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Every enabled Discord connection's attachments folder, built exactly as a refresh builds it, so
|
|
61
|
+
* `autorag attachments` and the refresh always agree on where files live.
|
|
62
|
+
*/
|
|
63
|
+
export declare function discordAttachmentConnections(config: DatasourcesConfig | undefined, workspaceRoot?: string): readonly DiscordAttachmentConnection[];
|
|
53
64
|
/** Whether the skill's backend exists on `platform`. Names with no platform restriction are always supported. */
|
|
54
65
|
export declare function datasourceSkillSupported(name: string, platform?: NodeJS.Platform): boolean;
|
|
55
66
|
/** Skill names this factory can build on `platform`. */
|
|
@@ -69,11 +69,11 @@ export declare class HisterClient {
|
|
|
69
69
|
* Wrap a free-text question as a Hister query confined to web pages.
|
|
70
70
|
*
|
|
71
71
|
* Hister ANDs bare terms, so a natural-language question would match almost nothing. Plain words become one
|
|
72
|
-
* alternation group `(a|b|c)
|
|
73
|
-
*
|
|
74
|
-
* `field:value`, wildcards, negation) passes through untouched, and a query using any of it is
|
|
75
|
-
* words ANDed, exactly as written. A `sort:` directive is hoisted out of the group because Hister
|
|
76
|
-
* the top level.
|
|
72
|
+
* alternation group `(a|b|c)`, while uppercase `AND`/`OR`/`NOT` tokens in natural-language questions are stripped by
|
|
73
|
+
* {@link normalizeTerm} so Hister 0.21+'s boolean operator parser never rejects casual English phrasing. Hister's own
|
|
74
|
+
* syntax (quoted phrases, `field:value`, wildcards, negation) passes through untouched, and a query using any of it is
|
|
75
|
+
* sent with its plain words ANDed, exactly as written. A `sort:` directive is hoisted out of the group because Hister
|
|
76
|
+
* only honours it at the top level.
|
|
77
77
|
*/
|
|
78
78
|
export declare function buildWebQuery(question: string, domain?: string): string | undefined;
|
|
79
79
|
/** Hister snippets carry `<mark>` highlights and HTML entities; the model reads plain text. */
|
|
@@ -41,6 +41,11 @@ export interface HisterServiceDeps {
|
|
|
41
41
|
readonly semanticEnabled?: boolean;
|
|
42
42
|
readonly reason?: string;
|
|
43
43
|
}>;
|
|
44
|
+
/** Reload a running Hister server's config (`hister reload`, v0.21.0+). Preferred over restarting the service. */
|
|
45
|
+
readonly reload?: (baseUrl: string) => Promise<{
|
|
46
|
+
readonly ok: boolean;
|
|
47
|
+
readonly reason?: string;
|
|
48
|
+
}>;
|
|
44
49
|
/** Restart the Hister service. Omitted means the operator must do it. */
|
|
45
50
|
readonly restart?: () => Promise<{
|
|
46
51
|
readonly ok: boolean;
|
|
@@ -13,7 +13,21 @@ export interface MailcrawlOptions {
|
|
|
13
13
|
readonly backend?: string;
|
|
14
14
|
readonly source?: string;
|
|
15
15
|
readonly fixture?: string;
|
|
16
|
+
/** `source: "files"` (mailcrawl 0.3.0+): `.eml` files, `.mbox`/`.mbx` archives, Apple Mail bundles, or directories. */
|
|
17
|
+
readonly paths?: readonly string[];
|
|
16
18
|
readonly himalayaConfig?: string;
|
|
19
|
+
/** Envelopes fetched per IMAP window (`--page-size`). */
|
|
20
|
+
readonly pageSize?: number;
|
|
21
|
+
/** Simultaneous message reads during Himalaya sync (`--concurrency`, mailcrawl 0.3.0+). */
|
|
22
|
+
readonly concurrency?: number;
|
|
23
|
+
/** Per-message read deadline in milliseconds (`--read-timeout`, mailcrawl 0.3.0+). */
|
|
24
|
+
readonly readTimeoutMs?: number;
|
|
25
|
+
/** Categories re-included over mailcrawl's default exclusions (`--include-category`, mailcrawl 0.3.0+). */
|
|
26
|
+
readonly includeCategories?: readonly string[];
|
|
27
|
+
/** Categories excluded from sync (`--exclude-category`, mailcrawl 0.3.0+). */
|
|
28
|
+
readonly excludeCategories?: readonly string[];
|
|
29
|
+
/** Force vector store rebuild on `index` (`--rebuild`, mailcrawl 0.3.0+). */
|
|
30
|
+
readonly rebuildIndex?: boolean;
|
|
17
31
|
/**
|
|
18
32
|
* Applies to every operation. `sync`/`index` additionally honor
|
|
19
33
|
* `indexTimeoutMs`, because a 0.2.0 native index run is not interactive.
|
|
@@ -45,7 +59,11 @@ export interface MailcrawlSyncInfo {
|
|
|
45
59
|
readonly deleted?: number;
|
|
46
60
|
readonly unchanged?: number;
|
|
47
61
|
readonly chunksAdded?: number;
|
|
62
|
+
readonly excluded?: number;
|
|
63
|
+
readonly files?: number;
|
|
64
|
+
readonly filesRead?: number;
|
|
48
65
|
readonly archiveRevision?: string;
|
|
66
|
+
readonly account?: string;
|
|
49
67
|
readonly messages: number;
|
|
50
68
|
}
|
|
51
69
|
export interface MailcrawlIndexInfo {
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* Full Disk Access: Spotlight returns hits for protected locations (Mail,
|
|
10
|
-
* Messages, Safari data, parts of ~/Library) but reading those files fails
|
|
11
|
-
* with EPERM/EACCES unless the process running AutoRAG (the terminal app or
|
|
12
|
-
* host binary) has Full Disk Access under System Settings -> Privacy &
|
|
13
|
-
* Security. When every content read is denied this maps to the `permission`
|
|
14
|
-
* failure reason with opaque FDA guidance; partial denials surface as
|
|
15
|
-
* count-only warnings. Full absolute paths are exposed in document metadata
|
|
16
|
-
* (`path`) so results stay traceable back to the file on disk — privacy is
|
|
17
|
-
* the operator's responsibility (run AutoRAG with a local LLM if paths must
|
|
18
|
-
* not leave the machine).
|
|
19
|
-
*/
|
|
20
|
-
import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
|
|
1
|
+
import type { ConnectorFetchFail, ConnectorFetchOk } from "../../connector.js";
|
|
2
|
+
export interface SpotlightConnectorFailure extends ConnectorFetchFail {
|
|
3
|
+
readonly stderr?: string;
|
|
4
|
+
readonly stdout?: string;
|
|
5
|
+
readonly code?: number | null;
|
|
6
|
+
}
|
|
7
|
+
export type SpotlightConnectorResult = ConnectorFetchOk | SpotlightConnectorFailure;
|
|
21
8
|
export interface ProcessRunResult {
|
|
22
9
|
readonly ok: boolean;
|
|
23
10
|
readonly stdout: string;
|
|
@@ -30,13 +17,13 @@ export interface ProcessRunResult {
|
|
|
30
17
|
export type ProcessRunner = (command: string, args: readonly string[], timeoutMs: number) => Promise<ProcessRunResult>;
|
|
31
18
|
export type FileReader = (path: string) => Promise<string>;
|
|
32
19
|
export interface SpotlightConnectorOptions {
|
|
33
|
-
/** Trusted Spotlight
|
|
20
|
+
/** Trusted Spotlight filters AND-ed with each user query. Required. */
|
|
34
21
|
readonly queries?: readonly string[];
|
|
35
22
|
/** Trusted directory restricting every query (`mdfind -onlyin`). */
|
|
36
23
|
readonly onlyIn?: string;
|
|
37
24
|
/** Hits kept per query after dedupe. Default 100. */
|
|
38
25
|
readonly maxResultsPerQuery?: number;
|
|
39
|
-
/**
|
|
26
|
+
/** Maximum documents hydrated by one live search. Default 300. */
|
|
40
27
|
readonly maxDocuments?: number;
|
|
41
28
|
/** Characters kept per document body. Default 100000. */
|
|
42
29
|
readonly maxContentChars?: number;
|
|
@@ -51,11 +38,16 @@ export interface SpotlightConnectorOptions {
|
|
|
51
38
|
/** Injectable file reader; defaults to utf8 `fs.readFile`. */
|
|
52
39
|
readonly readFile?: FileReader;
|
|
53
40
|
}
|
|
54
|
-
|
|
41
|
+
/** Executes live Spotlight queries. macOS owns indexing; no local snapshot is collected. */
|
|
42
|
+
export declare class SpotlightConnector {
|
|
55
43
|
private readonly options;
|
|
56
44
|
private readonly run;
|
|
57
45
|
private readonly readFile;
|
|
58
46
|
private readonly platform;
|
|
59
47
|
constructor(options?: SpotlightConnectorOptions);
|
|
60
|
-
|
|
48
|
+
/** Refresh-time health check only: never runs `mdfind` or hydrates files. */
|
|
49
|
+
probe(): Promise<SpotlightConnectorResult>;
|
|
50
|
+
/** Search the current macOS Spotlight index and hydrate only the requested hits. */
|
|
51
|
+
search(query: string, limit?: number, acceptDocument?: (docId: string) => boolean): Promise<SpotlightConnectorResult>;
|
|
52
|
+
private readinessFailure;
|
|
61
53
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type FileReader, type ProcessRunner, type ProcessRunResult, SpotlightConnector, type SpotlightConnectorOptions, } from "./connector.js";
|
|
2
|
-
export {
|
|
1
|
+
export { type FileReader, type ProcessRunner, type ProcessRunResult, SpotlightConnector, type SpotlightConnectorFailure, type SpotlightConnectorOptions, type SpotlightConnectorResult, } from "./connector.js";
|
|
2
|
+
export { SpotlightSkill, type SpotlightSkillOptions } from "./skill.js";
|