@autorag/librarian 2.0.0 → 2.1.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 (50) hide show
  1. package/README.md +45 -1
  2. package/dist/agent/search-documents.d.ts +1 -0
  3. package/dist/cli/config.d.ts +6 -0
  4. package/dist/cli/index.js +3423 -306
  5. package/dist/datasource/chunk-store.d.ts +67 -0
  6. package/dist/datasource/connector-skill.d.ts +107 -0
  7. package/dist/datasource/connector.d.ts +72 -0
  8. package/dist/datasource/http.d.ts +49 -0
  9. package/dist/datasource/index.d.ts +14 -0
  10. package/dist/datasource/skills/discord/connector.d.ts +30 -0
  11. package/dist/datasource/skills/discord/index.d.ts +2 -0
  12. package/dist/datasource/skills/discord/skill.d.ts +20 -0
  13. package/dist/datasource/skills/factory.d.ts +35 -0
  14. package/dist/datasource/skills/gdrive/connector.d.ts +30 -0
  15. package/dist/datasource/skills/gdrive/index.d.ts +3 -0
  16. package/dist/datasource/skills/gdrive/rclone-connector.d.ts +51 -0
  17. package/dist/datasource/skills/gdrive/skill.d.ts +24 -0
  18. package/dist/datasource/skills/github/connector.d.ts +28 -0
  19. package/dist/datasource/skills/github/index.d.ts +2 -0
  20. package/dist/datasource/skills/github/skill.d.ts +20 -0
  21. package/dist/datasource/skills/gmail/connector.d.ts +30 -0
  22. package/dist/datasource/skills/gmail/himalaya-connector.d.ts +40 -0
  23. package/dist/datasource/skills/gmail/index.d.ts +3 -0
  24. package/dist/datasource/skills/gmail/skill.d.ts +24 -0
  25. package/dist/datasource/skills/mail-export/connector.d.ts +21 -0
  26. package/dist/datasource/skills/mail-export/index.d.ts +2 -0
  27. package/dist/datasource/skills/mail-export/skill.d.ts +20 -0
  28. package/dist/datasource/skills/notion/connector.d.ts +26 -0
  29. package/dist/datasource/skills/notion/index.d.ts +2 -0
  30. package/dist/datasource/skills/notion/skill.d.ts +20 -0
  31. package/dist/datasource/skills/obsidian/connector.d.ts +22 -0
  32. package/dist/datasource/skills/obsidian/index.d.ts +2 -0
  33. package/dist/datasource/skills/obsidian/skill.d.ts +20 -0
  34. package/dist/datasource/skills/rss/connector.d.ts +28 -0
  35. package/dist/datasource/skills/rss/index.d.ts +2 -0
  36. package/dist/datasource/skills/rss/skill.d.ts +22 -0
  37. package/dist/datasource/skills/slack/connector.d.ts +28 -0
  38. package/dist/datasource/skills/slack/index.d.ts +2 -0
  39. package/dist/datasource/skills/slack/skill.d.ts +20 -0
  40. package/dist/datasource/skills/spotlight/connector.d.ts +59 -0
  41. package/dist/datasource/skills/spotlight/index.d.ts +2 -0
  42. package/dist/datasource/skills/spotlight/skill.d.ts +20 -0
  43. package/dist/index.js +3267 -152
  44. package/dist/parser/defaults.d.ts +2 -0
  45. package/dist/parser/hwp-markdown.d.ts +25 -0
  46. package/dist/parser/hwp.d.ts +7 -0
  47. package/dist/parser/index.d.ts +2 -1
  48. package/dist/parser/rhwp-adapter.d.ts +30 -0
  49. package/package.json +3 -2
  50. package/skills/autorag-setup/SKILL.md +52 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Persistent chunk store shared by the connector-backed datasource skills.
