@framers/agentos 0.1.122 → 0.1.123
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/dist/api/TextToolCallParser.d.ts +61 -0
- package/dist/api/TextToolCallParser.d.ts.map +1 -0
- package/dist/api/TextToolCallParser.js +137 -0
- package/dist/api/TextToolCallParser.js.map +1 -0
- package/dist/api/agent.d.ts +7 -0
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +1 -0
- package/dist/api/agent.js.map +1 -1
- package/dist/api/generateText.d.ts +105 -0
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js +191 -2
- package/dist/api/generateText.js.map +1 -1
- package/dist/cognitive_substrate/GMI.d.ts.map +1 -1
- package/dist/cognitive_substrate/GMI.js +27 -1
- package/dist/cognitive_substrate/GMI.js.map +1 -1
- package/dist/cognitive_substrate/IGMI.d.ts +5 -0
- package/dist/cognitive_substrate/IGMI.d.ts.map +1 -1
- package/dist/cognitive_substrate/IGMI.js.map +1 -1
- package/dist/emergent/AdaptPersonalityTool.d.ts +5 -21
- package/dist/emergent/AdaptPersonalityTool.d.ts.map +1 -1
- package/dist/emergent/AdaptPersonalityTool.js +18 -10
- package/dist/emergent/AdaptPersonalityTool.js.map +1 -1
- package/dist/emergent/CreateWorkflowTool.d.ts +1 -0
- package/dist/emergent/CreateWorkflowTool.d.ts.map +1 -1
- package/dist/emergent/CreateWorkflowTool.js +28 -5
- package/dist/emergent/CreateWorkflowTool.js.map +1 -1
- package/dist/emergent/EmergentCapabilityEngine.d.ts +68 -0
- package/dist/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/emergent/EmergentCapabilityEngine.js +99 -0
- package/dist/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/emergent/SelfEvaluateTool.d.ts +15 -5
- package/dist/emergent/SelfEvaluateTool.d.ts.map +1 -1
- package/dist/emergent/SelfEvaluateTool.js +111 -54
- package/dist/emergent/SelfEvaluateTool.js.map +1 -1
- package/dist/emergent/SelfImprovementConfig.d.ts +12 -1
- package/dist/emergent/SelfImprovementConfig.d.ts.map +1 -1
- package/dist/emergent/SelfImprovementConfig.js.map +1 -1
- package/dist/emergent/index.d.ts +7 -0
- package/dist/emergent/index.d.ts.map +1 -1
- package/dist/emergent/index.js +5 -0
- package/dist/emergent/index.js.map +1 -1
- package/dist/memory/AgentMemory.d.ts +2 -2
- package/dist/memory/AgentMemory.d.ts.map +1 -1
- package/dist/memory/AgentMemory.js +4 -3
- package/dist/memory/AgentMemory.js.map +1 -1
- package/dist/memory/consolidation/ConsolidationLoop.d.ts +31 -4
- package/dist/memory/consolidation/ConsolidationLoop.d.ts.map +1 -1
- package/dist/memory/consolidation/ConsolidationLoop.js +112 -69
- package/dist/memory/consolidation/ConsolidationLoop.js.map +1 -1
- package/dist/memory/facade/Memory.d.ts +12 -6
- package/dist/memory/facade/Memory.d.ts.map +1 -1
- package/dist/memory/facade/Memory.js +216 -212
- package/dist/memory/facade/Memory.js.map +1 -1
- package/dist/memory/facade/types.d.ts +11 -1
- package/dist/memory/facade/types.d.ts.map +1 -1
- package/dist/memory/feedback/RetrievalFeedbackSignal.d.ts +7 -10
- package/dist/memory/feedback/RetrievalFeedbackSignal.d.ts.map +1 -1
- package/dist/memory/feedback/RetrievalFeedbackSignal.js +40 -36
- package/dist/memory/feedback/RetrievalFeedbackSignal.js.map +1 -1
- package/dist/memory/io/ChatGptImporter.d.ts.map +1 -1
- package/dist/memory/io/ChatGptImporter.js +24 -18
- package/dist/memory/io/ChatGptImporter.js.map +1 -1
- package/dist/memory/io/CsvImporter.d.ts.map +1 -1
- package/dist/memory/io/CsvImporter.js +21 -8
- package/dist/memory/io/CsvImporter.js.map +1 -1
- package/dist/memory/io/JsonExporter.d.ts.map +1 -1
- package/dist/memory/io/JsonExporter.js +6 -17
- package/dist/memory/io/JsonExporter.js.map +1 -1
- package/dist/memory/io/JsonImporter.d.ts +3 -0
- package/dist/memory/io/JsonImporter.d.ts.map +1 -1
- package/dist/memory/io/JsonImporter.js +58 -29
- package/dist/memory/io/JsonImporter.js.map +1 -1
- package/dist/memory/io/MarkdownExporter.d.ts.map +1 -1
- package/dist/memory/io/MarkdownExporter.js +1 -4
- package/dist/memory/io/MarkdownExporter.js.map +1 -1
- package/dist/memory/io/MarkdownImporter.d.ts.map +1 -1
- package/dist/memory/io/MarkdownImporter.js +12 -7
- package/dist/memory/io/MarkdownImporter.js.map +1 -1
- package/dist/memory/io/ObsidianExporter.d.ts +14 -9
- package/dist/memory/io/ObsidianExporter.d.ts.map +1 -1
- package/dist/memory/io/ObsidianExporter.js +35 -23
- package/dist/memory/io/ObsidianExporter.js.map +1 -1
- package/dist/memory/io/ObsidianImporter.d.ts.map +1 -1
- package/dist/memory/io/ObsidianImporter.js +34 -27
- package/dist/memory/io/ObsidianImporter.js.map +1 -1
- package/dist/memory/io/SqliteExporter.d.ts +1 -2
- package/dist/memory/io/SqliteExporter.d.ts.map +1 -1
- package/dist/memory/io/SqliteExporter.js +2 -3
- package/dist/memory/io/SqliteExporter.js.map +1 -1
- package/dist/memory/io/SqliteImporter.d.ts +3 -0
- package/dist/memory/io/SqliteImporter.d.ts.map +1 -1
- package/dist/memory/io/SqliteImporter.js +62 -27
- package/dist/memory/io/SqliteImporter.js.map +1 -1
- package/dist/memory/store/SqliteBrain.d.ts +84 -24
- package/dist/memory/store/SqliteBrain.d.ts.map +1 -1
- package/dist/memory/store/SqliteBrain.js +139 -55
- package/dist/memory/store/SqliteBrain.js.map +1 -1
- package/dist/memory/store/SqliteKnowledgeGraph.d.ts +6 -2
- package/dist/memory/store/SqliteKnowledgeGraph.d.ts.map +1 -1
- package/dist/memory/store/SqliteKnowledgeGraph.js +94 -120
- package/dist/memory/store/SqliteKnowledgeGraph.js.map +1 -1
- package/dist/memory/store/SqliteMemoryGraph.d.ts +4 -5
- package/dist/memory/store/SqliteMemoryGraph.d.ts.map +1 -1
- package/dist/memory/store/SqliteMemoryGraph.js +31 -41
- package/dist/memory/store/SqliteMemoryGraph.js.map +1 -1
- package/dist/memory/tools/MemoryAddTool.d.ts.map +1 -1
- package/dist/memory/tools/MemoryAddTool.js +12 -16
- package/dist/memory/tools/MemoryAddTool.js.map +1 -1
- package/dist/memory/tools/MemoryDeleteTool.d.ts.map +1 -1
- package/dist/memory/tools/MemoryDeleteTool.js +1 -3
- package/dist/memory/tools/MemoryDeleteTool.js.map +1 -1
- package/dist/memory/tools/MemoryMergeTool.d.ts.map +1 -1
- package/dist/memory/tools/MemoryMergeTool.js +13 -22
- package/dist/memory/tools/MemoryMergeTool.js.map +1 -1
- package/dist/memory/tools/MemorySearchTool.js +4 -4
- package/dist/memory/tools/MemorySearchTool.js.map +1 -1
- package/dist/memory/tools/MemoryUpdateTool.d.ts.map +1 -1
- package/dist/memory/tools/MemoryUpdateTool.js +10 -18
- package/dist/memory/tools/MemoryUpdateTool.js.map +1 -1
- package/dist/orchestration/runtime/LoopController.d.ts +7 -0
- package/dist/orchestration/runtime/LoopController.d.ts.map +1 -1
- package/dist/orchestration/runtime/LoopController.js +7 -0
- package/dist/orchestration/runtime/LoopController.js.map +1 -1
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
90
90
|
inlineTags.push(tagMatch[1]);
|
|
91
91
|
}
|
|
92
92
|
if (inlineTags.length > 0) {
|
|
93
|
-
this._mergeTagsIntoTrace(traceId, inlineTags, result);
|
|
93
|
+
await this._mergeTagsIntoTrace(traceId, inlineTags, result);
|
|
94
94
|
}
|
|
95
95
|
// ---- 3. Parse wikilinks and create knowledge_edges ----
|
|
96
96
|
const wikiTargets = [];
|
|
@@ -101,7 +101,7 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
101
101
|
wikiTargets.push(wikilinkMatch[1].trim());
|
|
102
102
|
}
|
|
103
103
|
for (const target of wikiTargets) {
|
|
104
|
-
this._upsertWikiEdge(traceId, target, result);
|
|
104
|
+
await this._upsertWikiEdge(traceId, target, result);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
// -------------------------------------------------------------------------
|
|
@@ -116,12 +116,10 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
116
116
|
* @param newTags - Hashtag names to add (without the leading `#`).
|
|
117
117
|
* @param result - Mutable result accumulator (errors recorded here).
|
|
118
118
|
*/
|
|
119
|
-
_mergeTagsIntoTrace(traceId, newTags, result) {
|
|
119
|
+
async _mergeTagsIntoTrace(traceId, newTags, result) {
|
|
120
120
|
try {
|
|
121
|
-
const
|
|
122
|
-
const row =
|
|
123
|
-
.prepare('SELECT tags FROM memory_traces WHERE id = ?')
|
|
124
|
-
.get(traceId);
|
|
121
|
+
const brainRef = this.brain;
|
|
122
|
+
const row = await brainRef.get('SELECT tags FROM memory_traces WHERE id = ?', [traceId]);
|
|
125
123
|
if (!row)
|
|
126
124
|
return;
|
|
127
125
|
let existing = [];
|
|
@@ -132,7 +130,7 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
132
130
|
existing = [];
|
|
133
131
|
}
|
|
134
132
|
const merged = Array.from(new Set([...existing, ...newTags]));
|
|
135
|
-
|
|
133
|
+
await brainRef.run('UPDATE memory_traces SET tags = ? WHERE id = ?', [JSON.stringify(merged), traceId]);
|
|
136
134
|
}
|
|
137
135
|
catch (err) {
|
|
138
136
|
result.errors.push(`Tag merge error for trace ${traceId}: ${String(err)}`);
|
|
@@ -155,10 +153,9 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
155
153
|
* @param targetLabel - The label of the linked note (wikilink target).
|
|
156
154
|
* @param result - Mutable result accumulator.
|
|
157
155
|
*/
|
|
158
|
-
_upsertWikiEdge(sourceTraceId, targetLabel, result) {
|
|
156
|
+
async _upsertWikiEdge(sourceTraceId, targetLabel, result) {
|
|
159
157
|
try {
|
|
160
|
-
|
|
161
|
-
const db = this.brain.db;
|
|
158
|
+
const brainRef = this.brain;
|
|
162
159
|
// ---- Upsert source knowledge node for the trace ----
|
|
163
160
|
// We use the trace ID itself as the node label so the graph stays navigable.
|
|
164
161
|
const sourceLabel = `trace:${sourceTraceId}`;
|
|
@@ -167,17 +164,20 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
167
164
|
.update(`wiki-source::${sourceTraceId}`)
|
|
168
165
|
.digest('hex');
|
|
169
166
|
let sourceNodeId;
|
|
170
|
-
const existingSource =
|
|
171
|
-
.prepare(`SELECT id FROM knowledge_nodes WHERE label = ? LIMIT 1`)
|
|
172
|
-
.get(sourceLabel);
|
|
167
|
+
const existingSource = await brainRef.get(`SELECT id FROM knowledge_nodes WHERE label = ? LIMIT 1`, [sourceLabel]);
|
|
173
168
|
if (existingSource) {
|
|
174
169
|
sourceNodeId = existingSource.id;
|
|
175
170
|
}
|
|
176
171
|
else {
|
|
177
172
|
sourceNodeId = `kn_${uuidv4()}`;
|
|
178
|
-
|
|
173
|
+
await brainRef.run(`INSERT OR IGNORE INTO knowledge_nodes
|
|
179
174
|
(id, type, label, properties, embedding, confidence, source, created_at)
|
|
180
|
-
VALUES (?, 'trace', ?, ?, NULL, 1.0, '{}', ?)
|
|
175
|
+
VALUES (?, 'trace', ?, ?, NULL, 1.0, '{}', ?)`, [
|
|
176
|
+
sourceNodeId,
|
|
177
|
+
sourceLabel,
|
|
178
|
+
JSON.stringify({ import_hash: sourceHash, trace_id: sourceTraceId }),
|
|
179
|
+
Date.now(),
|
|
180
|
+
]);
|
|
181
181
|
}
|
|
182
182
|
// ---- Upsert target knowledge node for the wikilink label ----
|
|
183
183
|
const targetHash = crypto
|
|
@@ -185,17 +185,20 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
185
185
|
.update(`wiki::${targetLabel}`)
|
|
186
186
|
.digest('hex');
|
|
187
187
|
let targetNodeId;
|
|
188
|
-
const existingTarget =
|
|
189
|
-
.prepare(`SELECT id FROM knowledge_nodes WHERE label = ? LIMIT 1`)
|
|
190
|
-
.get(targetLabel);
|
|
188
|
+
const existingTarget = await brainRef.get(`SELECT id FROM knowledge_nodes WHERE label = ? LIMIT 1`, [targetLabel]);
|
|
191
189
|
if (existingTarget) {
|
|
192
190
|
targetNodeId = existingTarget.id;
|
|
193
191
|
}
|
|
194
192
|
else {
|
|
195
193
|
targetNodeId = `kn_${uuidv4()}`;
|
|
196
|
-
|
|
194
|
+
await brainRef.run(`INSERT OR IGNORE INTO knowledge_nodes
|
|
197
195
|
(id, type, label, properties, embedding, confidence, source, created_at)
|
|
198
|
-
VALUES (?, 'concept', ?, ?, NULL, 1.0, '{}', ?)
|
|
196
|
+
VALUES (?, 'concept', ?, ?, NULL, 1.0, '{}', ?)`, [
|
|
197
|
+
targetNodeId,
|
|
198
|
+
targetLabel,
|
|
199
|
+
JSON.stringify({ import_hash: targetHash, obsidian_wikilink: true }),
|
|
200
|
+
Date.now(),
|
|
201
|
+
]);
|
|
199
202
|
}
|
|
200
203
|
// ---- Create the directed edge: source node → target node ----
|
|
201
204
|
const edgeHash = crypto
|
|
@@ -203,14 +206,18 @@ export class ObsidianImporter extends MarkdownImporter {
|
|
|
203
206
|
.update(`${sourceNodeId}::${targetNodeId}::related_to`)
|
|
204
207
|
.digest('hex');
|
|
205
208
|
// Check for existing edge before insert (extra safety beyond OR IGNORE).
|
|
206
|
-
const existingEdge =
|
|
207
|
-
|
|
208
|
-
WHERE json_extract(metadata, '$.import_hash') = ? LIMIT 1`)
|
|
209
|
-
.get(edgeHash);
|
|
209
|
+
const existingEdge = await brainRef.get(`SELECT id FROM knowledge_edges
|
|
210
|
+
WHERE json_extract(metadata, '$.import_hash') = ? LIMIT 1`, [edgeHash]);
|
|
210
211
|
if (!existingEdge) {
|
|
211
|
-
|
|
212
|
+
await brainRef.run(`INSERT OR IGNORE INTO knowledge_edges
|
|
212
213
|
(id, source_id, target_id, type, weight, bidirectional, metadata, created_at)
|
|
213
|
-
VALUES (?, ?, ?, 'related_to', 1.0, 0, ?, ?)
|
|
214
|
+
VALUES (?, ?, ?, 'related_to', 1.0, 0, ?, ?)`, [
|
|
215
|
+
`ke_${uuidv4()}`,
|
|
216
|
+
sourceNodeId,
|
|
217
|
+
targetNodeId,
|
|
218
|
+
JSON.stringify({ import_hash: edgeHash, source: 'obsidian_wikilink', trace_id: sourceTraceId }),
|
|
219
|
+
Date.now(),
|
|
220
|
+
]);
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
223
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObsidianImporter.js","sourceRoot":"","sources":["../../../src/memory/io/ObsidianImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAE5D;;;GAGG;AACH,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAmBzC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IACpD;;OAEG;IACH,YAAY,KAAkB;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E;;;;;;;;;;;;OAYG;IACgB,KAAK,CAAC,WAAW,CAClC,SAAiB,EACjB,YAA8B,EAC9B,IAAY,EACZ,MAAoB,EACpB,OAAe;QAEf,0CAA0C;QAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC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AAE,CAAC;gBAChC,MAAM,QAAQ,CAAC,GAAG,CAChB;;2DAEiD,EACjD;oBACE,YAAY;oBACZ,WAAW;oBACX,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;oBACpE,IAAI,CAAC,GAAG,EAAE;iBACX,CACF,CAAC;YACJ,CAAC;YAED,gEAAgE;YAChE,MAAM,QAAQ,GAAG,MAAM;iBACpB,UAAU,CAAC,QAAQ,CAAC;iBACpB,MAAM,CAAC,GAAG,YAAY,KAAK,YAAY,cAAc,CAAC;iBACtD,MAAM,CAAC,KAAK,CAAC,CAAC;YAEjB,yEAAyE;YACzE,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,GAAG,CACrC;qEAC6D,EAC7D,CAAC,QAAQ,CAAC,CACX,CAAC;YAEF,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,QAAQ,CAAC,GAAG,CAChB;;wDAE8C,EAC9C;oBACE,MAAM,MAAM,EAAE,EAAE;oBAChB,YAAY;oBACZ,YAAY;oBACZ,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;oBAC/F,IAAI,CAAC,GAAG,EAAE;iBACX,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB,wBAAwB,aAAa,OAAO,WAAW,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* the database file to a specified output path. This is the highest-fidelity
|
|
6
6
|
* export format — it preserves all tables, indexes, and metadata exactly.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* built-in `VACUUM INTO` SQL command (SQLite 3.27+) which atomically creates
|
|
8
|
+
* Uses the `VACUUM INTO` SQL command (SQLite 3.27+) which atomically creates
|
|
10
9
|
* a clean, fully checkpointed copy without any WAL sidecar file.
|
|
11
10
|
*
|
|
12
11
|
* @module memory/io/SqliteExporter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteExporter.d.ts","sourceRoot":"","sources":["../../../src/memory/io/SqliteExporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteExporter.d.ts","sourceRoot":"","sources":["../../../src/memory/io/SqliteExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM3D;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC;;OAEG;gBAC0B,KAAK,EAAE,WAAW;IAM/C;;;;;;;;;;;;;OAaG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1E"}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* the database file to a specified output path. This is the highest-fidelity
|
|
6
6
|
* export format — it preserves all tables, indexes, and metadata exactly.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* built-in `VACUUM INTO` SQL command (SQLite 3.27+) which atomically creates
|
|
8
|
+
* Uses the `VACUUM INTO` SQL command (SQLite 3.27+) which atomically creates
|
|
10
9
|
* a clean, fully checkpointed copy without any WAL sidecar file.
|
|
11
10
|
*
|
|
12
11
|
* @module memory/io/SqliteExporter
|
|
@@ -50,7 +49,7 @@ export class SqliteExporter {
|
|
|
50
49
|
async export(outputPath, _options) {
|
|
51
50
|
// VACUUM INTO creates a compact, defragmented copy of the live database.
|
|
52
51
|
// It is an atomic operation from SQLite's perspective.
|
|
53
|
-
this.brain.
|
|
52
|
+
await this.brain.exec(`VACUUM INTO '${outputPath.replace(/'/g, "''")}'`);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
//# sourceMappingURL=SqliteExporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteExporter.js","sourceRoot":"","sources":["../../../src/memory/io/SqliteExporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteExporter.js","sourceRoot":"","sources":["../../../src/memory/io/SqliteExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAc;IACzB;;OAEG;IACH,YAA6B,KAAkB;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAEnD,4EAA4E;IAC5E,aAAa;IACb,4EAA4E;IAE5E;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,CAAC,UAAkB,EAAE,QAAwB;QACvD,yEAAyE;QACzE,uDAAuD;QACvD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -57,6 +57,7 @@ export declare class SqliteImporter {
|
|
|
57
57
|
*
|
|
58
58
|
* @param src - Open source `better-sqlite3` database.
|
|
59
59
|
* @param result - Mutable result accumulator.
|
|
60
|
+
* @param trx - Transactional storage adapter for target writes.
|
|
60
61
|
*/
|
|
61
62
|
private _mergeTraces;
|
|
62
63
|
/**
|
|
@@ -66,6 +67,7 @@ export declare class SqliteImporter {
|
|
|
66
67
|
*
|
|
67
68
|
* @param src - Open source database.
|
|
68
69
|
* @param result - Mutable result accumulator.
|
|
70
|
+
* @param trx - Transactional storage adapter for target writes.
|
|
69
71
|
*/
|
|
70
72
|
private _mergeNodes;
|
|
71
73
|
/**
|
|
@@ -76,6 +78,7 @@ export declare class SqliteImporter {
|
|
|
76
78
|
*
|
|
77
79
|
* @param src - Open source database.
|
|
78
80
|
* @param result - Mutable result accumulator.
|
|
81
|
+
* @param trx - Transactional storage adapter for target writes.
|
|
79
82
|
*/
|
|
80
83
|
private _mergeEdges;
|
|
81
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteImporter.d.ts","sourceRoot":"","sources":["../../../src/memory/io/SqliteImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAgD3D;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC;;OAEG;gBAC0B,KAAK,EAAE,WAAW;IAM/C;;;;;;;;OAQG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA8BvD;;OAEG;IACH,OAAO,CAAC,OAAO;IAIf
|
|
1
|
+
{"version":3,"file":"SqliteImporter.d.ts","sourceRoot":"","sources":["../../../src/memory/io/SqliteImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAgD3D;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC;;OAEG;gBAC0B,KAAK,EAAE,WAAW;IAM/C;;;;;;;;OAQG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA8BvD;;OAEG;IACH,OAAO,CAAC,OAAO;IAIf;;;;;;;;;OASG;YACW,YAAY;IA8E1B;;;;;;;;OAQG;YACW,WAAW;IA4CzB;;;;;;;;;OASG;YACW,WAAW;CAqD1B"}
|
|
@@ -65,11 +65,11 @@ export class SqliteImporter {
|
|
|
65
65
|
}
|
|
66
66
|
try {
|
|
67
67
|
// Run the whole merge in a single transaction on the target brain.
|
|
68
|
-
this.brain.
|
|
69
|
-
this._mergeTraces(sourceDb, result);
|
|
70
|
-
this._mergeNodes(sourceDb, result);
|
|
71
|
-
this._mergeEdges(sourceDb, result);
|
|
72
|
-
})
|
|
68
|
+
await this.brain.transaction(async (trx) => {
|
|
69
|
+
await this._mergeTraces(sourceDb, result, trx);
|
|
70
|
+
await this._mergeNodes(sourceDb, result, trx);
|
|
71
|
+
await this._mergeEdges(sourceDb, result, trx);
|
|
72
|
+
});
|
|
73
73
|
}
|
|
74
74
|
finally {
|
|
75
75
|
sourceDb.close();
|
|
@@ -93,8 +93,9 @@ export class SqliteImporter {
|
|
|
93
93
|
*
|
|
94
94
|
* @param src - Open source `better-sqlite3` database.
|
|
95
95
|
* @param result - Mutable result accumulator.
|
|
96
|
+
* @param trx - Transactional storage adapter for target writes.
|
|
96
97
|
*/
|
|
97
|
-
_mergeTraces(src, result) {
|
|
98
|
+
async _mergeTraces(src, result, trx) {
|
|
98
99
|
let sourceRows;
|
|
99
100
|
try {
|
|
100
101
|
sourceRows = src.prepare('SELECT * FROM memory_traces').all();
|
|
@@ -103,20 +104,20 @@ export class SqliteImporter {
|
|
|
103
104
|
// Table might not exist in an incompatible source.
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
|
-
const
|
|
107
|
+
const checkSql = `SELECT id, created_at, tags
|
|
107
108
|
FROM memory_traces
|
|
108
109
|
WHERE json_extract(metadata, '$.import_hash') = ?
|
|
109
110
|
OR content = ?
|
|
110
|
-
LIMIT 1
|
|
111
|
-
const
|
|
111
|
+
LIMIT 1`;
|
|
112
|
+
const insertSql = `INSERT INTO memory_traces
|
|
112
113
|
(id, type, scope, content, embedding, strength, created_at, last_accessed,
|
|
113
114
|
retrieval_count, tags, emotions, metadata, deleted)
|
|
114
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
115
|
-
const
|
|
115
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
116
|
+
const updateTimestampSql = `UPDATE memory_traces SET created_at = ?, tags = ? WHERE id = ?`;
|
|
116
117
|
for (const row of sourceRows) {
|
|
117
118
|
try {
|
|
118
119
|
const hash = this._sha256(row.content);
|
|
119
|
-
const existing =
|
|
120
|
+
const existing = await trx.get(checkSql, [hash, row.content]);
|
|
120
121
|
if (existing) {
|
|
121
122
|
// Keep the newer timestamp and union the tags.
|
|
122
123
|
const newerAt = Math.max(existing.created_at, row.created_at);
|
|
@@ -131,7 +132,7 @@ export class SqliteImporter {
|
|
|
131
132
|
}
|
|
132
133
|
catch { /* ignore */ }
|
|
133
134
|
const merged = Array.from(new Set([...existingTags, ...sourceTags]));
|
|
134
|
-
|
|
135
|
+
await trx.run(updateTimestampSql, [newerAt, JSON.stringify(merged), existing.id]);
|
|
135
136
|
result.skipped++;
|
|
136
137
|
continue;
|
|
137
138
|
}
|
|
@@ -142,7 +143,21 @@ export class SqliteImporter {
|
|
|
142
143
|
}
|
|
143
144
|
catch { /* ignore */ }
|
|
144
145
|
meta['import_hash'] = hash;
|
|
145
|
-
|
|
146
|
+
await trx.run(insertSql, [
|
|
147
|
+
row.id ?? `mt_${uuidv4()}`,
|
|
148
|
+
row.type ?? 'episodic',
|
|
149
|
+
row.scope ?? 'user',
|
|
150
|
+
row.content,
|
|
151
|
+
row.embedding ?? null,
|
|
152
|
+
row.strength ?? 1.0,
|
|
153
|
+
row.created_at ?? Date.now(),
|
|
154
|
+
row.last_accessed ?? null,
|
|
155
|
+
row.retrieval_count ?? 0,
|
|
156
|
+
row.tags ?? '[]',
|
|
157
|
+
row.emotions ?? '{}',
|
|
158
|
+
JSON.stringify(meta),
|
|
159
|
+
row.deleted ?? 0,
|
|
160
|
+
]);
|
|
146
161
|
result.imported++;
|
|
147
162
|
}
|
|
148
163
|
catch (err) {
|
|
@@ -157,8 +172,9 @@ export class SqliteImporter {
|
|
|
157
172
|
*
|
|
158
173
|
* @param src - Open source database.
|
|
159
174
|
* @param result - Mutable result accumulator.
|
|
175
|
+
* @param trx - Transactional storage adapter for target writes.
|
|
160
176
|
*/
|
|
161
|
-
_mergeNodes(src, result) {
|
|
177
|
+
async _mergeNodes(src, result, trx) {
|
|
162
178
|
let sourceRows;
|
|
163
179
|
try {
|
|
164
180
|
sourceRows = src.prepare('SELECT * FROM knowledge_nodes').all();
|
|
@@ -166,18 +182,27 @@ export class SqliteImporter {
|
|
|
166
182
|
catch {
|
|
167
183
|
return;
|
|
168
184
|
}
|
|
169
|
-
const
|
|
170
|
-
const
|
|
185
|
+
const checkSql = `SELECT id FROM knowledge_nodes WHERE label = ? AND type = ? LIMIT 1`;
|
|
186
|
+
const insertSql = `INSERT OR IGNORE INTO knowledge_nodes
|
|
171
187
|
(id, type, label, properties, embedding, confidence, source, created_at)
|
|
172
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
188
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
173
189
|
for (const row of sourceRows) {
|
|
174
190
|
try {
|
|
175
|
-
const existing =
|
|
191
|
+
const existing = await trx.get(checkSql, [row.label ?? '', row.type ?? '']);
|
|
176
192
|
if (existing) {
|
|
177
193
|
result.skipped++;
|
|
178
194
|
continue;
|
|
179
195
|
}
|
|
180
|
-
|
|
196
|
+
await trx.run(insertSql, [
|
|
197
|
+
row.id ?? `kn_${uuidv4()}`,
|
|
198
|
+
row.type ?? 'concept',
|
|
199
|
+
row.label ?? '',
|
|
200
|
+
row.properties ?? '{}',
|
|
201
|
+
row.embedding ?? null,
|
|
202
|
+
row.confidence ?? 1.0,
|
|
203
|
+
row.source ?? '{}',
|
|
204
|
+
row.created_at ?? Date.now(),
|
|
205
|
+
]);
|
|
181
206
|
result.imported++;
|
|
182
207
|
}
|
|
183
208
|
catch (err) {
|
|
@@ -193,8 +218,9 @@ export class SqliteImporter {
|
|
|
193
218
|
*
|
|
194
219
|
* @param src - Open source database.
|
|
195
220
|
* @param result - Mutable result accumulator.
|
|
221
|
+
* @param trx - Transactional storage adapter for target writes.
|
|
196
222
|
*/
|
|
197
|
-
_mergeEdges(src, result) {
|
|
223
|
+
async _mergeEdges(src, result, trx) {
|
|
198
224
|
let sourceRows;
|
|
199
225
|
try {
|
|
200
226
|
sourceRows = src.prepare('SELECT * FROM knowledge_edges').all();
|
|
@@ -202,24 +228,33 @@ export class SqliteImporter {
|
|
|
202
228
|
catch {
|
|
203
229
|
return;
|
|
204
230
|
}
|
|
205
|
-
const
|
|
231
|
+
const checkSql = `SELECT id FROM knowledge_edges
|
|
206
232
|
WHERE source_id = ? AND target_id = ? AND type = ?
|
|
207
|
-
LIMIT 1
|
|
208
|
-
const
|
|
233
|
+
LIMIT 1`;
|
|
234
|
+
const insertSql = `INSERT OR IGNORE INTO knowledge_edges
|
|
209
235
|
(id, source_id, target_id, type, weight, bidirectional, metadata, created_at)
|
|
210
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
236
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
211
237
|
for (const row of sourceRows) {
|
|
212
238
|
try {
|
|
213
239
|
if (!row.source_id || !row.target_id) {
|
|
214
240
|
result.skipped++;
|
|
215
241
|
continue;
|
|
216
242
|
}
|
|
217
|
-
const existing =
|
|
243
|
+
const existing = await trx.get(checkSql, [row.source_id, row.target_id, row.type ?? '']);
|
|
218
244
|
if (existing) {
|
|
219
245
|
result.skipped++;
|
|
220
246
|
continue;
|
|
221
247
|
}
|
|
222
|
-
|
|
248
|
+
await trx.run(insertSql, [
|
|
249
|
+
row.id ?? `ke_${uuidv4()}`,
|
|
250
|
+
row.source_id,
|
|
251
|
+
row.target_id,
|
|
252
|
+
row.type ?? 'related_to',
|
|
253
|
+
row.weight ?? 1.0,
|
|
254
|
+
row.bidirectional ?? 0,
|
|
255
|
+
row.metadata ?? '{}',
|
|
256
|
+
row.created_at ?? Date.now(),
|
|
257
|
+
]);
|
|
223
258
|
result.imported++;
|
|
224
259
|
}
|
|
225
260
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteImporter.js","sourceRoot":"","sources":["../../../src/memory/io/SqliteImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AA8CpC,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAc;IACzB;;OAEG;IACH,YAA6B,KAAkB;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAEnD,4EAA4E;IAC5E,aAAa;IACb,4EAA4E;IAE5E;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,MAAM,MAAM,GAAiB,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAErE,uEAAuE;QACvE,IAAI,QAA2B,CAAC;QAChC,IAAI,CAAC;YACH,QAAQ,GAAG,IAAI,QAAQ,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChE,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,CAA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AAG,CAAC,GAAG,CAC5B,QAAQ,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CACzD,CAAC;gBACF,IAAI,QAAQ,EAAE,CAAC;oBACb,MAAM,CAAC,OAAO,EAAE,CAAC;oBACjB,SAAS;gBACX,CAAC;gBAED,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE;oBACvB,GAAG,CAAC,EAAE,IAAI,MAAM,MAAM,EAAE,EAAE;oBAC1B,GAAG,CAAC,SAAS;oBACb,GAAG,CAAC,SAAS;oBACb,GAAG,CAAC,IAAI,IAAI,YAAY;oBACxB,GAAG,CAAC,MAAM,IAAI,GAAG;oBACjB,GAAG,CAAC,aAAa,IAAI,CAAC;oBACtB,GAAG,CAAC,QAAQ,IAAI,IAAI;oBACpB,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,EAAE;iBAC7B,CAAC,CAAC;gBAEH,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,+EAA+E;gBAC/E,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
* - `retrieval_feedback` → Hebbian reinforcement ("neurons that fire together wire together")
|
|
16
16
|
*
|
|
17
17
|
* ## Storage design choices
|
|
18
|
-
* - **
|
|
18
|
+
* - **Cross-platform**: Uses `@framers/sql-storage-adapter` StorageAdapter interface,
|
|
19
|
+
* enabling browser (IndexedDB/sql.js), mobile (Capacitor), and Postgres backends
|
|
20
|
+
* in addition to the default Node.js better-sqlite3 path.
|
|
21
|
+
* - **WAL mode**: allows concurrent reads during writes (when adapter supports it).
|
|
19
22
|
* - **FTS5 with Porter tokenizer**: enables fast full-text search over memory content with
|
|
20
23
|
* morphological stemming (retrieval cue → "retriev*").
|
|
21
24
|
* - **Embeddings as BLOBs**: raw Float32Array buffers stored directly — no external vector DB
|
|
@@ -25,43 +28,52 @@
|
|
|
25
28
|
*
|
|
26
29
|
* @module memory/store/SqliteBrain
|
|
27
30
|
*/
|
|
28
|
-
import
|
|
31
|
+
import type { StorageAdapter, StorageRunResult, StorageParameters } from '@framers/sql-storage-adapter';
|
|
29
32
|
/**
|
|
30
|
-
* Unified
|
|
33
|
+
* Unified cross-platform connection manager for a single agent's persistent brain.
|
|
34
|
+
*
|
|
35
|
+
* Uses the `StorageAdapter` interface from `@framers/sql-storage-adapter` to
|
|
36
|
+
* support multiple backends (better-sqlite3, sql.js, IndexedDB, Postgres, etc.)
|
|
37
|
+
* transparently. All methods are async.
|
|
31
38
|
*
|
|
32
39
|
* **Usage:**
|
|
33
40
|
* ```ts
|
|
34
|
-
* const brain =
|
|
41
|
+
* const brain = await SqliteBrain.open('/path/to/agent/brain.sqlite');
|
|
35
42
|
*
|
|
36
|
-
* //
|
|
37
|
-
* const row = brain.
|
|
43
|
+
* // Async query API for subsystems
|
|
44
|
+
* const row = await brain.get<{ value: string }>('SELECT value FROM brain_meta WHERE key = ?', ['schema_version']);
|
|
38
45
|
*
|
|
39
46
|
* // Meta helpers
|
|
40
|
-
* brain.setMeta('last_sync', Date.now().toString());
|
|
41
|
-
* const ver = brain.getMeta('schema_version'); // '1'
|
|
47
|
+
* await brain.setMeta('last_sync', Date.now().toString());
|
|
48
|
+
* const ver = await brain.getMeta('schema_version'); // '1'
|
|
42
49
|
*
|
|
43
|
-
* brain.close();
|
|
50
|
+
* await brain.close();
|
|
44
51
|
* ```
|
|
45
52
|
*
|
|
46
|
-
* Subsystems (
|
|
47
|
-
* receive the `SqliteBrain` instance and call
|
|
48
|
-
*
|
|
53
|
+
* Subsystems (KnowledgeGraph, MemoryGraph, ConsolidationLoop, etc.)
|
|
54
|
+
* receive the `SqliteBrain` instance and call its async proxy methods
|
|
55
|
+
* (`run`, `get`, `all`, `exec`, `transaction`) for all database operations.
|
|
49
56
|
*/
|
|
50
57
|
export declare class SqliteBrain {
|
|
51
58
|
/**
|
|
52
|
-
* The
|
|
59
|
+
* The cross-platform storage adapter backing this brain.
|
|
60
|
+
* Not exposed publicly — consumers use the async proxy methods instead.
|
|
61
|
+
*/
|
|
62
|
+
private readonly _adapter;
|
|
63
|
+
/**
|
|
64
|
+
* Private constructor — use `SqliteBrain.open(dbPath)` instead.
|
|
53
65
|
*
|
|
54
|
-
*
|
|
55
|
-
* without going through an intermediary layer. `better-sqlite3` is
|
|
56
|
-
* synchronous and thread-safe for single-writer, multi-reader scenarios.
|
|
66
|
+
* @param adapter - A fully initialised StorageAdapter instance.
|
|
57
67
|
*/
|
|
58
|
-
|
|
68
|
+
private constructor();
|
|
59
69
|
/**
|
|
60
70
|
* Create or open the agent's brain database at `dbPath`.
|
|
61
71
|
*
|
|
72
|
+
* Async factory that replaces the previous synchronous constructor.
|
|
73
|
+
*
|
|
62
74
|
* Initialization sequence:
|
|
63
|
-
* 1.
|
|
64
|
-
* 2. Enable WAL journal mode for concurrent read access.
|
|
75
|
+
* 1. Resolve the best available storage adapter for the current runtime.
|
|
76
|
+
* 2. Enable WAL journal mode for concurrent read access (when supported).
|
|
65
77
|
* 3. Enable foreign key enforcement (OFF by default in SQLite).
|
|
66
78
|
* 4. Execute the full DDL schema (all `CREATE TABLE IF NOT EXISTS`).
|
|
67
79
|
* 5. Create the FTS5 virtual table for full-text memory search.
|
|
@@ -69,8 +81,56 @@ export declare class SqliteBrain {
|
|
|
69
81
|
*
|
|
70
82
|
* @param dbPath - Absolute path to the `.sqlite` file. The file is created
|
|
71
83
|
* if it does not exist; parent directories must already exist.
|
|
84
|
+
* @returns A fully initialised `SqliteBrain` instance.
|
|
85
|
+
*/
|
|
86
|
+
static open(dbPath: string): Promise<SqliteBrain>;
|
|
87
|
+
/**
|
|
88
|
+
* Execute a mutation statement (INSERT, UPDATE, DELETE).
|
|
89
|
+
*
|
|
90
|
+
* @param sql - SQL statement with `?` positional placeholders.
|
|
91
|
+
* @param params - Parameter array matching the placeholders.
|
|
92
|
+
* @returns Metadata about affected rows.
|
|
93
|
+
*/
|
|
94
|
+
run(sql: string, params?: StorageParameters): Promise<StorageRunResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Retrieve a single row (or null if none found).
|
|
97
|
+
*
|
|
98
|
+
* @param sql - SQL SELECT statement.
|
|
99
|
+
* @param params - Parameter array.
|
|
100
|
+
* @returns First matching row or null.
|
|
101
|
+
*/
|
|
102
|
+
get<T = unknown>(sql: string, params?: StorageParameters): Promise<T | null>;
|
|
103
|
+
/**
|
|
104
|
+
* Retrieve all rows matching the statement.
|
|
105
|
+
*
|
|
106
|
+
* @param sql - SQL SELECT statement.
|
|
107
|
+
* @param params - Parameter array.
|
|
108
|
+
* @returns Array of matching rows (empty array if none).
|
|
109
|
+
*/
|
|
110
|
+
all<T = unknown>(sql: string, params?: StorageParameters): Promise<T[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Execute a script containing multiple SQL statements.
|
|
113
|
+
*
|
|
114
|
+
* @param sql - SQL script (semicolon-delimited statements).
|
|
115
|
+
*/
|
|
116
|
+
exec(sql: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Execute a callback within a database transaction.
|
|
119
|
+
*
|
|
120
|
+
* The transaction is automatically committed on success or rolled back
|
|
121
|
+
* on error.
|
|
122
|
+
*
|
|
123
|
+
* @param fn - Async callback receiving a transactional adapter.
|
|
124
|
+
* @returns Result of the callback.
|
|
125
|
+
*/
|
|
126
|
+
transaction<T>(fn: (trx: StorageAdapter) => Promise<T>): Promise<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Expose the raw storage adapter for advanced usage.
|
|
129
|
+
*
|
|
130
|
+
* Primarily used by SqliteExporter (VACUUM INTO) and SqliteImporter
|
|
131
|
+
* (which needs direct adapter access for the target brain).
|
|
72
132
|
*/
|
|
73
|
-
|
|
133
|
+
get adapter(): StorageAdapter;
|
|
74
134
|
/**
|
|
75
135
|
* Execute all DDL statements inside a single transaction.
|
|
76
136
|
* `CREATE TABLE IF NOT EXISTS` is idempotent, so re-running on an existing
|
|
@@ -88,7 +148,7 @@ export declare class SqliteBrain {
|
|
|
88
148
|
* @param key - The metadata key to look up.
|
|
89
149
|
* @returns The stored string value, or `undefined` if the key does not exist.
|
|
90
150
|
*/
|
|
91
|
-
getMeta(key: string): string | undefined
|
|
151
|
+
getMeta(key: string): Promise<string | undefined>;
|
|
92
152
|
/**
|
|
93
153
|
* Upsert a value into the `brain_meta` key-value store.
|
|
94
154
|
*
|
|
@@ -98,7 +158,7 @@ export declare class SqliteBrain {
|
|
|
98
158
|
* @param key - The metadata key.
|
|
99
159
|
* @param value - The string value to store.
|
|
100
160
|
*/
|
|
101
|
-
setMeta(key: string, value: string): void
|
|
161
|
+
setMeta(key: string, value: string): Promise<void>;
|
|
102
162
|
/**
|
|
103
163
|
* Check whether a given embedding dimension is compatible with this brain.
|
|
104
164
|
*
|
|
@@ -112,7 +172,7 @@ export declare class SqliteBrain {
|
|
|
112
172
|
* @param dimensions - The embedding vector length to check (e.g. 1536 for OpenAI ada-002).
|
|
113
173
|
* @returns `true` if compatible (or no prior value), `false` on mismatch.
|
|
114
174
|
*/
|
|
115
|
-
checkEmbeddingCompat(dimensions: number): boolean
|
|
175
|
+
checkEmbeddingCompat(dimensions: number): Promise<boolean>;
|
|
116
176
|
/**
|
|
117
177
|
* Close the database connection.
|
|
118
178
|
*
|
|
@@ -120,6 +180,6 @@ export declare class SqliteBrain {
|
|
|
120
180
|
* the file lock. Failing to close may leave the database in WAL mode with
|
|
121
181
|
* an unconsumed WAL file.
|
|
122
182
|
*/
|
|
123
|
-
close(): void
|
|
183
|
+
close(): Promise<void>;
|
|
124
184
|
}
|
|
125
185
|
//# sourceMappingURL=SqliteBrain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteBrain.d.ts","sourceRoot":"","sources":["../../../src/memory/store/SqliteBrain.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteBrain.d.ts","sourceRoot":"","sources":["../../../src/memory/store/SqliteBrain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AAoPtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,WAAW;IACtB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAM1C;;;;OAIG;IACH,OAAO;IAQP;;;;;;;;;;;;;;;;OAgBG;WACU,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAiCvD;;;;;;OAMG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI7E;;;;;;OAMG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAIlF;;;;;;OAMG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAI7E;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC;;;;;;;;OAQG;IACG,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzE;;;;;OAKG;IACH,IAAI,OAAO,IAAI,cAAc,CAE5B;IAM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