@deepagents/retrieval 0.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 (85) hide show
  1. package/dist/index.d.ts +8 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +8 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/lib/connectors/connector.d.ts +25 -0
  6. package/dist/lib/connectors/connector.d.ts.map +1 -0
  7. package/dist/lib/connectors/connector.js +1 -0
  8. package/dist/lib/connectors/connector.js.map +7 -0
  9. package/dist/lib/connectors/github.d.ts +35 -0
  10. package/dist/lib/connectors/github.d.ts.map +1 -0
  11. package/dist/lib/connectors/github.js +155 -0
  12. package/dist/lib/connectors/github.js.map +7 -0
  13. package/dist/lib/connectors/index.d.ts +8 -0
  14. package/dist/lib/connectors/index.d.ts.map +1 -0
  15. package/dist/lib/connectors/index.js +8 -0
  16. package/dist/lib/connectors/index.js.map +7 -0
  17. package/dist/lib/connectors/linear.d.ts +9 -0
  18. package/dist/lib/connectors/linear.d.ts.map +1 -0
  19. package/dist/lib/connectors/linear.js +29 -0
  20. package/dist/lib/connectors/linear.js.map +7 -0
  21. package/dist/lib/connectors/local.d.ts +7 -0
  22. package/dist/lib/connectors/local.d.ts.map +1 -0
  23. package/dist/lib/connectors/local.js +98 -0
  24. package/dist/lib/connectors/local.js.map +7 -0
  25. package/dist/lib/connectors/pdf.d.ts +4 -0
  26. package/dist/lib/connectors/pdf.d.ts.map +1 -0
  27. package/dist/lib/connectors/pdf.js +58 -0
  28. package/dist/lib/connectors/pdf.js.map +7 -0
  29. package/dist/lib/connectors/repo.d.ts +6 -0
  30. package/dist/lib/connectors/repo.d.ts.map +1 -0
  31. package/dist/lib/connectors/repo.js +171 -0
  32. package/dist/lib/connectors/repo.js.map +7 -0
  33. package/dist/lib/connectors/rss.d.ts +12 -0
  34. package/dist/lib/connectors/rss.d.ts.map +1 -0
  35. package/dist/lib/connectors/rss.js +136 -0
  36. package/dist/lib/connectors/rss.js.map +7 -0
  37. package/dist/lib/embedders/fastembed.d.ts +11 -0
  38. package/dist/lib/embedders/fastembed.d.ts.map +1 -0
  39. package/dist/lib/embedders/fastembed.js +35 -0
  40. package/dist/lib/embedders/fastembed.js.map +7 -0
  41. package/dist/lib/embedders/huggingface.d.ts +14 -0
  42. package/dist/lib/embedders/huggingface.d.ts.map +1 -0
  43. package/dist/lib/embedders/huggingface.js +40 -0
  44. package/dist/lib/embedders/huggingface.js.map +7 -0
  45. package/dist/lib/ingest.d.ts +24 -0
  46. package/dist/lib/ingest.d.ts.map +1 -0
  47. package/dist/lib/ingest.js +111 -0
  48. package/dist/lib/ingest.js.map +7 -0
  49. package/dist/lib/pipeline.d.ts +2 -0
  50. package/dist/lib/pipeline.d.ts.map +1 -0
  51. package/dist/lib/pipeline.js +1 -0
  52. package/dist/lib/pipeline.js.map +7 -0
  53. package/dist/lib/sidecar.d.ts +1 -0
  54. package/dist/lib/sidecar.d.ts.map +1 -0
  55. package/dist/lib/sidecar.js +1 -0
  56. package/dist/lib/sidecar.js.map +7 -0
  57. package/dist/lib/similiarty-search.d.ts +3 -0
  58. package/dist/lib/similiarty-search.d.ts.map +1 -0
  59. package/dist/lib/similiarty-search.js +43 -0
  60. package/dist/lib/similiarty-search.js.map +7 -0
  61. package/dist/lib/stores/cid.d.ts +2 -0
  62. package/dist/lib/stores/cid.d.ts.map +1 -0
  63. package/dist/lib/stores/cid.js +8 -0
  64. package/dist/lib/stores/cid.js.map +7 -0
  65. package/dist/lib/stores/sqlite/bun-sqlite.d.ts +1 -0
  66. package/dist/lib/stores/sqlite/bun-sqlite.d.ts.map +1 -0
  67. package/dist/lib/stores/sqlite/bun-sqlite.js +1 -0
  68. package/dist/lib/stores/sqlite/bun-sqlite.js.map +7 -0
  69. package/dist/lib/stores/sqlite/node-sqlite.d.ts +3 -0
  70. package/dist/lib/stores/sqlite/node-sqlite.d.ts.map +1 -0
  71. package/dist/lib/stores/sqlite/node-sqlite.js +14 -0
  72. package/dist/lib/stores/sqlite/node-sqlite.js.map +7 -0
  73. package/dist/lib/stores/sqlite/sqlite.d.ts +35 -0
  74. package/dist/lib/stores/sqlite/sqlite.d.ts.map +1 -0
  75. package/dist/lib/stores/sqlite/sqlite.js +223 -0
  76. package/dist/lib/stores/sqlite/sqlite.js.map +7 -0
  77. package/dist/lib/stores/sqlite/sqlite.sql.d.ts +3 -0
  78. package/dist/lib/stores/sqlite/sqlite.sql.d.ts.map +1 -0
  79. package/dist/lib/stores/sqlite/sqlite.sql.js +54 -0
  80. package/dist/lib/stores/sqlite/sqlite.sql.js.map +7 -0
  81. package/dist/lib/stores/store.d.ts +28 -0
  82. package/dist/lib/stores/store.d.ts.map +1 -0
  83. package/dist/lib/stores/store.js +1 -0
  84. package/dist/lib/stores/store.js.map +7 -0
  85. package/package.json +47 -0