3
+ *
4
+ * Documents fetched by a {@link DatasourceConnector} are split into bounded
5
+ * chunks, persisted as JSON under
6
+ * `<workspaceRoot>/.autorag/datasources/<skill>/<instance>/chunks.json`, and
7
+ * searched with a lightweight BM25-style lexical scorer. The store never
8
+ * throws from load/search; persistence failures degrade to in-memory-only
9
+ * operation.
10
+ */
11
+ import type { ConnectorDocument } from "./connector.js";
12
+ export interface StoredChunk {
13
+ readonly chunkId: string;
14
+ readonly docId: string;
15
+ /** Sanitized hierarchy segments under the instance root. */
16
+ readonly hierarchy: readonly string[];
17
+ readonly title?: string;
18
+ readonly content: string;
19
+ readonly publishedAt?: number;
20
+ readonly metadata: Readonly<Record<string, unknown>>;
21
+ }
22
+ export interface ScoredChunk {
23
+ readonly chunk: StoredChunk;
24
+ readonly score: number;
25
+ }
26
+ export interface DatasourceChunkStoreOptions {
27
+ readonly skillName: string;
28
+ readonly instanceId: string;
29
+ /** When set, chunks are persisted under `.autorag/datasources/…`. */
30
+ readonly workspaceRoot?: string;
31
+ /** Maximum characters per chunk. Default 2000. */
32
+ readonly maxChunkChars?: number;
33
+ }
34
+ export declare function datasourceChunkStorePath(workspaceRoot: string, skillName: string, instanceId: string): string;
35
+ export declare class DatasourceChunkStore {
36
+ private readonly skillName;
37
+ private readonly instanceId;
38
+ private readonly storePath;
39
+ private readonly maxChunkChars;
40
+ private chunkList;
41
+ private loaded;
42
+ constructor(options: DatasourceChunkStoreOptions);
43
+ /**
44
+ * Replace the store contents with chunks derived from `documents`.
45
+ * Returns the resulting chunk count. Persistence failures are swallowed
46
+ * (in-memory contents stay authoritative for this process).
47
+ */
48
+ replaceDocuments(documents: readonly ConnectorDocument[]): number;
49
+ /** Load persisted chunks when present. Returns true when data was loaded. */
50
+ load(): boolean;
51
+ /** Ensure persisted chunks are loaded once for read paths. */
52
+ ensureLoaded(): void;
53
+ chunks(): readonly StoredChunk[];
54
+ /** Distinct hierarchy prefixes present in the store (for source listing). */
55
+ hierarchies(): readonly (readonly string[])[];
56
+ /**
57
+ * BM25-style lexical search over the stored chunks. Empty queries and
58
+ * empty stores return `[]`; this method never throws.
59
+ *
60
+ * Terms match document tokens exactly or as a prefix (min 2 chars), so
61
+ * agglutinative suffixes — Korean particles/endings (인증서 → 인증서를) and
62
+ * English inflections (index → indexing) — still rank. Prefix hits are
63
+ * slightly discounted against exact hits.
64
+ */
65
+ search(query: string, topK: number): readonly ScoredChunk[];
66
+ private persist;
67
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Shared {@link DatasourceSkill} implementation for connector-backed
3
+ * datasources (Slack, Discord, Notion, GitHub, Google Drive, Gmail/IMAP,
4
+ * local mail exports, Obsidian vaults, RSS/news).
5
+ *
6
+ * Composition: a trusted {@link DatasourceConnector} fetches documents, a
7
+ * {@link DatasourceChunkStore} persists and lexically indexes them, and this
8
+ * class exposes the standard skill surface — descriptor, polling metadata,
9
+ * ok/fail indexing with traceable diagnostics, retrieval methods routed
10
+ * through the shared pipeline, source descriptions, and a
11
+ * progressive-disclosure agent-skill manifest.
12
+ *
13
+ * Invariants:
14
+ * - Constructed only from trusted, server-supplied configuration.
15
+ * - Sources are stable slash-hierarchical paths `/<skill>/<instance>/…`.
16
+ * - `index()` never throws; failures surface as traceable diagnostics.
17
+ * - Retrieval honors `scope` and `allowedScopes` narrowing; tool arguments
18
+ * can never widen access (enforced upstream by DatasourceAccessContext).
19
+ * - Results and metadata may carry real file paths or account identifiers;
20
+ * privacy is the operator's responsibility (use a local LLM).
21
+ */
22
+ import type { RetrievalMethod, RetrievalMethodDescriptor, RetrievalOptions, RetrievalResult } from "../retrieval/types.js";
23
+ import { DatasourceChunkStore } from "./chunk-store.js";
24
+ import type { DatasourceConnector } from "./connector.js";
25
+ import type { DatasourceIndexResult, DatasourceSkill, DatasourceSkillDescriptor, DatasourceSkillManifest, PollingMetadata, SourceDescription } from "./types.js";
26
+ /** Static identity/behavior shared by all instances of one skill kind. */
27
+ export interface ConnectorSkillDefinition {
28
+ /** Stable skill name and datasource id, e.g. `"slack"`. */
29
+ readonly skillName: string;
30
+ /** Skill kind, e.g. `"slack-workspace"`. */
31
+ readonly skillType: string;
32
+ /** One-line descriptor description. */
33
+ readonly description: string;
34
+ /** Capability tags such as `"chat"`, `"api"`, `"polling"`. */
35
+ readonly capabilities: readonly string[];
36
+ /** Default authorization tags when the server config supplies none. */
37
+ readonly defaultTags: readonly string[];
38
+ /** Content type reported on source descriptions, e.g. `"chat"`. */
39
+ readonly contentType: string;
40
+ /** Short "when to use" text for the system-prompt skills block. */
41
+ readonly manifestDescription: string;
42
+ /** Extra path-opaque manifest body lines (after the standard sections). */
43
+ readonly manifestNotes?: readonly string[];
44
+ }
45
+ export interface ConnectorSkillOptions {
46
+ readonly connector: DatasourceConnector;
47
+ readonly instanceId?: string;
48
+ readonly instances?: readonly string[];
49
+ /** Poll interval in ms. Default 15 minutes; `0` disables polling. */
50
+ readonly pollingIntervalMs?: number;
51
+ readonly tags?: readonly string[];
52
+ readonly lastIndexedAt?: number;
53
+ /** Workspace root for chunk persistence; omitted ⇒ in-memory only. */
54
+ readonly workspaceRoot?: string;
55
+ readonly maxChunkChars?: number;
56
+ /**
57
+ * Dedupe window in ms: when > 0, documents whose `docId` was already
58
+ * indexed within the window keep their previous timestamp identity and
59
+ * duplicates inside one fetch are dropped (RSS/news re-delivery).
60
+ */
61
+ readonly dedupeWindowMs?: number;
62
+ }
63
+ export declare class ConnectorDatasourceSkill implements DatasourceSkill {
64
+ protected readonly definition: ConnectorSkillDefinition;
65
+ protected readonly connector: DatasourceConnector;
66
+ protected readonly instanceId: string;
67
+ protected readonly instances: readonly string[];
68
+ protected readonly pollingIntervalMs: number;
69
+ protected readonly tags: readonly string[];
70
+ protected readonly store: DatasourceChunkStore;
71
+ protected readonly dedupeWindowMs: number;
72
+ private lastIndexedAt;
73
+ private lastPolledAt;
74
+ private lastError;
75
+ /** docId → last-seen epoch ms, for the dedupe window. */
76
+ private readonly seenDocs;
77
+ constructor(definition: ConnectorSkillDefinition, options: ConnectorSkillOptions);
78
+ describe(): DatasourceSkillDescriptor;
79
+ polling(): PollingMetadata;
80
+ index(): Promise<DatasourceIndexResult>;
81
+ retrievalMethods(): readonly RetrievalMethod[];
82
+ describeSources(): readonly SourceDescription[];
83
+ skillManifest(): DatasourceSkillManifest;
84
+ private applyDedupeWindow;
85
+ private fail;
86
+ }
87
+ interface ConnectorLexicalMethodOptions {
88
+ readonly skillName: string;
89
+ readonly skillType: string;
90
+ readonly instanceId: string;
91
+ readonly tags: readonly string[];
92
+ readonly store: DatasourceChunkStore;
93
+ }
94
+ /**
95
+ * Lexical retrieval over a connector skill's chunk store. Failures collapse
96
+ * to an empty result set; retrieval never throws. Sources are opaque
97
+ * `/<skill>/<instance>/chunks/<chunk-id>` paths and are matched against both
98
+ * the user scope and the trusted allowed scopes.
99
+ */
100
+ export declare class ConnectorLexicalMethod implements RetrievalMethod {
101
+ private readonly options;
102
+ constructor(options: ConnectorLexicalMethodOptions);
103
+ describe(): RetrievalMethodDescriptor;
104
+ retrieve(query: string, options: RetrievalOptions): Promise<RetrievalResult[]>;
105
+ private matchesScope;
106
+ }
107
+ export {};
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Connector contract shared by the built-in datasource skills (Slack, Discord,
3
+ * Notion, GitHub, Google Drive, Gmail/IMAP, local mail exports, Obsidian,
4
+ * RSS/news).
5
+ *
6
+ * A *connector* is the trusted, server-configured bridge to one external
7
+ * system. It fetches documents for indexing and NEVER throws — every failure
8
+ * is reported as a discriminated `ok: false` result with a coarse
9
+ * {@link ConnectorFailureReason} and a traceable diagnostic message.
10
+ * Connectors are constructed from server-supplied configuration only;
11
+ * model/tool arguments never reach a connector.
12
+ */
13
+ import type { DatasourceDiagnosticCode } from "./types.js";
14
+ /** Coarse failure classes a connector can report. */
15
+ export type ConnectorFailureReason = "not-configured" | "auth" | "permission" | "rate-limited" | "unavailable" | "api-error" | "invalid-data" | "empty";
16
+ /**
17
+ * One document fetched from the external system. `docId` and `hierarchy`
18
+ * segments are sanitized into opaque slash-safe segments before they become
19
+ * part of a source path.
20
+ */
21
+ export interface ConnectorDocument {
22
+ /** Stable, unique id within the connector instance (pre-sanitization). */
23
+ readonly docId: string;
24
+ /**
25
+ * Optional hierarchy segments under the instance root, e.g.
26
+ * `["channels", "general"]` for a Slack channel or
27
+ * `["folders", "projects"]` for a vault folder.
28
+ */
29
+ readonly hierarchy?: readonly string[];
30
+ readonly title?: string;
31
+ readonly content: string;
32
+ /** Epoch milliseconds of the document's own timestamp when known. */
33
+ readonly publishedAt?: number;
34
+ readonly metadata?: Readonly<Record<string, unknown>>;
35
+ }
36
+ export interface ConnectorFetchOk {
37
+ readonly ok: true;
38
+ readonly documents: readonly ConnectorDocument[];
39
+ /** Sanitized, path/PII-opaque warning strings. */
40
+ readonly warnings?: readonly string[];
41
+ }
42
+ export interface ConnectorFetchFail {
43
+ readonly ok: false;
44
+ readonly reason: ConnectorFailureReason;
45
+ /** Sanitized, path/PII-opaque failure message. */
46
+ readonly message?: string;
47
+ }
48
+ export type ConnectorFetchResult = ConnectorFetchOk | ConnectorFetchFail;
49
+ /**
50
+ * The trusted bridge to one external system. Implementations never throw from
51
+ * `fetch` — they return an `ok: false` result instead.
52
+ */
53
+ export interface DatasourceConnector {
54
+ fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
55
+ }
56
+ /** Map a connector failure reason onto the datasource diagnostic union. */
57
+ export declare function connectorFailureToDiagnosticCode(reason: ConnectorFailureReason): DatasourceDiagnosticCode;
58
+ /**
59
+ * Bound free-form diagnostic text: trimmed and capped at 500 characters.
60
+ * Diagnostic messages are passed through verbatim (paths, account ids, and
61
+ * all) so failures stay traceable; privacy is the operator's responsibility
62
+ * (run AutoRAG with a local LLM if diagnostics must not leave the machine).
63
+ */
64
+ export declare function boundDiagnosticText(value: string): string;
65
+ /**
66
+ * Sanitize an arbitrary string into a slash-safe source-path segment.
67
+ * Unicode letters/digits (e.g. Hangul channel or folder names) are kept so
68
+ * scopes stay human-readable; separators, punctuation, and control chars
69
+ * collapse to `-`. When sanitization loses information, a short hash of the
70
+ * original value is appended so distinct inputs stay distinct.
71
+ */
72
+ export declare function sanitizeIdSegment(value: string): string;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Minimal HTTP helper shared by the API-backed datasource connectors.
3
+ *
4
+ * Every request is bounded by a timeout, honors an optional outer abort
5
+ * signal, and maps failures onto the coarse {@link ConnectorFailureReason}
6
+ * union with short, path/PII-opaque messages (never URLs, tokens, or bodies).
7
+ */
8
+ import type { ConnectorFailureReason } from "./connector.js";
9
+ export interface HttpRequestOptions {
10
+ readonly fetchImpl?: typeof fetch;
11
+ readonly timeoutMs?: number;
12
+ readonly signal?: AbortSignal;
13
+ readonly headers?: Readonly<Record<string, string>>;
14
+ readonly method?: string;
15
+ readonly body?: string;
16
+ }
17
+ export type HttpJsonResult = {
18
+ readonly ok: true;
19
+ readonly status: number;
20
+ readonly json: unknown;
21
+ } | {
22
+ readonly ok: false;
23
+ readonly reason: ConnectorFailureReason;
24
+ readonly message: string;
25
+ };
26
+ export type HttpTextResult = {
27
+ readonly ok: true;
28
+ readonly status: number;
29
+ readonly text: string;
30
+ } | {
31
+ readonly ok: false;
32
+ readonly reason: ConnectorFailureReason;
33
+ readonly message: string;
34
+ };
35
+ /** Map an HTTP status code onto a connector failure reason. */
36
+ export declare function statusToReason(status: number): ConnectorFailureReason;
37
+ /** GET/POST a URL and return the body text; never throws. */
38
+ export declare function httpText(url: string, options?: HttpRequestOptions): Promise<HttpTextResult>;
39
+ /** GET/POST a URL and parse the body as JSON; never throws. */
40
+ export declare function httpJson(url: string, options?: HttpRequestOptions): Promise<HttpJsonResult>;
41
+ /** Narrowing helpers for defensive JSON traversal. */
42
+ export declare function asRecord(value: unknown): Record<string, unknown> | undefined;
43
+ export declare function asArray(value: unknown): readonly unknown[];
44
+ export declare function asString(value: unknown): string | undefined;
45
+ export declare function asNumber(value: unknown): number | undefined;
46
+ /** Parse a date-ish string to epoch ms, or undefined. */
47
+ export declare function parseEpochMs(value: unknown): number | undefined;
48
+ /** Resolve an auth token from explicit config or an environment variable name. */
49
+ export declare function resolveToken(token: string | undefined, tokenEnv: string | undefined): string | undefined;
@@ -1,9 +1,23 @@
1
1
  export { DatasourceAccessContext, type DatasourceAccessContextOptions } from "./access-context.js";
2
+ export { DatasourceChunkStore, type DatasourceChunkStoreOptions, datasourceChunkStorePath, type ScoredChunk, type StoredChunk, } from "./chunk-store.js";
3
+ export { boundDiagnosticText, type ConnectorDocument, type ConnectorFailureReason, type ConnectorFetchFail, type ConnectorFetchOk, type ConnectorFetchResult, connectorFailureToDiagnosticCode, type DatasourceConnector, sanitizeIdSegment, } from "./connector.js";
4
+ export { ConnectorDatasourceSkill, ConnectorLexicalMethod, type ConnectorSkillDefinition, type ConnectorSkillOptions, } from "./connector-skill.js";
2
5
  export { mapDatasourceDiagnostic, mapDatasourceDiagnostics } from "./diagnostics.js";
3
6
  export { type CronParseResult, isDue, parseCronExpr } from "./polling.js";
4
7
  export { DatasourceSkillRegistry, type RegisteredDatasourceSkill } from "./registry.js";
5
8
  export { DatasourceResultFilter, type ResultsByMethod } from "./result-filter.js";
6
9
  export { buildDatasourceChunkSource, buildDatasourceInstanceSource, DATASOURCE_CHUNKS_SEGMENT, datasourceSourceHasFragment, datasourceSourcePath, isDatasourceSource, matchesDatasourceScope, matchesVirtualPathScope, normalizeVirtualPath, } from "./scope.js";
10
+ export { DiscordConnector, type DiscordConnectorOptions, DiscordSkill, type DiscordSkillOptions, } from "./skills/discord/index.js";
11
+ export { BUILTIN_DATASOURCE_SKILL_NAMES, type BuildDatasourceSkillsResult, buildDatasourceSkills, type DatasourceSkillConfig, type DatasourcesConfig, } from "./skills/factory.js";
12
+ export { GDriveConnector, type GDriveConnectorOptions, GDriveSkill, type GDriveSkillOptions, } from "./skills/gdrive/index.js";
13
+ export { GitHubConnector, type GitHubConnectorOptions, GitHubSkill, type GitHubSkillOptions, } from "./skills/github/index.js";
14
+ export { GmailConnector, type GmailConnectorOptions, GmailSkill, type GmailSkillOptions, } from "./skills/gmail/index.js";
7
15
  export type { KatokFailureReason, KatokHit, KatokOptions, KatokSearchMode, KatokSearchOptions, KatokSearchResult, KatokSkillClient, KatokSkillOptions, } from "./skills/katok/index.js";
8
16
  export { KatokBm25Method, KatokClient, KatokSemanticMethod, KatokSkill } from "./skills/katok/index.js";
17
+ export { MailExportConnector, type MailExportConnectorOptions, MailExportSkill, type MailExportSkillOptions, } from "./skills/mail-export/index.js";
18
+ export { NotionConnector, type NotionConnectorOptions, NotionSkill, type NotionSkillOptions, } from "./skills/notion/index.js";
19
+ export { ObsidianConnector, type ObsidianConnectorOptions, ObsidianSkill, type ObsidianSkillOptions, } from "./skills/obsidian/index.js";
20
+ export { RssConnector, type RssConnectorOptions, type RssFeedConfig, RssSkill, type RssSkillOptions, } from "./skills/rss/index.js";
21
+ export { SlackConnector, type SlackConnectorOptions, SlackSkill, type SlackSkillOptions, } from "./skills/slack/index.js";
22
+ export { SpotlightConnector, type SpotlightConnectorOptions, SpotlightSkill, type SpotlightSkillOptions, } from "./skills/spotlight/index.js";
9
23
  export type { DatasourceAccessible, DatasourceDiagnostic, DatasourceDiagnosticCode, DatasourceIndexFail, DatasourceIndexOk, DatasourceIndexResult, DatasourceInstance, DatasourceSkill, DatasourceSkillDescriptor, DatasourceSkillManifest, PollingMetadata, SourceDescription, } from "./types.js";
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Discord guild connector (issue #1305).
3
+ *
4
+ * Fetches text/announcement channel history through the Discord REST API
5
+ * using a trusted, server-configured bot token. Per-channel permission
6
+ * failures degrade to warnings; a guild-level 429 fails the whole fetch as
7
+ * rate-limited. Never throws; all messages stay path/PII-opaque.
8
+ */
9
+ import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
+ export interface DiscordConnectorOptions {
11
+ /** Discord REST base; override to point at a mock server in tests. */
12
+ readonly baseUrl?: string;
13
+ /** Bot token; explicit value wins over {@link tokenEnv}. */
14
+ readonly token?: string;
15
+ /** Env var name holding the bot token. Default `DISCORD_BOT_TOKEN`. */
16
+ readonly tokenEnv?: string;
17
+ /** Guild (server) id to index. Required trusted configuration. */
18
+ readonly guildId?: string;
19
+ /** Restrict indexing to these channel names or ids. */
20
+ readonly channels?: readonly string[];
21
+ readonly timeoutMs?: number;
22
+ readonly fetchImpl?: typeof fetch;
23
+ readonly maxPages?: number;
24
+ readonly maxDocuments?: number;
25
+ }
26
+ export declare class DiscordConnector implements DatasourceConnector {
27
+ private readonly options;
28
+ constructor(options?: DiscordConnectorOptions);
29
+ fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
30
+ }
@@ -0,0 +1,2 @@
1
+ export { DiscordConnector, type DiscordConnectorOptions } from "./connector.js";
2
+ export { DISCORD_SKILL_DEFINITION, DiscordSkill, type DiscordSkillOptions } from "./skill.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Discord guild datasource skill (issue #1305).
3
+ *
4
+ * Thin composition of DiscordConnector with the shared
5
+ * {@link ConnectorDatasourceSkill} base: descriptor, polling metadata,
6
+ * ok/fail indexing with path/PII-opaque diagnostics, lexical retrieval via
7
+ * the shared pipeline, opaque `/discord/<instance>/…` sources, and a
8
+ * progressive-disclosure agent-skill manifest.
9
+ */
10
+ import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
11
+ import { DiscordConnector, type DiscordConnectorOptions } from "./connector.js";
12
+ export declare const DISCORD_SKILL_DEFINITION: ConnectorSkillDefinition;
13
+ export interface DiscordSkillOptions extends Omit<ConnectorSkillOptions, "connector"> {
14
+ /** Trusted connector configuration; a pre-built connector wins. */
15
+ readonly connector?: DiscordConnector;
16
+ readonly connectorOptions?: DiscordConnectorOptions;
17
+ }
18
+ export declare class DiscordSkill extends ConnectorDatasourceSkill {
19
+ constructor(options?: DiscordSkillOptions);
20
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Config-driven factory for the built-in connector-backed datasource skills.
3
+ *
4
+ * The CLI/server layer passes the trusted `datasources` section of
5
+ * `config.json`; this factory materializes one skill per configured entry.
6
+ * Model/tool arguments never reach this factory — it is part of the trusted
7
+ * configuration path. Unknown skill names and disabled entries are skipped
8
+ * and reported so setup surfaces actionable (but path-opaque) feedback.
9
+ */
10
+ import type { DatasourceSkill } from "../types.js";
11
+ /** One configured datasource entry (the trusted `datasources.<name>` value). */
12
+ export interface DatasourceSkillConfig {
13
+ readonly enabled?: boolean;
14
+ readonly instanceId?: string;
15
+ readonly pollingIntervalMs?: number;
16
+ readonly tags?: readonly string[];
17
+ /** Connector-specific options (token env names, repos, feeds, paths, …). */
18
+ readonly connector?: Record<string, unknown>;
19
+ }
20
+ /** The trusted `datasources` config section: skill name → config. */
21
+ export type DatasourcesConfig = Readonly<Record<string, DatasourceSkillConfig | boolean>>;
22
+ export interface BuildDatasourceSkillsResult {
23
+ readonly skills: readonly DatasourceSkill[];
24
+ /** Names that were configured but not recognized. */
25
+ readonly unknown: readonly string[];
26
+ }
27
+ /** Skill names this factory can build. */
28
+ export declare const BUILTIN_DATASOURCE_SKILL_NAMES: readonly string[];
29
+ /**
30
+ * Build datasource skills from the trusted config section. `false` or
31
+ * `{ enabled: false }` entries are skipped silently; unrecognized names are
32
+ * collected in `unknown` (never thrown) so callers can surface setup
33
+ * feedback without failing agent construction.
34
+ */
35
+ export declare function buildDatasourceSkills(config: DatasourcesConfig | undefined, workspaceRoot?: string): BuildDatasourceSkillsResult;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Google Drive connector (issue #1301).
3
+ *
4
+ * Lists files through the Drive v3 API with a trusted, server-configured
5
+ * OAuth access token, exporting Google Docs/Sheets as plain text/CSV and
6
+ * downloading plain-text files. Binary formats are skipped. Per-file export
7
+ * failures degrade to warnings. Never throws; messages stay path/PII-opaque.
8
+ */
9
+ import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
+ export interface GDriveConnectorOptions {
11
+ /** Drive v3 REST base; override to point at a mock server in tests. */
12
+ readonly baseUrl?: string;
13
+ /** OAuth access token; explicit value wins over {@link tokenEnv}. */
14
+ readonly token?: string;
15
+ /** Env var name holding the access token. Default `GDRIVE_ACCESS_TOKEN`. */
16
+ readonly tokenEnv?: string;
17
+ /** Restrict to files whose parent is this folder id. */
18
+ readonly folderId?: string;
19
+ /** Include shared-drive items in listings. */
20
+ readonly includeSharedDrives?: boolean;
21
+ readonly timeoutMs?: number;
22
+ readonly fetchImpl?: typeof fetch;
23
+ readonly maxPages?: number;
24
+ readonly maxDocuments?: number;
25
+ }
26
+ export declare class GDriveConnector implements DatasourceConnector {
27
+ private readonly options;
28
+ constructor(options?: GDriveConnectorOptions);
29
+ fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
30
+ }
@@ -0,0 +1,3 @@
1
+ export { GDriveConnector, type GDriveConnectorOptions } from "./connector.js";
2
+ export { RcloneConnector, type RcloneConnectorOptions, type RcloneRunner, type RcloneRunResult, } from "./rclone-connector.js";
3
+ export { GDRIVE_SKILL_DEFINITION, GDriveSkill, type GDriveSkillOptions } from "./skill.js";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Rclone-backed drive connector (issue #1301, rclone path).
3
+ *
4
+ * Uses the external `rclone` CLI (https://rclone.org) as the trusted bridge
5
+ * to Google Drive — or any of rclone's 70+ storage backends — so OAuth
6
+ * setup and token refresh live entirely in `rclone config`, not here
7
+ * (katok/himalaya pattern). Google Docs/Sheets are transparently exported
8
+ * as text via rclone's `--drive-export-formats`. Never throws; failures map
9
+ * onto the coarse connector failure union with path/PII-opaque messages.
10
+ *
11
+ * Listing: `rclone lsjson <remote> --recursive --files-only`
12
+ * Content: `rclone cat <remote>/<path>` (bounded, text formats only)
13
+ */
14
+ import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
15
+ export interface RcloneRunResult {
16
+ readonly ok: boolean;
17
+ readonly stdout: string;
18
+ readonly stderr: string;
19
+ readonly code: number | null;
20
+ }
21
+ export type RcloneRunner = (args: readonly string[], timeoutMs: number) => Promise<RcloneRunResult>;
22
+ export interface RcloneConnectorOptions {
23
+ /** Path to the rclone binary. Default bare `rclone` PATH lookup. */
24
+ readonly binaryPath?: string;
25
+ /**
26
+ * Rclone remote path, e.g. `gdrive:` or `gdrive:Team/Docs`. Required
27
+ * trusted configuration (`rclone config` defines the remote).
28
+ */
29
+ readonly remote?: string;
30
+ /**
31
+ * Indexable file extensions (lowercase, with dot). Google Docs/Sheets
32
+ * surface as these after `--drive-export-formats txt,csv`.
33
+ */
34
+ readonly extensions?: readonly string[];
35
+ /** Drive export formats forwarded to rclone. Default `txt,csv`. */
36
+ readonly exportFormats?: string;
37
+ /** Max files whose contents are fetched per run. Default 200. */
38
+ readonly maxDocuments?: number;
39
+ /** Files larger than this are skipped. Default 2 MiB. */
40
+ readonly maxBytesPerFile?: number;
41
+ /** Per-spawn timeout. Default 60s (cloud listings can be slow). */
42
+ readonly timeoutMs?: number;
43
+ /** Injectable process runner for tests. */
44
+ readonly runner?: RcloneRunner;
45
+ }
46
+ export declare class RcloneConnector implements DatasourceConnector {
47
+ private readonly options;
48
+ private readonly runner;
49
+ constructor(options?: RcloneConnectorOptions);
50
+ fetch(): Promise<ConnectorFetchResult>;
51
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Google Drive datasource skill (issue #1301).
3
+ *
4
+ * Thin composition of GDriveConnector with the shared
5
+ * {@link ConnectorDatasourceSkill} base: descriptor, polling metadata,
6
+ * ok/fail indexing with path/PII-opaque diagnostics, lexical retrieval via
7
+ * the shared pipeline, opaque `/gdrive/<instance>/…` sources, and a
8
+ * progressive-disclosure agent-skill manifest.
9
+ */
10
+ import type { DatasourceConnector } from "../../connector.js";
11
+ import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
12
+ import { type GDriveConnectorOptions } from "./connector.js";
13
+ export declare const GDRIVE_SKILL_DEFINITION: ConnectorSkillDefinition;
14
+ export interface GDriveSkillOptions extends Omit<ConnectorSkillOptions, "connector"> {
15
+ /**
16
+ * Trusted pre-built connector; wins over {@link connectorOptions}. Accepts
17
+ * any drive-backed connector (Drive REST or the rclone CLI bridge).
18
+ */
19
+ readonly connector?: DatasourceConnector;
20
+ readonly connectorOptions?: GDriveConnectorOptions;
21
+ }
22
+ export declare class GDriveSkill extends ConnectorDatasourceSkill {
23
+ constructor(options?: GDriveSkillOptions);
24
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * GitHub Issues/PRs connector (issue #1303).
3
+ *
4
+ * Fetches issues and pull requests for a trusted list of `owner/repo`
5
+ * targets through the GitHub REST API. A token is optional (public repos
6
+ * work unauthenticated). Per-repo 404s degrade to warnings; 401 fails as
7
+ * auth and rate limiting fails the whole fetch. Never throws.
8
+ */
9
+ import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
+ export interface GitHubConnectorOptions {
11
+ /** GitHub REST base; override to point at a mock server in tests. */
12
+ readonly baseUrl?: string;
13
+ /** Optional token; explicit value wins over {@link tokenEnv}. */
14
+ readonly token?: string;
15
+ /** Env var name holding the token. Default `GITHUB_TOKEN`. */
16
+ readonly tokenEnv?: string;
17
+ /** Repositories to index as `owner/repo`. Required trusted configuration. */
18
+ readonly repos?: readonly string[];
19
+ readonly timeoutMs?: number;
20
+ readonly fetchImpl?: typeof fetch;
21
+ readonly maxPages?: number;
22
+ readonly maxDocuments?: number;
23
+ }
24
+ export declare class GitHubConnector implements DatasourceConnector {
25
+ private readonly options;
26
+ constructor(options?: GitHubConnectorOptions);
27
+ fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
28
+ }
@@ -0,0 +1,2 @@
1
+ export { GitHubConnector, type GitHubConnectorOptions } from "./connector.js";
2
+ export { GITHUB_SKILL_DEFINITION, GitHubSkill, type GitHubSkillOptions } from "./skill.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * GitHub Issues/PRs datasource skill (issue #1303).
3
+ *
4
+ * Thin composition of GitHubConnector with the shared
5
+ * {@link ConnectorDatasourceSkill} base: descriptor, polling metadata,
6
+ * ok/fail indexing with path/PII-opaque diagnostics, lexical retrieval via
7
+ * the shared pipeline, opaque `/github/<instance>/…` sources, and a
8
+ * progressive-disclosure agent-skill manifest.
9
+ */
10
+ import { ConnectorDatasourceSkill, type ConnectorSkillDefinition, type ConnectorSkillOptions } from "../../connector-skill.js";
11
+ import { GitHubConnector, type GitHubConnectorOptions } from "./connector.js";
12
+ export declare const GITHUB_SKILL_DEFINITION: ConnectorSkillDefinition;
13
+ export interface GitHubSkillOptions extends Omit<ConnectorSkillOptions, "connector"> {
14
+ /** Trusted connector configuration; a pre-built connector wins. */
15
+ readonly connector?: GitHubConnector;
16
+ readonly connectorOptions?: GitHubConnectorOptions;
17
+ }
18
+ export declare class GitHubSkill extends ConnectorDatasourceSkill {
19
+ constructor(options?: GitHubSkillOptions);
20
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Gmail connector (issue #1304).
3
+ *
4
+ * Lists and fetches messages through the Gmail REST v1 API with a trusted,
5
+ * server-configured OAuth access token. Per-message fetch failures degrade
6
+ * to warnings. Never throws; messages stay path/PII-opaque (addresses appear
7
+ * only inside indexed chunk content, never in diagnostics).
8
+ */
9
+ import type { ConnectorFetchResult, DatasourceConnector } from "../../connector.js";
10
+ export interface GmailConnectorOptions {
11
+ /** Gmail REST base; override to point at a mock server in tests. */
12
+ readonly baseUrl?: string;
13
+ /** OAuth access token; explicit value wins over {@link tokenEnv}. */
14
+ readonly token?: string;
15
+ /** Env var name holding the access token. Default `GMAIL_ACCESS_TOKEN`. */
16
+ readonly tokenEnv?: string;
17
+ /** Restrict to these label ids (e.g. `["INBOX"]`). */
18
+ readonly labelIds?: readonly string[];
19
+ /** Gmail search query (the `q` parameter). */
20
+ readonly query?: string;
21
+ readonly timeoutMs?: number;
22
+ readonly fetchImpl?: typeof fetch;
23
+ readonly maxPages?: number;
24
+ readonly maxDocuments?: number;
25
+ }
26
+ export declare class GmailConnector implements DatasourceConnector {
27
+ private readonly options;
28
+ constructor(options?: GmailConnectorOptions);
29
+ fetch(signal?: AbortSignal): Promise<ConnectorFetchResult>;
30
+ }