@backendkit-labs/agent-enterprise 0.2.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.
- package/README.md +185 -0
- package/dist/__tests__/integration/ObsidianRAGProvider.test.d.ts +2 -0
- package/dist/__tests__/integration/ObsidianRAGProvider.test.d.ts.map +1 -0
- package/dist/__tests__/integration/ObsidianRAGProvider.test.js +237 -0
- package/dist/__tests__/integration/ObsidianRAGProvider.test.js.map +1 -0
- package/dist/__tests__/integration/OllamaEmbedder.test.d.ts +2 -0
- package/dist/__tests__/integration/OllamaEmbedder.test.d.ts.map +1 -0
- package/dist/__tests__/integration/OllamaEmbedder.test.js +101 -0
- package/dist/__tests__/integration/OllamaEmbedder.test.js.map +1 -0
- package/dist/__tests__/unit/VaultIndexer.test.d.ts +2 -0
- package/dist/__tests__/unit/VaultIndexer.test.d.ts.map +1 -0
- package/dist/__tests__/unit/VaultIndexer.test.js +174 -0
- package/dist/__tests__/unit/VaultIndexer.test.js.map +1 -0
- package/dist/__tests__/unit/VectorStore.test.d.ts +2 -0
- package/dist/__tests__/unit/VectorStore.test.d.ts.map +1 -0
- package/dist/__tests__/unit/VectorStore.test.js +146 -0
- package/dist/__tests__/unit/VectorStore.test.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/rag/ObsidianRAGProvider.d.ts +52 -0
- package/dist/rag/ObsidianRAGProvider.d.ts.map +1 -0
- package/dist/rag/ObsidianRAGProvider.js +148 -0
- package/dist/rag/ObsidianRAGProvider.js.map +1 -0
- package/dist/rag/OllamaEmbedder.d.ts +15 -0
- package/dist/rag/OllamaEmbedder.d.ts.map +1 -0
- package/dist/rag/OllamaEmbedder.js +50 -0
- package/dist/rag/OllamaEmbedder.js.map +1 -0
- package/dist/rag/VaultIndexer.d.ts +34 -0
- package/dist/rag/VaultIndexer.d.ts.map +1 -0
- package/dist/rag/VaultIndexer.js +230 -0
- package/dist/rag/VaultIndexer.js.map +1 -0
- package/dist/rag/VaultWriter.d.ts +33 -0
- package/dist/rag/VaultWriter.d.ts.map +1 -0
- package/dist/rag/VaultWriter.js +112 -0
- package/dist/rag/VaultWriter.js.map +1 -0
- package/dist/rag/VectorStore.d.ts +36 -0
- package/dist/rag/VectorStore.d.ts.map +1 -0
- package/dist/rag/VectorStore.js +119 -0
- package/dist/rag/VectorStore.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OllamaEmbedder = exports.OLLAMA_EMBED_DEFAULT_HOST = exports.OLLAMA_EMBED_DEFAULT_MODEL = void 0;
|
|
4
|
+
exports.OLLAMA_EMBED_DEFAULT_MODEL = 'nomic-embed-text';
|
|
5
|
+
exports.OLLAMA_EMBED_DEFAULT_HOST = 'http://localhost:11434';
|
|
6
|
+
class OllamaEmbedder {
|
|
7
|
+
host;
|
|
8
|
+
model;
|
|
9
|
+
constructor(opts = {}) {
|
|
10
|
+
this.host = (opts.host ?? exports.OLLAMA_EMBED_DEFAULT_HOST).replace(/\/$/, '');
|
|
11
|
+
this.model = opts.model ?? exports.OLLAMA_EMBED_DEFAULT_MODEL;
|
|
12
|
+
}
|
|
13
|
+
async embed(texts) {
|
|
14
|
+
if (texts.length === 0)
|
|
15
|
+
return [];
|
|
16
|
+
const res = await fetch(`${this.host}/api/embed`, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: { 'Content-Type': 'application/json' },
|
|
19
|
+
body: JSON.stringify({ model: this.model, input: texts }),
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok) {
|
|
22
|
+
const body = await res.text().catch(() => '');
|
|
23
|
+
if (res.status === 404) {
|
|
24
|
+
throw new Error(`Modelo de embeddings '${this.model}' no encontrado en Ollama. ` +
|
|
25
|
+
`Descárgalo con: ollama pull ${this.model}`);
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`Ollama /api/embed error ${res.status}: ${body}`);
|
|
28
|
+
}
|
|
29
|
+
const data = await res.json();
|
|
30
|
+
return data.embeddings;
|
|
31
|
+
}
|
|
32
|
+
async embedOne(text) {
|
|
33
|
+
const results = await this.embed([text]);
|
|
34
|
+
return results[0] ?? [];
|
|
35
|
+
}
|
|
36
|
+
async checkConnection() {
|
|
37
|
+
try {
|
|
38
|
+
const res = await fetch(`${this.host}/api/tags`);
|
|
39
|
+
if (!res.ok)
|
|
40
|
+
throw new Error(`Status ${res.status}`);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
44
|
+
throw new Error(`No se puede conectar a Ollama en ${this.host}: ${msg}\n` +
|
|
45
|
+
`Asegúrate de que Ollama esté corriendo con: ollama serve`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.OllamaEmbedder = OllamaEmbedder;
|
|
50
|
+
//# sourceMappingURL=OllamaEmbedder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OllamaEmbedder.js","sourceRoot":"","sources":["../../src/rag/OllamaEmbedder.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG,kBAAkB,CAAC;AAChD,QAAA,yBAAyB,GAAG,wBAAwB,CAAC;AAWlE,MAAa,cAAc;IACN,IAAI,CAAS;IACrB,KAAK,CAAS;IAEvB,YAAY,OAA8B,EAAE;QACxC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,iCAAyB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,kCAA0B,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAe;QACvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YA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AC,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,IAAI,KAAK,CACX,oCAAoC,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI;gBACzD,0DAA0D,CAC7D,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAlDD,wCAkDC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { VectorChunk } from './VectorStore';
|
|
2
|
+
export interface RawChunk {
|
|
3
|
+
filePath: string;
|
|
4
|
+
mtime: number;
|
|
5
|
+
title: string;
|
|
6
|
+
section: string;
|
|
7
|
+
text: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IndexerOptions {
|
|
12
|
+
vaultPath: string;
|
|
13
|
+
/** Subcarpetas a incluir. Si está vacío, escanea todo el vault. */
|
|
14
|
+
folders?: string[];
|
|
15
|
+
/** Tags del frontmatter a excluir (ej. 'skill' para no duplicar con ObsidianProvider). */
|
|
16
|
+
excludeTags?: string[];
|
|
17
|
+
/** Archivos a excluir por nombre (ej. 'MEMORY.md'). */
|
|
18
|
+
excludeFiles?: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare class VaultIndexer {
|
|
21
|
+
private readonly opts;
|
|
22
|
+
constructor(opts: IndexerOptions);
|
|
23
|
+
getChangedFiles(knownMtimes: Map<string, number>): Promise<{
|
|
24
|
+
toIndex: Array<{
|
|
25
|
+
filePath: string;
|
|
26
|
+
mtime: number;
|
|
27
|
+
}>;
|
|
28
|
+
toRemove: string[];
|
|
29
|
+
}>;
|
|
30
|
+
buildChunks(filePath: string, mtime: number): Promise<RawChunk[]>;
|
|
31
|
+
private scanVault;
|
|
32
|
+
toVectorChunk(raw: RawChunk, embedding: number[]): VectorChunk;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=VaultIndexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VaultIndexer.d.ts","sourceRoot":"","sources":["../../src/rag/VaultIndexer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAYjD,MAAM,WAAW,QAAQ;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACvB;AAmGD,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;gBAEpC,IAAI,EAAE,cAAc;IAS1B,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;QAC7D,OAAO,EAAE,KAAK,CAAC;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACpD,QAAQ,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;IAcI,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;YAiCzD,SAAS;IAqBvB,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,WAAW;CAiBjE"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.VaultIndexer = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const yaml = __importStar(require("yaml"));
|
|
40
|
+
const crypto_1 = require("crypto");
|
|
41
|
+
const MAX_WORDS_PER_CHUNK = 500;
|
|
42
|
+
function parseFrontmatter(content) {
|
|
43
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
44
|
+
if (!match)
|
|
45
|
+
return { meta: {}, body: content };
|
|
46
|
+
try {
|
|
47
|
+
const meta = yaml.parse(match[1]) ?? {};
|
|
48
|
+
return { meta, body: match[2] ?? '' };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return { meta: {}, body: content };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function normalizeTags(raw) {
|
|
55
|
+
if (!Array.isArray(raw))
|
|
56
|
+
return raw ? [raw] : [];
|
|
57
|
+
return raw.map(String);
|
|
58
|
+
}
|
|
59
|
+
function extractArea(tags) {
|
|
60
|
+
return tags.find(t => t.startsWith('área/'))?.replace('área/', '');
|
|
61
|
+
}
|
|
62
|
+
function extractStack(tags) {
|
|
63
|
+
return tags.find(t => t.startsWith('stack/'))?.replace('stack/', '');
|
|
64
|
+
}
|
|
65
|
+
function wordCount(text) {
|
|
66
|
+
return text.split(/\s+/).filter(Boolean).length;
|
|
67
|
+
}
|
|
68
|
+
function splitByParagraph(text, maxWords) {
|
|
69
|
+
const paragraphs = text.split(/\n{2,}/);
|
|
70
|
+
const chunks = [];
|
|
71
|
+
let current = '';
|
|
72
|
+
for (const para of paragraphs) {
|
|
73
|
+
const candidate = current ? `${current}\n\n${para}` : para;
|
|
74
|
+
if (wordCount(candidate) > maxWords && current) {
|
|
75
|
+
chunks.push(current.trim());
|
|
76
|
+
current = para;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
current = candidate;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (current.trim())
|
|
83
|
+
chunks.push(current.trim());
|
|
84
|
+
return chunks.filter(c => c.length > 0);
|
|
85
|
+
}
|
|
86
|
+
function chunkBody(body) {
|
|
87
|
+
const lines = body.split('\n');
|
|
88
|
+
const sections = [];
|
|
89
|
+
let current = { heading: '', lines: [] };
|
|
90
|
+
for (const line of lines) {
|
|
91
|
+
const h2Match = line.match(/^##\s+(.+)/);
|
|
92
|
+
if (h2Match) {
|
|
93
|
+
if (current.lines.join('\n').trim())
|
|
94
|
+
sections.push(current);
|
|
95
|
+
current = { heading: h2Match[1].trim(), lines: [] };
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
current.lines.push(line);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (current.lines.join('\n').trim())
|
|
102
|
+
sections.push(current);
|
|
103
|
+
const result = [];
|
|
104
|
+
for (const sec of sections) {
|
|
105
|
+
const text = sec.lines.join('\n').trim();
|
|
106
|
+
if (!text)
|
|
107
|
+
continue;
|
|
108
|
+
if (wordCount(text) <= MAX_WORDS_PER_CHUNK) {
|
|
109
|
+
result.push({ section: sec.heading, text });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const subChunks = splitByParagraph(text, MAX_WORDS_PER_CHUNK);
|
|
113
|
+
subChunks.forEach((sub, i) => result.push({ section: sec.heading ? `${sec.heading} (${i + 1})` : `parte ${i + 1}`, text: sub }));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
async function collectMdFiles(dir) {
|
|
119
|
+
let result = [];
|
|
120
|
+
let entries;
|
|
121
|
+
try {
|
|
122
|
+
entries = await fs.readdir(dir, { withFileTypes: true, encoding: 'utf8' });
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
for (const entry of entries) {
|
|
128
|
+
if (entry.name.startsWith('.'))
|
|
129
|
+
continue;
|
|
130
|
+
const fullPath = path.join(dir, entry.name);
|
|
131
|
+
if (entry.isDirectory()) {
|
|
132
|
+
result = result.concat(await collectMdFiles(fullPath));
|
|
133
|
+
}
|
|
134
|
+
else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
135
|
+
result.push(fullPath);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
class VaultIndexer {
|
|
141
|
+
opts;
|
|
142
|
+
constructor(opts) {
|
|
143
|
+
this.opts = {
|
|
144
|
+
vaultPath: opts.vaultPath,
|
|
145
|
+
folders: opts.folders ?? [],
|
|
146
|
+
excludeTags: opts.excludeTags ?? ['skill'],
|
|
147
|
+
excludeFiles: opts.excludeFiles ?? [],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async getChangedFiles(knownMtimes) {
|
|
151
|
+
const allFiles = await this.scanVault();
|
|
152
|
+
const currentPaths = new Set(allFiles.map(f => f.filePath));
|
|
153
|
+
const toIndex = allFiles.filter(f => {
|
|
154
|
+
const known = knownMtimes.get(f.filePath);
|
|
155
|
+
return known === undefined || known < f.mtime;
|
|
156
|
+
});
|
|
157
|
+
const toRemove = [...knownMtimes.keys()].filter(p => !currentPaths.has(p));
|
|
158
|
+
return { toIndex, toRemove };
|
|
159
|
+
}
|
|
160
|
+
async buildChunks(filePath, mtime) {
|
|
161
|
+
let content;
|
|
162
|
+
try {
|
|
163
|
+
content = await fs.readFile(filePath, 'utf-8');
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
const { meta, body } = parseFrontmatter(content);
|
|
169
|
+
const tags = normalizeTags(meta.tags);
|
|
170
|
+
if (this.opts.excludeTags.some(t => tags.includes(t)))
|
|
171
|
+
return [];
|
|
172
|
+
const title = meta.title ?? path.basename(filePath, '.md');
|
|
173
|
+
const description = meta.description ?? '';
|
|
174
|
+
const topicHints = Array.isArray(meta.semantic_topics)
|
|
175
|
+
? `\n\nTopics: ${meta.semantic_topics.join(', ')}`
|
|
176
|
+
: '';
|
|
177
|
+
const sections = chunkBody(body + topicHints);
|
|
178
|
+
if (sections.length === 0)
|
|
179
|
+
return [];
|
|
180
|
+
return sections.map(sec => ({
|
|
181
|
+
filePath,
|
|
182
|
+
mtime,
|
|
183
|
+
title,
|
|
184
|
+
section: sec.section,
|
|
185
|
+
text: `${title}${sec.section ? ` — ${sec.section}` : ''}\n\n${sec.text}`,
|
|
186
|
+
tags,
|
|
187
|
+
description,
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
async scanVault() {
|
|
191
|
+
const scanDirs = this.opts.folders.length > 0
|
|
192
|
+
? this.opts.folders.map(f => path.join(this.opts.vaultPath, f))
|
|
193
|
+
: [this.opts.vaultPath];
|
|
194
|
+
const allFiles = [];
|
|
195
|
+
for (const dir of scanDirs) {
|
|
196
|
+
const mdFiles = await collectMdFiles(dir);
|
|
197
|
+
for (const filePath of mdFiles) {
|
|
198
|
+
if (this.opts.excludeFiles.some(ex => path.basename(filePath) === ex))
|
|
199
|
+
continue;
|
|
200
|
+
try {
|
|
201
|
+
const stat = await fs.stat(filePath);
|
|
202
|
+
allFiles.push({ filePath, mtime: stat.mtimeMs });
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// archivo desapareció entre escaneo y stat
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return allFiles;
|
|
210
|
+
}
|
|
211
|
+
toVectorChunk(raw, embedding) {
|
|
212
|
+
return {
|
|
213
|
+
id: (0, crypto_1.randomUUID)(),
|
|
214
|
+
filePath: raw.filePath,
|
|
215
|
+
title: raw.title,
|
|
216
|
+
section: raw.section,
|
|
217
|
+
text: raw.text,
|
|
218
|
+
embedding,
|
|
219
|
+
metadata: {
|
|
220
|
+
tags: raw.tags,
|
|
221
|
+
description: raw.description,
|
|
222
|
+
mtime: raw.mtime,
|
|
223
|
+
area: extractArea(raw.tags),
|
|
224
|
+
stack: extractStack(raw.tags),
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.VaultIndexer = VaultIndexer;
|
|
230
|
+
//# sourceMappingURL=VaultIndexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VaultIndexer.js","sourceRoot":"","sources":["../../src/rag/VaultIndexer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAElC,2CAA6B;AAC7B,2CAA6B;AAC7B,mCAAoC;AAGpC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAoBhC,SAAS,gBAAgB,CAAC,OAAe;IACrC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC3E,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC/C,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAgB,IAAI,EAAE,CAAC;QACvD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACvC,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,GAAkC;IACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,WAAW,CAAC,IAAc;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CA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I,EAAE,GAAG,CAAC,IAAI;YACd,SAAS;YACT,QAAQ,EAAE;gBACN,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;gBAC3B,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;aAChC;SACJ,CAAC;IACN,CAAC;CACJ;AApGD,oCAoGC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@backendkit-labs/agent-core';
|
|
2
|
+
export interface VaultWriterOptions {
|
|
3
|
+
/** Absolute path to the shared vault directory. */
|
|
4
|
+
vaultPath: string;
|
|
5
|
+
/** Sub-folder for agent-written notes. Default: 'agentes' */
|
|
6
|
+
agentFolder?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WriteNoteParams {
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
tags?: string[];
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Writes structured Markdown notes to a shared Obsidian vault.
|
|
17
|
+
*
|
|
18
|
+
* Notes use standard YAML frontmatter so the VaultIndexer picks them up
|
|
19
|
+
* on the next incremental index() call, making them immediately searchable
|
|
20
|
+
* by any agent or human that queries the vault.
|
|
21
|
+
*/
|
|
22
|
+
export declare class VaultWriter {
|
|
23
|
+
private readonly vaultPath;
|
|
24
|
+
private readonly agentFolder;
|
|
25
|
+
constructor(opts: VaultWriterOptions);
|
|
26
|
+
writeNote(params: WriteNoteParams): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a ToolDefinition ready to register with ToolRegistry.
|
|
29
|
+
* The agentId is baked in so audit trails show which agent wrote each note.
|
|
30
|
+
*/
|
|
31
|
+
createTool(agentId: string): ToolDefinition;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=VaultWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VaultWriter.d.ts","sourceRoot":"","sources":["../../src/rag/VaultWriter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,WAAW,kBAAkB;IAC/B,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,IAAI,EAAE,kBAAkB;IAK9B,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAoCzD;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc;CA4B9C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.VaultWriter = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const agent_core_1 = require("@backendkit-labs/agent-core");
|
|
40
|
+
/**
|
|
41
|
+
* Writes structured Markdown notes to a shared Obsidian vault.
|
|
42
|
+
*
|
|
43
|
+
* Notes use standard YAML frontmatter so the VaultIndexer picks them up
|
|
44
|
+
* on the next incremental index() call, making them immediately searchable
|
|
45
|
+
* by any agent or human that queries the vault.
|
|
46
|
+
*/
|
|
47
|
+
class VaultWriter {
|
|
48
|
+
vaultPath;
|
|
49
|
+
agentFolder;
|
|
50
|
+
constructor(opts) {
|
|
51
|
+
this.vaultPath = opts.vaultPath;
|
|
52
|
+
this.agentFolder = opts.agentFolder ?? 'agentes';
|
|
53
|
+
}
|
|
54
|
+
async writeNote(params) {
|
|
55
|
+
const { title, content, agentId, tags = [], description = '' } = params;
|
|
56
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
57
|
+
const slug = title
|
|
58
|
+
.toLowerCase()
|
|
59
|
+
.normalize('NFD')
|
|
60
|
+
.replace(/[̀-ͯ]/g, '')
|
|
61
|
+
.replace(/[^a-z0-9\s-]/g, '')
|
|
62
|
+
.trim()
|
|
63
|
+
.replace(/\s+/g, '-')
|
|
64
|
+
.slice(0, 60);
|
|
65
|
+
const filename = `${date}-${slug}.md`;
|
|
66
|
+
const dir = path.join(this.vaultPath, this.agentFolder);
|
|
67
|
+
await fs.mkdir(dir, { recursive: true });
|
|
68
|
+
const tagsLine = tags.length
|
|
69
|
+
? `[${tags.map(t => `"${t}"`).join(', ')}]`
|
|
70
|
+
: '[]';
|
|
71
|
+
const lines = [
|
|
72
|
+
'---',
|
|
73
|
+
`title: "${title}"`,
|
|
74
|
+
`author: "agent/${agentId}"`,
|
|
75
|
+
`date: ${date}`,
|
|
76
|
+
`tags: ${tagsLine}`,
|
|
77
|
+
];
|
|
78
|
+
if (description)
|
|
79
|
+
lines.push(`description: "${description}"`);
|
|
80
|
+
lines.push('---', '', content);
|
|
81
|
+
const filePath = path.join(dir, filename);
|
|
82
|
+
await fs.writeFile(filePath, lines.join('\n'), 'utf-8');
|
|
83
|
+
return filePath;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns a ToolDefinition ready to register with ToolRegistry.
|
|
87
|
+
* The agentId is baked in so audit trails show which agent wrote each note.
|
|
88
|
+
*/
|
|
89
|
+
createTool(agentId) {
|
|
90
|
+
const self = this;
|
|
91
|
+
return (0, agent_core_1.defineTool)({
|
|
92
|
+
name: 'write_knowledge',
|
|
93
|
+
description: "Write a new note to the organization's shared knowledge vault. " +
|
|
94
|
+
'Use this to record findings, decisions, resolved problems, or any knowledge ' +
|
|
95
|
+
'worth sharing with other agents and team members. ' +
|
|
96
|
+
'Notes are indexed automatically and become searchable via search_knowledge.',
|
|
97
|
+
input: agent_core_1.z.object({
|
|
98
|
+
title: agent_core_1.z.string().describe('Short descriptive title for the note'),
|
|
99
|
+
content: agent_core_1.z.string().describe('Note body in Markdown. Use ## headings for sections. ' +
|
|
100
|
+
'Be specific — this will be retrieved by semantic search.'),
|
|
101
|
+
tags: agent_core_1.z.array(agent_core_1.z.string()).default([]).describe('Domain tags, e.g. ["función/arquitectura", "stack/typescript", "área/rag"]'),
|
|
102
|
+
description: agent_core_1.z.string().optional().describe('One-line summary shown in search results'),
|
|
103
|
+
}),
|
|
104
|
+
execute: async ({ title, content, tags, description }) => {
|
|
105
|
+
const filePath = await self.writeNote({ title, content, agentId, tags, description });
|
|
106
|
+
return `Knowledge saved to vault: ${path.basename(filePath)}`;
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.VaultWriter = VaultWriter;
|
|
112
|
+
//# sourceMappingURL=VaultWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VaultWriter.js","sourceRoot":"","sources":["../../src/rag/VaultWriter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,4DAA4D;AAkB5D;;;;;;GAMG;AACH,MAAa,WAAW;IACH,SAAS,CAAS;IAClB,WAAW,CAAS;IAErC,YAAY,IAAwB;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,SAAS,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAuB;QACnC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;QAExE,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|
3
|
+
filePath: string;
|
|
4
|
+
title: string;
|
|
5
|
+
section: string;
|
|
6
|
+
text: string;
|
|
7
|
+
embedding: number[];
|
|
8
|
+
metadata: {
|
|
9
|
+
tags: string[];
|
|
10
|
+
description: string;
|
|
11
|
+
mtime: number;
|
|
12
|
+
area?: string;
|
|
13
|
+
stack?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface SearchResult {
|
|
17
|
+
chunk: VectorChunk;
|
|
18
|
+
score: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class VectorStore {
|
|
21
|
+
private chunks;
|
|
22
|
+
private readonly storePath;
|
|
23
|
+
private readonly embeddingModel;
|
|
24
|
+
private dirty;
|
|
25
|
+
constructor(storePath: string, embeddingModel: string);
|
|
26
|
+
load(): Promise<void>;
|
|
27
|
+
save(): Promise<void>;
|
|
28
|
+
/** Devuelve los mtime conocidos por filePath para detectar cambios. */
|
|
29
|
+
getKnownMtimes(): Map<string, number>;
|
|
30
|
+
/** Elimina todos los chunks de un archivo (para re-indexar). */
|
|
31
|
+
removeFile(filePath: string): void;
|
|
32
|
+
addChunks(newChunks: VectorChunk[]): void;
|
|
33
|
+
search(queryEmbedding: number[], topK: number): SearchResult[];
|
|
34
|
+
get size(): number;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=VectorStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorStore.d.ts","sourceRoot":"","sources":["../../src/rag/VectorStore.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACL;AAmBD,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,KAAK,CAAS;gBAEV,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAK/C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAerB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAY3B,uEAAuE;IACvE,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAUrC,gEAAgE;IAChE,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMlC,SAAS,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI;IAMzC,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE;IAO9D,IAAI,IAAI,IAAI,MAAM,CAEjB;CACJ"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.VectorStore = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
function cosineSimilarity(a, b) {
|
|
40
|
+
let dot = 0, normA = 0, normB = 0;
|
|
41
|
+
for (let i = 0; i < a.length; i++) {
|
|
42
|
+
dot += a[i] * b[i];
|
|
43
|
+
normA += a[i] * a[i];
|
|
44
|
+
normB += b[i] * b[i];
|
|
45
|
+
}
|
|
46
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
47
|
+
return denom === 0 ? 0 : dot / denom;
|
|
48
|
+
}
|
|
49
|
+
class VectorStore {
|
|
50
|
+
chunks = [];
|
|
51
|
+
storePath;
|
|
52
|
+
embeddingModel;
|
|
53
|
+
dirty = false;
|
|
54
|
+
constructor(storePath, embeddingModel) {
|
|
55
|
+
this.storePath = storePath;
|
|
56
|
+
this.embeddingModel = embeddingModel;
|
|
57
|
+
}
|
|
58
|
+
async load() {
|
|
59
|
+
try {
|
|
60
|
+
const raw = await fs.readFile(this.storePath, 'utf-8');
|
|
61
|
+
const data = JSON.parse(raw);
|
|
62
|
+
// Si el modelo de embeddings cambió, el índice no es compatible
|
|
63
|
+
if (data.embeddingModel !== this.embeddingModel) {
|
|
64
|
+
this.chunks = [];
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.chunks = data.chunks;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
this.chunks = [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async save() {
|
|
74
|
+
if (!this.dirty)
|
|
75
|
+
return;
|
|
76
|
+
await fs.mkdir(path.dirname(this.storePath), { recursive: true });
|
|
77
|
+
const data = {
|
|
78
|
+
version: '1',
|
|
79
|
+
embeddingModel: this.embeddingModel,
|
|
80
|
+
chunks: this.chunks,
|
|
81
|
+
};
|
|
82
|
+
await fs.writeFile(this.storePath, JSON.stringify(data), 'utf-8');
|
|
83
|
+
this.dirty = false;
|
|
84
|
+
}
|
|
85
|
+
/** Devuelve los mtime conocidos por filePath para detectar cambios. */
|
|
86
|
+
getKnownMtimes() {
|
|
87
|
+
const map = new Map();
|
|
88
|
+
for (const chunk of this.chunks) {
|
|
89
|
+
if (!map.has(chunk.filePath)) {
|
|
90
|
+
map.set(chunk.filePath, chunk.metadata.mtime);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return map;
|
|
94
|
+
}
|
|
95
|
+
/** Elimina todos los chunks de un archivo (para re-indexar). */
|
|
96
|
+
removeFile(filePath) {
|
|
97
|
+
const before = this.chunks.length;
|
|
98
|
+
this.chunks = this.chunks.filter(c => c.filePath !== filePath);
|
|
99
|
+
if (this.chunks.length !== before)
|
|
100
|
+
this.dirty = true;
|
|
101
|
+
}
|
|
102
|
+
addChunks(newChunks) {
|
|
103
|
+
if (newChunks.length === 0)
|
|
104
|
+
return;
|
|
105
|
+
this.chunks.push(...newChunks);
|
|
106
|
+
this.dirty = true;
|
|
107
|
+
}
|
|
108
|
+
search(queryEmbedding, topK) {
|
|
109
|
+
return this.chunks
|
|
110
|
+
.map(chunk => ({ chunk, score: cosineSimilarity(queryEmbedding, chunk.embedding) }))
|
|
111
|
+
.sort((a, b) => b.score - a.score)
|
|
112
|
+
.slice(0, topK);
|
|
113
|
+
}
|
|
114
|
+
get size() {
|
|
115
|
+
return this.chunks.length;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.VectorStore = VectorStore;
|
|
119
|
+
//# sourceMappingURL=VectorStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorStore.js","sourceRoot":"","sources":["../../src/rag/VectorStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAwB7B,SAAS,gBAAgB,CAAC,CAAW,EAAE,CAAW;IAC9C,IAAI,GAAG,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG,IAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,C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