swarm-mail 0.5.0 → 1.0.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 +84 -0
- package/bin/daemon-cli.ts +4 -4
- package/dist/beads/adapter.d.ts +38 -0
- package/dist/beads/adapter.d.ts.map +1 -0
- package/dist/beads/blocked-cache.d.ts +21 -0
- package/dist/beads/blocked-cache.d.ts.map +1 -0
- package/dist/beads/comments.d.ts +21 -0
- package/dist/beads/comments.d.ts.map +1 -0
- package/dist/beads/dependencies.d.ts +58 -0
- package/dist/beads/dependencies.d.ts.map +1 -0
- package/dist/beads/events.d.ts +163 -0
- package/dist/beads/events.d.ts.map +1 -0
- package/dist/beads/flush-manager.d.ts +71 -0
- package/dist/beads/flush-manager.d.ts.map +1 -0
- package/dist/beads/index.d.ts +25 -0
- package/dist/beads/index.d.ts.map +1 -0
- package/dist/beads/jsonl.d.ts +103 -0
- package/dist/beads/jsonl.d.ts.map +1 -0
- package/dist/beads/labels.d.ts +21 -0
- package/dist/beads/labels.d.ts.map +1 -0
- package/dist/beads/merge.d.ts +99 -0
- package/dist/beads/merge.d.ts.map +1 -0
- package/dist/beads/migrations.d.ts +41 -0
- package/dist/beads/migrations.d.ts.map +1 -0
- package/dist/beads/operations.d.ts +56 -0
- package/dist/beads/operations.d.ts.map +1 -0
- package/dist/beads/projections.d.ts +103 -0
- package/dist/beads/projections.d.ts.map +1 -0
- package/dist/beads/queries.d.ts +77 -0
- package/dist/beads/queries.d.ts.map +1 -0
- package/dist/beads/store.d.ts +98 -0
- package/dist/beads/store.d.ts.map +1 -0
- package/dist/beads/validation.d.ts +75 -0
- package/dist/beads/validation.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -6
- package/dist/memory/adapter.d.ts +2 -0
- package/dist/memory/adapter.d.ts.map +1 -1
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/migrations.d.ts.map +1 -1
- package/dist/memory/store.d.ts +2 -0
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/sync.d.ts +93 -0
- package/dist/memory/sync.d.ts.map +1 -0
- package/dist/types/beads-adapter.d.ts +397 -0
- package/dist/types/beads-adapter.d.ts.map +1 -0
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -16860,7 +16860,8 @@ var init_migrations2 = __esm(() => {
|
|
|
16860
16860
|
content TEXT NOT NULL,
|
|
16861
16861
|
metadata JSONB DEFAULT '{}',
|
|
16862
16862
|
collection TEXT DEFAULT 'default',
|
|
16863
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
16863
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
16864
|
+
confidence REAL DEFAULT 0.7
|
|
16864
16865
|
);
|
|
16865
16866
|
|
|
16866
16867
|
-- Collection filtering index
|
|
@@ -20711,23 +20712,26 @@ function createMemoryStore(db) {
|
|
|
20711
20712
|
content: row.content,
|
|
20712
20713
|
metadata: row.metadata ?? {},
|
|
20713
20714
|
collection: row.collection ?? "default",
|
|
20714
|
-
createdAt: new Date(row.created_at)
|
|
20715
|
+
createdAt: new Date(row.created_at),
|
|
20716
|
+
confidence: row.confidence ?? 0.7
|
|
20715
20717
|
});
|
|
20716
20718
|
return {
|
|
20717
20719
|
async store(memory, embedding) {
|
|
20718
20720
|
await db.exec("BEGIN");
|
|
20719
20721
|
try {
|
|
20720
|
-
await db.query(`INSERT INTO memories (id, content, metadata, collection, created_at)
|
|
20721
|
-
VALUES ($1, $2, $3, $4, $5)
|
|
20722
|
+
await db.query(`INSERT INTO memories (id, content, metadata, collection, created_at, confidence)
|
|
20723
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
20722
20724
|
ON CONFLICT (id) DO UPDATE SET
|
|
20723
20725
|
content = EXCLUDED.content,
|
|
20724
20726
|
metadata = EXCLUDED.metadata,
|
|
20725
|
-
collection = EXCLUDED.collection
|
|
20727
|
+
collection = EXCLUDED.collection,
|
|
20728
|
+
confidence = EXCLUDED.confidence`, [
|
|
20726
20729
|
memory.id,
|
|
20727
20730
|
memory.content,
|
|
20728
20731
|
JSON.stringify(memory.metadata),
|
|
20729
20732
|
memory.collection,
|
|
20730
|
-
memory.createdAt.toISOString()
|
|
20733
|
+
memory.createdAt.toISOString(),
|
|
20734
|
+
memory.confidence ?? 0.7
|
|
20731
20735
|
]);
|
|
20732
20736
|
const vectorStr = `[${embedding.join(",")}]`;
|
|
20733
20737
|
await db.query(`INSERT INTO memory_embeddings (memory_id, embedding)
|
|
@@ -20750,6 +20754,7 @@ function createMemoryStore(db) {
|
|
|
20750
20754
|
m.metadata,
|
|
20751
20755
|
m.collection,
|
|
20752
20756
|
m.created_at,
|
|
20757
|
+
m.confidence,
|
|
20753
20758
|
1 - (e.embedding <=> $1::vector) as score
|
|
20754
20759
|
FROM memory_embeddings e
|
|
20755
20760
|
JOIN memories m ON m.id = e.memory_id
|
|
@@ -20786,6 +20791,7 @@ function createMemoryStore(db) {
|
|
|
20786
20791
|
m.metadata,
|
|
20787
20792
|
m.collection,
|
|
20788
20793
|
m.created_at,
|
|
20794
|
+
m.confidence,
|
|
20789
20795
|
ts_rank(to_tsvector('english', m.content), plainto_tsquery('english', $1)) as score
|
|
20790
20796
|
FROM memories m
|
|
20791
20797
|
WHERE to_tsvector('english', m.content) @@ plainto_tsquery('english', $1)
|
|
@@ -55211,6 +55217,169 @@ async function getMigrationStatus(legacyPath) {
|
|
|
55211
55217
|
await db.close();
|
|
55212
55218
|
}
|
|
55213
55219
|
}
|
|
55220
|
+
// src/memory/sync.ts
|
|
55221
|
+
import { existsSync as existsSync7, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
55222
|
+
import { join as join11 } from "node:path";
|
|
55223
|
+
function serializeMemoryToJSONL(memory) {
|
|
55224
|
+
const clean = {
|
|
55225
|
+
id: memory.id,
|
|
55226
|
+
information: memory.information,
|
|
55227
|
+
created_at: memory.created_at
|
|
55228
|
+
};
|
|
55229
|
+
if (memory.metadata !== undefined) {
|
|
55230
|
+
clean.metadata = memory.metadata;
|
|
55231
|
+
}
|
|
55232
|
+
if (memory.tags !== undefined) {
|
|
55233
|
+
clean.tags = memory.tags;
|
|
55234
|
+
}
|
|
55235
|
+
if (memory.confidence !== undefined) {
|
|
55236
|
+
clean.confidence = memory.confidence;
|
|
55237
|
+
}
|
|
55238
|
+
return JSON.stringify(clean);
|
|
55239
|
+
}
|
|
55240
|
+
function parseMemoryJSONL(jsonl) {
|
|
55241
|
+
if (!jsonl || jsonl.trim() === "") {
|
|
55242
|
+
return [];
|
|
55243
|
+
}
|
|
55244
|
+
const lines = jsonl.split(`
|
|
55245
|
+
`);
|
|
55246
|
+
const memories = [];
|
|
55247
|
+
for (const line of lines) {
|
|
55248
|
+
const trimmed2 = line.trim();
|
|
55249
|
+
if (trimmed2 === "") {
|
|
55250
|
+
continue;
|
|
55251
|
+
}
|
|
55252
|
+
try {
|
|
55253
|
+
const memory = JSON.parse(trimmed2);
|
|
55254
|
+
memories.push(memory);
|
|
55255
|
+
} catch (err) {
|
|
55256
|
+
throw new Error(`Invalid JSON in JSONL: ${err instanceof Error ? err.message : String(err)}`);
|
|
55257
|
+
}
|
|
55258
|
+
}
|
|
55259
|
+
return memories;
|
|
55260
|
+
}
|
|
55261
|
+
async function exportMemories(db, options = {}) {
|
|
55262
|
+
const conditions = [];
|
|
55263
|
+
const params = [];
|
|
55264
|
+
let paramIndex = 1;
|
|
55265
|
+
if (options.collection) {
|
|
55266
|
+
conditions.push(`collection = $${paramIndex++}`);
|
|
55267
|
+
params.push(options.collection);
|
|
55268
|
+
}
|
|
55269
|
+
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
55270
|
+
const query = `
|
|
55271
|
+
SELECT id, content, metadata, collection, created_at
|
|
55272
|
+
FROM memories
|
|
55273
|
+
${whereClause}
|
|
55274
|
+
ORDER BY id ASC
|
|
55275
|
+
`;
|
|
55276
|
+
const result = await db.query(query, params);
|
|
55277
|
+
if (result.rows.length === 0) {
|
|
55278
|
+
return "";
|
|
55279
|
+
}
|
|
55280
|
+
const lines = [];
|
|
55281
|
+
for (const row of result.rows) {
|
|
55282
|
+
let metadata = {};
|
|
55283
|
+
try {
|
|
55284
|
+
if (typeof row.metadata === "string") {
|
|
55285
|
+
metadata = JSON.parse(row.metadata || "{}");
|
|
55286
|
+
} else if (row.metadata && typeof row.metadata === "object") {
|
|
55287
|
+
metadata = row.metadata;
|
|
55288
|
+
}
|
|
55289
|
+
} catch {}
|
|
55290
|
+
const tags = Array.isArray(metadata.tags) ? metadata.tags.join(",") : undefined;
|
|
55291
|
+
const confidence = typeof metadata.confidence === "number" ? metadata.confidence : undefined;
|
|
55292
|
+
const metadataWithoutSpecial = { ...metadata };
|
|
55293
|
+
delete metadataWithoutSpecial.tags;
|
|
55294
|
+
delete metadataWithoutSpecial.confidence;
|
|
55295
|
+
const metadataStr = Object.keys(metadataWithoutSpecial).length > 0 ? JSON.stringify(metadataWithoutSpecial) : undefined;
|
|
55296
|
+
const memoryExport = {
|
|
55297
|
+
id: row.id,
|
|
55298
|
+
information: row.content,
|
|
55299
|
+
metadata: metadataStr,
|
|
55300
|
+
tags,
|
|
55301
|
+
confidence,
|
|
55302
|
+
created_at: row.created_at
|
|
55303
|
+
};
|
|
55304
|
+
lines.push(serializeMemoryToJSONL(memoryExport));
|
|
55305
|
+
}
|
|
55306
|
+
return lines.join(`
|
|
55307
|
+
`);
|
|
55308
|
+
}
|
|
55309
|
+
async function importMemories(db, jsonl, options = {}) {
|
|
55310
|
+
const { skipExisting = true } = options;
|
|
55311
|
+
const memories = parseMemoryJSONL(jsonl);
|
|
55312
|
+
const result = {
|
|
55313
|
+
created: 0,
|
|
55314
|
+
skipped: 0,
|
|
55315
|
+
errors: []
|
|
55316
|
+
};
|
|
55317
|
+
for (const memoryExport of memories) {
|
|
55318
|
+
try {
|
|
55319
|
+
await importSingleMemory(db, memoryExport, skipExisting, result);
|
|
55320
|
+
} catch (err) {
|
|
55321
|
+
result.errors.push({
|
|
55322
|
+
memoryId: memoryExport.id,
|
|
55323
|
+
error: err instanceof Error ? err.message : String(err)
|
|
55324
|
+
});
|
|
55325
|
+
}
|
|
55326
|
+
}
|
|
55327
|
+
return result;
|
|
55328
|
+
}
|
|
55329
|
+
async function importSingleMemory(db, memoryExport, skipExisting, result) {
|
|
55330
|
+
if (!memoryExport.id || memoryExport.id.trim() === "") {
|
|
55331
|
+
throw new Error("Memory ID is required");
|
|
55332
|
+
}
|
|
55333
|
+
const existingResult = await db.query("SELECT id FROM memories WHERE id = $1", [memoryExport.id]);
|
|
55334
|
+
if (existingResult.rows.length > 0) {
|
|
55335
|
+
if (skipExisting) {
|
|
55336
|
+
result.skipped++;
|
|
55337
|
+
return;
|
|
55338
|
+
}
|
|
55339
|
+
result.skipped++;
|
|
55340
|
+
return;
|
|
55341
|
+
}
|
|
55342
|
+
const metadata = {};
|
|
55343
|
+
if (memoryExport.metadata) {
|
|
55344
|
+
try {
|
|
55345
|
+
const parsed = JSON.parse(memoryExport.metadata);
|
|
55346
|
+
Object.assign(metadata, parsed);
|
|
55347
|
+
} catch {
|
|
55348
|
+
metadata.raw = memoryExport.metadata;
|
|
55349
|
+
}
|
|
55350
|
+
}
|
|
55351
|
+
if (memoryExport.tags) {
|
|
55352
|
+
metadata.tags = memoryExport.tags.split(",").map((t) => t.trim());
|
|
55353
|
+
}
|
|
55354
|
+
if (memoryExport.confidence !== undefined) {
|
|
55355
|
+
metadata.confidence = memoryExport.confidence;
|
|
55356
|
+
}
|
|
55357
|
+
await db.query(`INSERT INTO memories (id, content, metadata, collection, created_at)
|
|
55358
|
+
VALUES ($1, $2, $3, $4, $5)`, [
|
|
55359
|
+
memoryExport.id,
|
|
55360
|
+
memoryExport.information,
|
|
55361
|
+
JSON.stringify(metadata),
|
|
55362
|
+
"default",
|
|
55363
|
+
memoryExport.created_at
|
|
55364
|
+
]);
|
|
55365
|
+
result.created++;
|
|
55366
|
+
}
|
|
55367
|
+
async function syncMemories(db, hivePath) {
|
|
55368
|
+
const memoriesPath = join11(hivePath, "memories.jsonl");
|
|
55369
|
+
let importResult = { created: 0, skipped: 0, errors: [] };
|
|
55370
|
+
if (existsSync7(memoriesPath)) {
|
|
55371
|
+
const fileContent = readFileSync2(memoriesPath, "utf-8");
|
|
55372
|
+
importResult = await importMemories(db, fileContent);
|
|
55373
|
+
}
|
|
55374
|
+
const exportContent = await exportMemories(db);
|
|
55375
|
+
writeFileSync2(memoriesPath, exportContent);
|
|
55376
|
+
const exportedCount = exportContent ? exportContent.split(`
|
|
55377
|
+
`).filter(Boolean).length : 0;
|
|
55378
|
+
return {
|
|
55379
|
+
imported: importResult,
|
|
55380
|
+
exported: exportedCount
|
|
55381
|
+
};
|
|
55382
|
+
}
|
|
55214
55383
|
|
|
55215
55384
|
// src/index.ts
|
|
55216
55385
|
var SWARM_MAIL_VERSION = "0.1.0";
|
|
@@ -55220,9 +55389,11 @@ export {
|
|
|
55220
55389
|
withTiming,
|
|
55221
55390
|
withTimeout,
|
|
55222
55391
|
updateProjections,
|
|
55392
|
+
syncMemories,
|
|
55223
55393
|
stopDaemon,
|
|
55224
55394
|
startDaemon,
|
|
55225
55395
|
serializeToJSONL,
|
|
55396
|
+
serializeMemoryToJSONL,
|
|
55226
55397
|
sendSwarmMessage,
|
|
55227
55398
|
sendMessage,
|
|
55228
55399
|
sendAgentMessage,
|
|
@@ -55245,6 +55416,7 @@ export {
|
|
|
55245
55416
|
readCellEvents,
|
|
55246
55417
|
readAgentMessage,
|
|
55247
55418
|
queryCells,
|
|
55419
|
+
parseMemoryJSONL,
|
|
55248
55420
|
parseJSONL,
|
|
55249
55421
|
migrations,
|
|
55250
55422
|
migrateLegacyMemories,
|
|
@@ -55266,6 +55438,7 @@ export {
|
|
|
55266
55438
|
inspectState,
|
|
55267
55439
|
initSwarmAgent,
|
|
55268
55440
|
initAgent,
|
|
55441
|
+
importMemories,
|
|
55269
55442
|
importFromJSONL,
|
|
55270
55443
|
hiveMigrations,
|
|
55271
55444
|
healthCheck,
|
|
@@ -55311,6 +55484,7 @@ export {
|
|
|
55311
55484
|
getAgent,
|
|
55312
55485
|
getActiveReservations,
|
|
55313
55486
|
exportToJSONL,
|
|
55487
|
+
exportMemories,
|
|
55314
55488
|
exportDirtyBeads,
|
|
55315
55489
|
debugReservations,
|
|
55316
55490
|
debugMessage,
|
package/dist/memory/adapter.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export interface StoreOptions {
|
|
|
54
54
|
readonly tags?: string;
|
|
55
55
|
/** JSON string with additional metadata */
|
|
56
56
|
readonly metadata?: string;
|
|
57
|
+
/** Confidence level (0.0-1.0) affecting decay rate. Higher = slower decay. Default 0.7 */
|
|
58
|
+
readonly confidence?: number;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Options for searching memories
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/memory/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAqB,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAMxE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,QAA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AC;CACzB;AAMD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY;IAqFzE;;;;;;;OAOG;uBAEY,MAAM,YACV,YAAY,GACpB,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IA2C1B;;;;;;OAMG;gBACe,MAAM,YAAW,WAAW,GAAQ,OAAO,CAAC,YAAY,EAAE,CAAC;IA0C7E;;;;;OAKG;YACW,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI7C;;;;OAIG;eACc,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;;;;;;;OAQG;iBACgB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAczC;;;;;OAKG;mBACiB;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;IAIpE;;;;OAIG;aACY,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAIhE;;;;OAIG;mBACkB,OAAO,CAAC,YAAY,CAAC;EAiB7C"}
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export { getDefaultConfig, makeOllamaLive, Ollama, OllamaError, } from "./ollama
|
|
|
8
8
|
export { createMemoryStore, EMBEDDING_DIM } from "./store.js";
|
|
9
9
|
export { memoryMigration, memoryMigrations } from "./migrations.js";
|
|
10
10
|
export { getDefaultLegacyPath, getMigrationStatus, legacyDatabaseExists, migrateLegacyMemories, type MigrationOptions, type MigrationResult, } from "./migrate-legacy.js";
|
|
11
|
+
export { exportMemories, importMemories, syncMemories, parseMemoryJSONL, serializeMemoryToJSONL, type ExportOptions as MemoryExportOptions, type ImportOptions as MemoryImportOptions, type MemoryExport, type MemoryImportResult, } from "./sync.js";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,WAAW,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACpB,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,WAAW,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACN,cAAc,EACd,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,aAAa,IAAI,mBAAmB,EACzC,KAAK,aAAa,IAAI,mBAAmB,EACzC,KAAK,YAAY,EACjB,KAAK,kBAAkB,GACvB,MAAM,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/memory/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/memory/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,SAkD7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,EAAsB,CAAC"}
|
package/dist/memory/store.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export interface Memory {
|
|
|
34
34
|
readonly metadata: Record<string, unknown>;
|
|
35
35
|
readonly collection: string;
|
|
36
36
|
readonly createdAt: Date;
|
|
37
|
+
/** Confidence level (0.0-1.0) affecting decay rate. Higher = slower decay. Default 0.7 */
|
|
38
|
+
readonly confidence?: number;
|
|
37
39
|
}
|
|
38
40
|
/** Search result with similarity score */
|
|
39
41
|
export interface SearchResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/memory/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,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C,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,eAAe;IAcjD;;;;;;;;;OASG;kBACiB,MAAM,aAAa,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuC/D;;;;;;;;;OASG;2BAEe,MAAM,EAAE,YACf,aAAa,GACrB,OAAO,CAAC,YAAY,EAAE,CAAC;IAmD1B;;;;;;;;;OASG;2BAEY,MAAM,YACV,aAAa,GACrB,OAAO,CAAC,YAAY,EAAE,CAAC;IAqC1B;;;;;OAKG;sBACqB,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAelD;;;;;OAKG;YACW,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQ7C;;;;;;OAMG;eACc,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC;;;;OAIG;gBACe,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;EActE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Sync - JSONL Export/Import for Git Sync
|
|
3
|
+
*
|
|
4
|
+
* Implements git-synced memory persistence, similar to how hive syncs issues.jsonl.
|
|
5
|
+
* Memories travel with the repo so team members share learnings.
|
|
6
|
+
*
|
|
7
|
+
* ## Architecture
|
|
8
|
+
* ```
|
|
9
|
+
* .hive/
|
|
10
|
+
* issues.jsonl # existing
|
|
11
|
+
* memories.jsonl # NEW
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ## JSONL Format
|
|
15
|
+
* ```json
|
|
16
|
+
* {"id":"mem_abc123","information":"OAuth tokens need 5min buffer...","metadata":"auth,tokens","tags":"oauth,refresh","confidence":0.9,"created_at":"2024-12-19T00:00:00Z"}
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Note: Embeddings are NOT stored (too large). Regenerated on import if Ollama available.
|
|
20
|
+
*
|
|
21
|
+
* @module memory/sync
|
|
22
|
+
*/
|
|
23
|
+
import type { DatabaseAdapter } from "../types/database.js";
|
|
24
|
+
/**
|
|
25
|
+
* JSONL export format for memories
|
|
26
|
+
*
|
|
27
|
+
* Embeddings are NOT included - they're too large and can be regenerated.
|
|
28
|
+
*/
|
|
29
|
+
export interface MemoryExport {
|
|
30
|
+
id: string;
|
|
31
|
+
information: string;
|
|
32
|
+
metadata?: string;
|
|
33
|
+
tags?: string;
|
|
34
|
+
confidence?: number;
|
|
35
|
+
created_at: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ExportOptions {
|
|
38
|
+
/** Filter by collection */
|
|
39
|
+
collection?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ImportOptions {
|
|
42
|
+
/** Skip existing memories (default: true) */
|
|
43
|
+
skipExisting?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface MemoryImportResult {
|
|
46
|
+
created: number;
|
|
47
|
+
skipped: number;
|
|
48
|
+
errors: Array<{
|
|
49
|
+
memoryId: string;
|
|
50
|
+
error: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Serialize a memory to a JSONL line
|
|
55
|
+
*/
|
|
56
|
+
export declare function serializeMemoryToJSONL(memory: MemoryExport): string;
|
|
57
|
+
/**
|
|
58
|
+
* Parse JSONL string to memory exports
|
|
59
|
+
*
|
|
60
|
+
* Skips empty lines. Throws on invalid JSON.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseMemoryJSONL(jsonl: string): MemoryExport[];
|
|
63
|
+
/**
|
|
64
|
+
* Export all memories to JSONL string
|
|
65
|
+
*
|
|
66
|
+
* Embeddings are NOT included - they're too large for git sync.
|
|
67
|
+
* They can be regenerated on import if Ollama is available.
|
|
68
|
+
*/
|
|
69
|
+
export declare function exportMemories(db: DatabaseAdapter, options?: ExportOptions): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Import memories from JSONL string
|
|
72
|
+
*
|
|
73
|
+
* Features:
|
|
74
|
+
* - Creates new memories
|
|
75
|
+
* - Skips existing memories (by ID)
|
|
76
|
+
* - Embeddings NOT imported (regenerate with Ollama if needed)
|
|
77
|
+
*/
|
|
78
|
+
export declare function importMemories(db: DatabaseAdapter, jsonl: string, options?: ImportOptions): Promise<MemoryImportResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Bidirectional sync between database and .hive/memories.jsonl
|
|
81
|
+
*
|
|
82
|
+
* 1. Import from file (new memories only)
|
|
83
|
+
* 2. Export all to file (overwrites)
|
|
84
|
+
*
|
|
85
|
+
* This ensures:
|
|
86
|
+
* - Memories from git are imported
|
|
87
|
+
* - Local memories are exported for git commit
|
|
88
|
+
*/
|
|
89
|
+
export declare function syncMemories(db: DatabaseAdapter, hivePath: string): Promise<{
|
|
90
|
+
imported: MemoryImportResult;
|
|
91
|
+
exported: number;
|
|
92
|
+
}>;
|
|
93
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/memory/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAM5D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,M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