@@ -0,0 +1,8 @@
1
+ export * from './lib/embedders/fastembed.js';
2
+ export * from './lib/ingest.js';
3
+ export * from './lib/similiarty-search.js';
4
+ export * from './lib/stores/cid.js';
5
+ export * from './lib/stores/sqlite/node-sqlite.js';
6
+ export * from './lib/stores/sqlite/sqlite.js';
7
+ export * from './lib/stores/store.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from "./lib/embedders/fastembed.js";
2
+ export * from "./lib/ingest.js";
3
+ export * from "./lib/similiarty-search.js";
4
+ export * from "./lib/stores/cid.js";
5
+ export * from "./lib/stores/sqlite/node-sqlite.js";
6
+ export * from "./lib/stores/sqlite/sqlite.js";
7
+ export * from "./lib/stores/store.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export * from './lib/embedders/fastembed.js';\nexport * from './lib/ingest.js';\nexport * from './lib/similiarty-search.js';\nexport * from './lib/stores/cid.js';\nexport * from './lib/stores/sqlite/node-sqlite.js';\nexport * from './lib/stores/sqlite/sqlite.js';\nexport * from './lib/stores/store.js';\n// export * from './lib/embedders/huggingface.js';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ export type Connector = {
2
+ /**
3
+ * List of corpuses
4
+ */
5
+ sources: () => AsyncGenerator<{
6
+ id: string;
7
+ content: () => Promise<string>;
8
+ metadata?: Record<string, any> | undefined;
9
+ }, void, unknown>;
10
+ /** Unique identifier for the logical source (group of documents) used in the embedding store. */
11
+ sourceId: string;
12
+ /**
13
+ * Controls ingestion behavior:
14
+ * - 'never': perform ingestion only if the source does NOT yet exist; once created, never re-ingest
15
+ * - 'contentChanged': (default) run ingestion; underlying pipeline will skip unchanged documents
16
+ * - 'expired': only ingest if source doesn't exist OR is expired
17
+ */
18
+ ingestWhen?: 'never' | 'contentChanged' | 'expired';
19
+ /**
20
+ * Optional expiry duration in milliseconds from now.
21
+ * When set, the source will be considered expired after this duration.
22
+ */
23
+ expiresAfter?: number;
24
+ };
25
+ //# sourceMappingURL=connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/connector.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,cAAc,CAC3B;QACE,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;KAC5C,EACD,IAAI,EACJ,OAAO,CACR,CAAC;IACF,iGAAiG;IACjG,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACpD;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=connector.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,35 @@
1
+ import type { Connector } from './connector.ts';
2
+ interface ReleaseFetchOptions {
3
+ /** Stop fetching when this tag is encountered (latest-first order). */
4
+ untilTag?: string;
5
+ /** Include the matching untilTag release (default true). */
6
+ inclusive?: boolean;
7
+ /** Include draft releases (default false). */
8
+ includeDrafts?: boolean;
9
+ /** Include prereleases (default false). */
10
+ includePrerelease?: boolean;
11
+ }
12
+ export declare const github: {
13
+ file(filePath: string): Connector;
14
+ /**
15
+ * Create a connector over GitHub Releases with optional pagination & early-stop.
16
+ * @param repo owner/repo string
17
+ * @param options Release filtering & pagination controls
18
+ */
19
+ release: (repo: string, options?: ReleaseFetchOptions) => Connector;
20
+ /**
21
+ * Create a connector over a GitHub repository file tree using gitingest to produce a markdown digest.
22
+ * @param repoUrl full https://github.com/OWNER/REPO or .../tree/BRANCH/subdir URL
23
+ */
24
+ repo: (repoUrl: string, opts: {
25
+ includes: string[];
26
+ excludes?: string[];
27
+ branch?: string;
28
+ includeGitignored?: boolean;
29
+ includeSubmodules?: boolean;
30
+ githubToken?: string;
31
+ ingestWhen?: "never" | "contentChanged";
32
+ }) => Connector;
33
+ };
34
+ export {};
35
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/github.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,UAAU,mBAAmB;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2CAA2C;IAC3C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAsDD,eAAO,MAAM,MAAM;mBACF,MAAM,GAAG,SAAS;IAcjC;;;;OAIG;oBACa,MAAM,YAAW,mBAAmB,KAAQ,SAAS;IAmBrE;;;OAGG;oBAEQ,MAAM,QACT;QACJ,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;KACzC,KACA,SAAS;CA8Db,CAAC"}
@@ -0,0 +1,155 @@
1
+ import { execa } from "execa";
2
+ function fs(path) {
3
+ const [owner, repo, ...filePath] = path.split("/");
4
+ return {
5
+ readFile: async () => {
6
+ const url = `https://api.github.com/repos/${owner}/${repo}/contents/${filePath.join("/")}`;
7
+ const res = await fetch(url);
8
+ const data = await res.json();
9
+ return atob(data.content);
10
+ },
11
+ release: async (repo2, opts = {}) => {
12
+ const [owner2, repoName] = repo2.split("/");
13
+ const perPage = 100;
14
+ const maxPages = 10;
15
+ const releases = [];
16
+ let stop = false;
17
+ for (let page = 1; page <= maxPages && !stop; page++) {
18
+ const url = `https://api.github.com/repos/${owner2}/${repoName}/releases?per_page=${perPage}&page=${page}`;
19
+ const res = await fetch(url, {
20
+ headers: { Accept: "application/vnd.github+json" }
21
+ });
22
+ if (!res.ok) break;
23
+ const pageData = await res.json();
24
+ if (!pageData.length) break;
25
+ for (const rel of pageData) {
26
+ if (!opts.includeDrafts && rel.draft) continue;
27
+ if (!opts.includePrerelease && rel.prerelease) continue;
28
+ releases.push(rel);
29
+ if (opts.untilTag && rel.tag_name === opts.untilTag) {
30
+ if (opts.inclusive === false) {
31
+ releases.pop();
32
+ }
33
+ stop = true;
34
+ break;
35
+ }
36
+ }
37
+ }
38
+ return releases;
39
+ }
40
+ };
41
+ }
42
+ const github = {
43
+ file(filePath) {
44
+ const sourceId = `github:file:${filePath}`;
45
+ const documentId = filePath;
46
+ return {
47
+ sourceId,
48
+ sources: async function* () {
49
+ const { readFile } = fs(filePath);
50
+ yield {
51
+ id: documentId,
52
+ content: () => readFile()
53
+ };
54
+ }
55
+ };
56
+ },
57
+ /**
58
+ * Create a connector over GitHub Releases with optional pagination & early-stop.
59
+ * @param repo owner/repo string
60
+ * @param options Release filtering & pagination controls
61
+ */
62
+ release: (repo, options = {}) => {
63
+ const sourceId = `github:releases:${repo}`;
64
+ return {
65
+ sourceId,
66
+ sources: async function* () {
67
+ const releases = await fs(repo).release(repo, options);
68
+ for (const rel of releases) {
69
+ yield {
70
+ id: `${repo}:release:${rel.tag_name}`,
71
+ content: async () => {
72
+ const name = rel.name || rel.tag_name;
73
+ const body = rel.body || "";
74
+ return `Release: ${name}
75
+ Tag: ${rel.tag_name}
76
+ Published at: ${rel.published_at}
77
+ Updated at: ${rel.updated_at}
78
+ URL: ${rel.html_url}
79
+ Draft: ${rel.draft}
80
+ Prerelease: ${rel.prerelease}
81
+
82
+ ${body}`;
83
+ }
84
+ };
85
+ }
86
+ }
87
+ };
88
+ },
89
+ /**
90
+ * Create a connector over a GitHub repository file tree using gitingest to produce a markdown digest.
91
+ * @param repoUrl full https://github.com/OWNER/REPO or .../tree/BRANCH/subdir URL
92
+ */
93
+ repo: (repoUrl, opts) => {
94
+ const sourceId = `github:repo:${repoUrl}`;
95
+ const {
96
+ excludes = [
97
+ "**/node_modules/**",
98
+ "**/dist/**",
99
+ "**/coverage/**",
100
+ "**/*.test.ts",
101
+ "**/*.test.tsx",
102
+ "**/dist/**",
103
+ "**/.git/**",
104
+ "**/.github/**",
105
+ "**/.vscode/**",
106
+ "**/.idea/**",
107
+ "**/build/**",
108
+ "**/out/**",
109
+ "**/vendor/**",
110
+ "**/__tests__/**",
111
+ "**/*.d.ts"
112
+ ],
113
+ branch,
114
+ includeGitignored = false,
115
+ includeSubmodules = false,
116
+ githubToken,
117
+ ingestWhen,
118
+ includes
119
+ } = opts;
120
+ async function gitingestDigest() {
121
+ const args = [
122
+ "gitingest",
123
+ ...branch ? ["-b", branch] : [],
124
+ ...includes.flatMap((p) => ["-i", p]),
125
+ ...excludes.flatMap((p) => ["-e", p]),
126
+ ...includeGitignored ? ["--include-gitignored"] : [],
127
+ ...includeSubmodules ? ["--include-submodules"] : [],
128
+ repoUrl,
129
+ "-o",
130
+ "-"
131
+ ];
132
+ const { stdout } = await execa("uvx", args, {
133
+ env: githubToken ? { ...process.env, GITHUB_TOKEN: githubToken } : process.env,
134
+ stdout: "pipe",
135
+ stderr: "inherit"
136
+ });
137
+ return stdout;
138
+ }
139
+ return {
140
+ sourceId,
141
+ ingestWhen,
142
+ sources: async function* () {
143
+ const content = await gitingestDigest();
144
+ yield {
145
+ id: "digest.md",
146
+ content: async () => content
147
+ };
148
+ }
149
+ };
150
+ }
151
+ };
152
+ export {
153
+ github
154
+ };
155
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/connectors/github.ts"],
4
+ "sourcesContent": ["import { execa } from 'execa';\n\nimport type { Connector } from './connector.ts';\n\ninterface ReleaseFetchOptions {\n /** Stop fetching when this tag is encountered (latest-first order). */\n untilTag?: string;\n /** Include the matching untilTag release (default true). */\n inclusive?: boolean;\n /** Include draft releases (default false). */\n includeDrafts?: boolean;\n /** Include prereleases (default false). */\n includePrerelease?: boolean;\n}\n\nfunction fs(path: string) {\n const [owner, repo, ...filePath] = path.split('/');\n return {\n readFile: async () => {\n const url = `https://api.github.com/repos/${owner}/${repo}/contents/${filePath.join('/')}`;\n const res = await fetch(url);\n const data = (await res.json()) as { content: string };\n return atob(data.content);\n },\n release: async (repo: string, opts: ReleaseFetchOptions = {}) => {\n const [owner, repoName] = repo.split('/');\n const perPage = 100; // always fetch max per page for efficiency\n const maxPages = 10; // internal safety cap, not user configurable\n const releases: Array<{\n tag_name: string;\n name: string | null;\n body: string | null;\n updated_at: string;\n published_at: string;\n html_url: string;\n draft: boolean;\n prerelease: boolean;\n }> = [];\n let stop = false;\n\n for (let page = 1; page <= maxPages && !stop; page++) {\n const url = `https://api.github.com/repos/${owner}/${repoName}/releases?per_page=${perPage}&page=${page}`;\n const res = await fetch(url, {\n headers: { Accept: 'application/vnd.github+json' },\n });\n if (!res.ok) break;\n const pageData = (await res.json()) as typeof releases;\n if (!pageData.length) break;\n for (const rel of pageData) {\n if (!opts.includeDrafts && rel.draft) continue;\n if (!opts.includePrerelease && rel.prerelease) continue;\n\n releases.push(rel);\n if (opts.untilTag && rel.tag_name === opts.untilTag) {\n if (opts.inclusive === false) {\n releases.pop();\n }\n stop = true;\n break;\n }\n }\n }\n return releases;\n },\n };\n}\n\nexport const github = {\n file(filePath: string): Connector {\n const sourceId = `github:file:${filePath}`;\n const documentId = filePath;\n return {\n sourceId,\n sources: async function* () {\n const { readFile } = fs(filePath);\n yield {\n id: documentId,\n content: () => readFile(),\n };\n },\n };\n },\n /**\n * Create a connector over GitHub Releases with optional pagination & early-stop.\n * @param repo owner/repo string\n * @param options Release filtering & pagination controls\n */\n release: (repo: string, options: ReleaseFetchOptions = {}): Connector => {\n const sourceId = `github:releases:${repo}`;\n return {\n sourceId,\n sources: async function* () {\n const releases = await fs(repo).release(repo, options);\n for (const rel of releases) {\n yield {\n id: `${repo}:release:${rel.tag_name}`,\n content: async () => {\n const name = rel.name || rel.tag_name;\n const body = rel.body || '';\n return `Release: ${name}\\nTag: ${rel.tag_name}\\nPublished at: ${rel.published_at}\\nUpdated at: ${rel.updated_at}\\nURL: ${rel.html_url}\\nDraft: ${rel.draft}\\nPrerelease: ${rel.prerelease}\\n\\n${body}`;\n },\n };\n }\n },\n };\n },\n /**\n * Create a connector over a GitHub repository file tree using gitingest to produce a markdown digest.\n * @param repoUrl full https://github.com/OWNER/REPO or .../tree/BRANCH/subdir URL\n */\n repo: (\n repoUrl: string,\n opts: {\n includes: string[];\n excludes?: string[];\n branch?: string;\n includeGitignored?: boolean;\n includeSubmodules?: boolean;\n githubToken?: string;\n ingestWhen?: 'never' | 'contentChanged';\n },\n ): Connector => {\n const sourceId = `github:repo:${repoUrl}`;\n const {\n excludes = [\n '**/node_modules/**',\n '**/dist/**',\n '**/coverage/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/dist/**',\n '**/.git/**',\n '**/.github/**',\n '**/.vscode/**',\n '**/.idea/**',\n '**/build/**',\n '**/out/**',\n '**/vendor/**',\n '**/__tests__/**',\n '**/*.d.ts',\n ],\n branch,\n includeGitignored = false,\n includeSubmodules = false,\n githubToken,\n ingestWhen,\n includes,\n } = opts;\n\n async function gitingestDigest(): Promise<string> {\n const args = [\n 'gitingest',\n ...(branch ? ['-b', branch] : []),\n ...includes.flatMap((p) => ['-i', p]),\n ...excludes.flatMap((p) => ['-e', p]),\n ...(includeGitignored ? ['--include-gitignored'] : []),\n ...(includeSubmodules ? ['--include-submodules'] : []),\n repoUrl,\n '-o',\n '-',\n ];\n const { stdout } = await execa('uvx', args, {\n env: githubToken\n ? { ...process.env, GITHUB_TOKEN: githubToken }\n : process.env,\n stdout: 'pipe',\n stderr: 'inherit',\n });\n return stdout;\n }\n\n return {\n sourceId,\n ingestWhen,\n sources: async function* () {\n const content = await gitingestDigest();\n yield {\n id: 'digest.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AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACA,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI;AAEJ,mBAAe,kBAAmC;AAChD,YAAM,OAAO;AAAA,QACX;AAAA,QACA,GAAI,SAAS,CAAC,MAAM,MAAM,IAAI,CAAC;AAAA,QAC/B,GAAG,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAAA,QACpC,GAAG,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAAA,QACpC,GAAI,oBAAoB,CAAC,sBAAsB,IAAI,CAAC;AAAA,QACpD,GAAI,oBAAoB,CAAC,sBAAsB,IAAI,CAAC;AAAA,QACpD;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,YAAM,EAAE,OAAO,IAAI,MAAM,MAAM,OAAO,MAAM;AAAA,QAC1C,KAAK,cACD,EAAE,GAAG,QAAQ,KAAK,cAAc,YAAY,IAC5C,QAAQ;AAAA,QACZ,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV,CAAC;AACD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,SAAS,mBAAmB;AAC1B,cAAM,UAAU,MAAM,gBAAgB;AACtC,cAAM;AAAA,UACJ,IAAI;AAAA,UACJ,SAAS,YAAY;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": ["repo", "owner"]
7
+ }
@@ -0,0 +1,8 @@
1
+ export * from './connector.js';
2
+ export * from './github.js';
3
+ export * from './linear.js';
4
+ export * from './local.js';
5
+ export * from './pdf.js';
6
+ export * from './rss.js';
7
+ export * from './repo.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./connector.js";
2
+ export * from "./github.js";
3
+ export * from "./linear.js";
4
+ export * from "./local.js";
5
+ export * from "./pdf.js";
6
+ export * from "./rss.js";
7
+ export * from "./repo.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/connectors/index.ts"],
4
+ "sourcesContent": ["export * from './connector.js';\nexport * from './github.js';\nexport * from './linear.js';\nexport * from './local.js';\nexport * from './pdf.js';\nexport * from './rss.js';\nexport * from './repo.js';\n\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,9 @@
1
+ export declare function linear(apiKey: string): {
2
+ sourceId: string;
3
+ instructions: string;
4
+ sources: () => Promise<{
5
+ id: string;
6
+ content: () => Promise<string>;
7
+ }[]>;
8
+ };
9
+ //# sourceMappingURL=linear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linear.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/linear.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM;;;;;;;EAsBpC"}
@@ -0,0 +1,29 @@
1
+ import { LinearClient } from "@linear/sdk";
2
+ function linear(apiKey) {
3
+ const linearClient = new LinearClient({ apiKey });
4
+ const sourceId = "linear:workspace";
5
+ return {
6
+ sourceId,
7
+ instructions: "You answer questions about Linear issues assigned to the user.",
8
+ sources: async () => {
9
+ const user = await linearClient.viewer;
10
+ const issues = await user.assignedIssues();
11
+ return Promise.all(
12
+ issues.nodes.map(async (it) => {
13
+ const state = await it.state;
14
+ return {
15
+ id: it.id,
16
+ content: async () => `Issue: ${it.title}
17
+ Description: ${it.description || "No description"}
18
+ Status: ${state?.name || "Unknown"}
19
+ ID: ${it.id}`
20
+ };
21
+ })
22
+ );
23
+ }
24
+ };
25
+ }
26
+ export {
27
+ linear
28
+ };
29
+ //# sourceMappingURL=linear.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/connectors/linear.ts"],
4
+ "sourcesContent": ["import { LinearClient } from '@linear/sdk';\n\nexport function linear(apiKey: string) {\n const linearClient = new LinearClient({ apiKey });\n const sourceId = 'linear:workspace';\n return {\n sourceId,\n instructions:\n 'You answer questions about Linear issues assigned to the user.',\n sources: async () => {\n const user = await linearClient.viewer;\n const issues = await user.assignedIssues();\n return Promise.all(\n issues.nodes.map(async (it) => {\n const state = await it.state;\n return {\n id: it.id,\n content: async () =>\n `Issue: ${it.title}\\nDescription: ${it.description || 'No description'}\\nStatus: ${state?.name || 'Unknown'}\\nID: ${it.id}`,\n };\n }),\n );\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAEtB,SAAS,OAAO,QAAgB;AACrC,QAAM,eAAe,IAAI,aAAa,EAAE,OAAO,CAAC;AAChD,QAAM,WAAW;AACjB,SAAO;AAAA,IACL;AAAA,IACA,cACE;AAAA,IACF,SAAS,YAAY;AACnB,YAAM,OAAO,MAAM,aAAa;AAChC,YAAM,SAAS,MAAM,KAAK,eAAe;AACzC,aAAO,QAAQ;AAAA,QACb,OAAO,MAAM,IAAI,OAAO,OAAO;AAC7B,gBAAM,QAAQ,MAAM,GAAG;AACvB,iBAAO;AAAA,YACL,IAAI,GAAG;AAAA,YACP,SAAS,YACP,UAAU,GAAG,KAAK;AAAA,eAAkB,GAAG,eAAe,gBAAgB;AAAA,UAAa,OAAO,QAAQ,SAAS;AAAA,MAAS,GAAG,EAAE;AAAA,UAC7H;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ import type { Connector } from './connector.js';
2
+ export declare function local(pattern: string, options?: {
3
+ ingestWhen?: 'never' | 'contentChanged' | 'expired';
4
+ expiresAfter?: number;
5
+ cwd?: string;
6
+ }): Connector;
7
+ //# sourceMappingURL=local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/local.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAmHhD,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACA,SAAS,CAmBX"}
@@ -0,0 +1,98 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { dirname, join, relative, resolve } from "node:path";
3
+ import fg from "fast-glob";
4
+ import ignore from "ignore";
5
+ const gitignoreCache = /* @__PURE__ */ new Map();
6
+ async function collectGitignorePatterns(targetPath) {
7
+ const absolutePath = resolve(targetPath);
8
+ if (gitignoreCache.has(absolutePath)) {
9
+ return gitignoreCache.get(absolutePath);
10
+ }
11
+ const ig = ignore();
12
+ const pathSegments = absolutePath.split("/");
13
+ const gitignoreFiles = [];
14
+ for (let i = 1; i <= pathSegments.length; i++) {
15
+ const currentPath = pathSegments.slice(0, i).join("/");
16
+ const gitignorePath = join(currentPath, ".gitignore");
17
+ try {
18
+ await stat(gitignorePath);
19
+ gitignoreFiles.push(gitignorePath);
20
+ } catch {
21
+ }
22
+ }
23
+ for (const gitignoreFile of gitignoreFiles) {
24
+ try {
25
+ const content = await readFile(gitignoreFile, "utf8");
26
+ const patterns = content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
27
+ ig.add(patterns);
28
+ } catch {
29
+ }
30
+ }
31
+ gitignoreCache.set(absolutePath, ig);
32
+ return ig;
33
+ }
34
+ async function getFilteredFiles(cwd, pattern) {
35
+ const allFiles = await fg(pattern, {
36
+ dot: false,
37
+ absolute: true,
38
+ onlyFiles: true,
39
+ cwd,
40
+ followSymbolicLinks: false,
41
+ ignore: [
42
+ "**/node_modules/**",
43
+ "**/.git/**",
44
+ "**/.DS_Store",
45
+ "**/Thumbs.db",
46
+ "**/*.tmp",
47
+ "**/*.temp",
48
+ "**/coverage/**",
49
+ "**/dist/**",
50
+ "**/build/**"
51
+ ]
52
+ });
53
+ if (allFiles.length === 0) {
54
+ return [];
55
+ }
56
+ const filesByDir = /* @__PURE__ */ new Map();
57
+ for (const file of allFiles) {
58
+ const dir = dirname(file);
59
+ if (!filesByDir.has(dir)) {
60
+ filesByDir.set(dir, []);
61
+ }
62
+ filesByDir.get(dir).push(file);
63
+ }
64
+ const filteredFiles = [];
65
+ for (const [dir, files] of filesByDir) {
66
+ const ignoreFilter = await collectGitignorePatterns(dir);
67
+ for (const file of files) {
68
+ if (!ignoreFilter.ignores(relative(cwd, file))) {
69
+ filteredFiles.push(file);
70
+ }
71
+ }
72
+ }
73
+ return filteredFiles.sort();
74
+ }
75
+ function local(pattern, options) {
76
+ const sourceId = `glob:${pattern}`;
77
+ return {
78
+ sourceId,
79
+ ingestWhen: options?.ingestWhen,
80
+ expiresAfter: options?.expiresAfter,
81
+ sources: async function* () {
82
+ const paths = await getFilteredFiles(
83
+ options?.cwd ?? process.cwd(),
84
+ pattern
85
+ );
86
+ for (const filePath of paths) {
87
+ yield {
88
+ id: filePath,
89
+ content: () => readFile(filePath, "utf8").catch(() => "")
90
+ };
91
+ }
92
+ }
93
+ };
94
+ }
95
+ export {
96
+ local
97
+ };
98
+ //# sourceMappingURL=local.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/connectors/local.ts"],
4
+ "sourcesContent": ["import { readFile, stat } from 'node:fs/promises';\nimport { dirname, join, relative, resolve } from 'node:path';\n\nimport fg from 'fast-glob';\nimport ignore from 'ignore';\n\nimport type { Connector } from './connector.js';\n\n/**\n * Cache for gitignore patterns to avoid repeated file reads\n */\nconst gitignoreCache = new Map<string, ReturnType<typeof ignore>>();\n\n/**\n * Collect all .gitignore patterns from root directory up to target directory\n */\nasync function collectGitignorePatterns(\n targetPath: string,\n): Promise<ReturnType<typeof ignore>> {\n const absolutePath = resolve(targetPath);\n\n if (gitignoreCache.has(absolutePath)) {\n return gitignoreCache.get(absolutePath)!;\n }\n\n const ig = ignore();\n\n // Find all .gitignore files from root to target directory\n const pathSegments = absolutePath.split('/');\n const gitignoreFiles: string[] = [];\n\n // Check each level from root to target\n for (let i = 1; i <= pathSegments.length; i++) {\n const currentPath = pathSegments.slice(0, i).join('/');\n const gitignorePath = join(currentPath, '.gitignore');\n\n try {\n await stat(gitignorePath);\n gitignoreFiles.push(gitignorePath);\n } catch {\n // .gitignore doesn't exist at this level, continue\n }\n }\n\n // Read and add patterns from all .gitignore files\n for (const gitignoreFile of gitignoreFiles) {\n try {\n const content = await readFile(gitignoreFile, 'utf8');\n const patterns = content\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#'));\n\n ig.add(patterns);\n } catch {\n // Skip if can't read gitignore file\n }\n }\n\n gitignoreCache.set(absolutePath, ig);\n return ig;\n}\n\n/**\n * Get all files matching the pattern while respecting .gitignore files\n */\nasync function getFilteredFiles(\n cwd: string,\n pattern: string,\n): Promise<string[]> {\n // Get all files matching the pattern without gitignore filtering first\n const allFiles = await fg(pattern, {\n dot: false,\n absolute: true,\n onlyFiles: true,\n cwd: cwd,\n followSymbolicLinks: false,\n ignore: [\n '**/node_modules/**',\n '**/.git/**',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/*.tmp',\n '**/*.temp',\n '**/coverage/**',\n '**/dist/**',\n '**/build/**',\n ],\n });\n\n if (allFiles.length === 0) {\n return [];\n }\n\n // Group files by their directory to optimize gitignore pattern collection\n const filesByDir = new Map<string, string[]>();\n\n for (const file of allFiles) {\n const dir = dirname(file);\n if (!filesByDir.has(dir)) {\n filesByDir.set(dir, []);\n }\n filesByDir.get(dir)!.push(file);\n }\n\n const filteredFiles: string[] = [];\n\n // Process each directory and filter files\n for (const [dir, files] of filesByDir) {\n const ignoreFilter = await collectGitignorePatterns(dir);\n\n for (const file of files) {\n if (!ignoreFilter.ignores(relative(cwd, file))) {\n filteredFiles.push(file);\n }\n }\n }\n\n return filteredFiles.sort();\n}\n\nexport function local(\n pattern: string,\n options?: {\n ingestWhen?: 'never' | 'contentChanged' | 'expired';\n expiresAfter?: number;\n cwd?: string;\n },\n): Connector {\n const sourceId = `glob:${pattern}`;\n return {\n sourceId,\n ingestWhen: options?.ingestWhen,\n expiresAfter: options?.expiresAfter,\n sources: async function* () {\n const paths = await getFilteredFiles(\n options?.cwd ?? process.cwd(),\n pattern,\n );\n for (const filePath of paths) {\n yield {\n id: filePath,\n content: () => readFile(filePath, 'utf8').catch(() => ''),\n };\n }\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,YAAY;AAC/B,SAAS,SAAS,MAAM,UAAU,eAAe;AAEjD,OAAO,QAAQ;AACf,OAAO,YAAY;AAOnB,MAAM,iBAAiB,oBAAI,IAAuC;AAKlE,eAAe,yBACb,YACoC;AACpC,QAAM,eAAe,QAAQ,UAAU;AAEvC,MAAI,eAAe,IAAI,YAAY,GAAG;AACpC,WAAO,eAAe,IAAI,YAAY;AAAA,EACxC;AAEA,QAAM,KAAK,OAAO;AAGlB,QAAM,eAAe,aAAa,MAAM,GAAG;AAC3C,QAAM,iBAA2B,CAAC;AAGlC,WAAS,IAAI,GAAG,KAAK,aAAa,QAAQ,KAAK;AAC7C,UAAM,cAAc,aAAa,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG;AACrD,UAAM,gBAAgB,KAAK,aAAa,YAAY;AAEpD,QAAI;AACF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AA,MACzB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,cAAc,KAAK;AAC5B;AAEO,SAAS,MACd,SACA,SAKW;AACX,QAAM,WAAW,QAAQ,OAAO;AAChC,SAAO;AAAA,IACL;AAAA,IACA,YAAY,SAAS;AAAA,IACrB,cAAc,SAAS;AAAA,IACvB,SAAS,mBAAmB;AAC1B,YAAM,QAAQ,MAAM;AAAA,QAClB,SAAS,OAAO,QAAQ,IAAI;AAAA,QAC5B;AAAA,MACF;AACA,iBAAW,YAAY,OAAO;AAC5B,cAAM;AAAA,UACJ,IAAI;AAAA,UACJ,SAAS,MAAM,SAAS,UAAU,MAAM,EAAE,MAAM,MAAM,EAAE;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { Connector } from './connector.js';
2
+ export declare function pdf(pattern: string): Connector;
3
+ export declare function pdfFile(source: string): Connector;
4
+ //# sourceMappingURL=pdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/pdf.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAuB9C;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CA8BjD"}
@@ -0,0 +1,58 @@
1
+ import { glob, readFile } from "node:fs/promises";
2
+ import { extractText, getDocumentProxy } from "unpdf";
3
+ function pdf(pattern) {
4
+ const sourceId = `pdf:${pattern}`;
5
+ return {
6
+ sourceId,
7
+ sources: async function* () {
8
+ const paths = await Array.fromAsync(
9
+ glob(pattern, { exclude: ["**/node_modules/**", "**/.git/**"] })
10
+ );
11
+ for (const path of paths) {
12
+ if (!path.toLowerCase().endsWith(".pdf")) continue;
13
+ yield {
14
+ id: path,
15
+ content: async () => {
16
+ const buffer = await readFile(path);
17
+ const pdf2 = await getDocumentProxy(new Uint8Array(buffer));
18
+ const { text } = await extractText(pdf2, { mergePages: true });
19
+ return text;
20
+ }
21
+ };
22
+ }
23
+ }
24
+ };
25
+ }
26
+ function pdfFile(source) {
27
+ const isUrl = /^https?:\/\//.test(source);
28
+ const sourceId = `pdf:${isUrl ? "url" : "file"}:${source}`;
29
+ return {
30
+ sourceId,
31
+ sources: async function* () {
32
+ yield {
33
+ id: source,
34
+ content: async () => {
35
+ let buffer;
36
+ if (isUrl) {
37
+ const response = await fetch(source);
38
+ if (!response.ok) {
39
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
40
+ }
41
+ buffer = new Uint8Array(await response.arrayBuffer());
42
+ } else {
43
+ const fileBuffer = await readFile(source);
44
+ buffer = new Uint8Array(fileBuffer.buffer);
45
+ }
46
+ const pdf2 = await getDocumentProxy(new Uint8Array(buffer));
47
+ const { text } = await extractText(pdf2, { mergePages: true });
48
+ return text;
49
+ }
50
+ };
51
+ }
52
+ };
53
+ }
54
+ export {
55
+ pdf,
56
+ pdfFile
57
+ };
58
+ //# sourceMappingURL=pdf.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/connectors/pdf.ts"],
4
+ "sourcesContent": ["import { glob, readFile } from 'node:fs/promises';\n\nimport { extractText, getDocumentProxy } from 'unpdf';\n\nimport type { Connector } from './connector.js';\n\nexport function pdf(pattern: string): Connector {\n const sourceId = `pdf:${pattern}`;\n\n return {\n sourceId,\n sources: async function* () {\n const paths = await Array.fromAsync(\n glob(pattern, { exclude: ['**/node_modules/**', '**/.git/**'] }),\n );\n for (const path of paths) {\n if (!path.toLowerCase().endsWith('.pdf')) continue;\n yield {\n id: path,\n content: async () => {\n const buffer = await readFile(path);\n const pdf = await getDocumentProxy(new Uint8Array(buffer));\n const { text } = await extractText(pdf, { mergePages: true });\n return text;\n },\n };\n }\n },\n };\n}\n\nexport function pdfFile(source: string): Connector {\n const isUrl = /^https?:\\/\\//.test(source);\n const sourceId = `pdf:${isUrl ? 'url' : 'file'}:${source}`;\n\n return {\n sourceId,\n sources: async function* () {\n yield {\n id: source,\n content: async () => {\n let buffer: Uint8Array;\n\n if (isUrl) {\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n }\n buffer = new Uint8Array(await response.arrayBuffer());\n } else {\n const fileBuffer = await readFile(source);\n buffer = new Uint8Array(fileBuffer.buffer);\n }\n\n const pdf = await getDocumentProxy(new Uint8Array(buffer));\n const { text } = await extractText(pdf, { mergePages: true });\n return text;\n },\n };\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,MAAM,gBAAgB;AAE/B,SAAS,aAAa,wBAAwB;AAIvC,SAAS,IAAI,SAA4B;AAC9C,QAAM,WAAW,OAAO,OAAO;AAE/B,SAAO;AAAA,IACL;AAAA,IACA,SAAS,mBAAmB;AAC1B,YAAM,QAAQ,MAAM,MAAM;AAAA,QACxB,KAAK,SAAS,EAAE,SAAS,CAAC,sBAAsB,YAAY,EAAE,CAAC;AAAA,MACjE;AACA,iBAAW,QAAQ,OAAO;AACxB,YAAI,CAAC,KAAK,YAAY,EAAE,SAAS,MAAM,EAAG;AAC1C,cAAM;AAAA,UACJ,IAAI;AAAA,UACJ,SAAS,YAAY;AACnB,kBAAM,SAAS,MAAM,SAAS,IAAI;AAClC,kBAAMA,OAAM,MAAM,iBAAiB,IAAI,WAAW,MAAM,CAAC;AACzD,kBAAM,EAAE,KAAK,IAAI,MAAM,YAAYA,MAAK,EAAE,YAAY,KAAK,CAAC;AAC5D,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,QAAQ,QAA2B;AACjD,QAAM,QAAQ,eAAe,KAAK,MAAM;AACxC,QAAM,WAAW,OAAO,QAAQ,QAAQ,MAAM,IAAI,MAAM;AAExD,SAAO;AAAA,IACL;AAAA,IACA,SAAS,mBAAmB;AAC1B,YAAM;AAAA,QACJ,IAAI;AAAA,QACJ,SAAS,YAAY;AACnB,cAAI;AAEJ,cAAI,OAAO;AACT,kBAAM,WAAW,MAAM,MAAM,MAAM;AACnC,gBAAI,CAAC,SAAS,IAAI;AAChB,oBAAM,IAAI,MAAM,QAAQ,SAAS,MAAM,KAAK,SAAS,UAAU,EAAE;AAAA,YACnE;AACA,qBAAS,IAAI,WAAW,MAAM,SAAS,YAAY,CAAC;AAAA,UACtD,OAAO;AACL,kBAAM,aAAa,MAAM,SAAS,MAAM;AACxC,qBAAS,IAAI,WAAW,WAAW,MAAM;AAAA,UAC3C;AAEA,gBAAMA,OAAM,MAAM,iBAAiB,IAAI,WAAW,MAAM,CAAC;AACzD,gBAAM,EAAE,KAAK,IAAI,MAAM,YAAYA,MAAK,EAAE,YAAY,KAAK,CAAC;AAC5D,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": ["pdf"]
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { Connector } from './connector.js';
2
+ export declare function repo(dir: string, extensions: string[], ingestWhen: Connector['ingestWhen']): Connector;
3
+ export declare function findAllGitRepos(root: string): AsyncGenerator<string, void, unknown>;
4
+ export declare function ignorePatterns(repo: string): Promise<string[]>;
5
+ export declare function collectFiles(repo: string, extensions: string[]): Promise<AsyncIterable<string>>;
6
+ //# sourceMappingURL=repo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/repo.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,IAAI,CAClB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAAE,EACpB,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,GAClC,SAAS,CAqBX;AAED,wBAAuB,eAAe,CAAC,IAAI,EAAE,MAAM,yCAoClD;AAmBD,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,qBA4FhD;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAahC"}