@hasna/mementos 0.14.69 → 0.14.70
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 +155 -73
- package/dist/cli/commands/storage.d.ts.map +1 -1
- package/dist/cli/commands/system-mcp.d.ts.map +1 -1
- package/dist/cli/commands/system-profile.d.ts.map +1 -1
- package/dist/cli/index.js +200 -63
- package/dist/db/__fixtures__/fail-closed-stub-server.d.ts.map +1 -1
- package/dist/db/agents.d.ts.map +1 -1
- package/dist/db/database.d.ts +16 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/db/migrations.d.ts +1 -0
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/pg-migrations.d.ts.map +1 -1
- package/dist/index.js +116 -42
- package/dist/lib/auto-memory-queue.d.ts +2 -0
- package/dist/lib/auto-memory-queue.d.ts.map +1 -1
- package/dist/lib/auto-memory.d.ts +1 -0
- package/dist/lib/auto-memory.d.ts.map +1 -1
- package/dist/lib/built-in-hooks.d.ts.map +1 -1
- package/dist/lib/gdpr.d.ts.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +154 -48
- package/dist/mcp/tools/system-tools-memory-admin.d.ts.map +1 -1
- package/dist/server/index.js +119 -42
- package/dist/storage.d.ts +11 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +42 -11
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -65,6 +65,27 @@ var __export = (target, all) => {
|
|
|
65
65
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
66
66
|
var __require = import.meta.require;
|
|
67
67
|
|
|
68
|
+
// src/generated/storage-kit/mode.ts
|
|
69
|
+
function normalizeStorageMode(value) {
|
|
70
|
+
const normalized = value.trim().toLowerCase().replace(/-/g, "_");
|
|
71
|
+
if (normalized === "local")
|
|
72
|
+
return { mode: "local", deprecatedAlias: null };
|
|
73
|
+
if (normalized === "cloud")
|
|
74
|
+
return { mode: "cloud", deprecatedAlias: null };
|
|
75
|
+
if (DEPRECATED_STORAGE_MODE_ALIASES.includes(normalized)) {
|
|
76
|
+
return { mode: "cloud", deprecatedAlias: normalized };
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Unknown storage mode: ${value}. Use local or cloud.`);
|
|
79
|
+
}
|
|
80
|
+
var DEPRECATED_STORAGE_MODE_ALIASES;
|
|
81
|
+
var init_mode = __esm(() => {
|
|
82
|
+
DEPRECATED_STORAGE_MODE_ALIASES = [
|
|
83
|
+
"remote",
|
|
84
|
+
"hybrid",
|
|
85
|
+
"self_hosted"
|
|
86
|
+
];
|
|
87
|
+
});
|
|
88
|
+
|
|
68
89
|
// src/storage.ts
|
|
69
90
|
import { Database } from "bun:sqlite";
|
|
70
91
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -281,18 +302,20 @@ function warnDeprecatedStorageMode(alias) {
|
|
|
281
302
|
warnedDeprecatedModes.add(alias);
|
|
282
303
|
process.emitWarning(`${MEMENTOS_STORAGE_ENV.mode}="${alias}" is deprecated; use "cloud". ` + `"${alias}" now maps to pure-remote cloud storage. The local<->remote ` + `sync path is deprecated and is not the fleet cutover path.`, { type: "DeprecationWarning", code: "MEMENTOS_STORAGE_MODE_ALIAS" });
|
|
283
304
|
}
|
|
284
|
-
function
|
|
285
|
-
if (!value)
|
|
305
|
+
function normalizeStorageMode2(value, source) {
|
|
306
|
+
if (!value || !value.trim())
|
|
286
307
|
return null;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
308
|
+
let normalized;
|
|
309
|
+
try {
|
|
310
|
+
normalized = normalizeStorageMode(value);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
313
|
+
throw new Error(`mementos: ${source}=${value} is not a valid mode. ${detail}`);
|
|
290
314
|
}
|
|
291
|
-
if (normalized
|
|
292
|
-
warnDeprecatedStorageMode(normalized);
|
|
293
|
-
return "cloud";
|
|
315
|
+
if (normalized.deprecatedAlias) {
|
|
316
|
+
warnDeprecatedStorageMode(normalized.deprecatedAlias);
|
|
294
317
|
}
|
|
295
|
-
return
|
|
318
|
+
return normalized.mode;
|
|
296
319
|
}
|
|
297
320
|
function readConfigFile() {
|
|
298
321
|
if (!existsSync2(STORAGE_CONFIG_PATH)) {
|
|
@@ -317,7 +340,7 @@ function getStorageDatabaseUrl() {
|
|
|
317
340
|
}
|
|
318
341
|
function getStorageModeOverride() {
|
|
319
342
|
for (const env of MODE_ENV_NAMES) {
|
|
320
|
-
const value =
|
|
343
|
+
const value = normalizeStorageMode2(readEnv(env.name) ?? undefined, env.name);
|
|
321
344
|
if (value)
|
|
322
345
|
return value;
|
|
323
346
|
}
|
|
@@ -327,7 +350,7 @@ function getStorageConfig() {
|
|
|
327
350
|
const fileConfig = readConfigFile();
|
|
328
351
|
const modeOverride = getStorageModeOverride();
|
|
329
352
|
const envConnectionString = getConfiguredConnectionString();
|
|
330
|
-
const fileMode =
|
|
353
|
+
const fileMode = normalizeStorageMode2(fileConfig.mode, `${STORAGE_CONFIG_PATH} "mode"`);
|
|
331
354
|
const merged = {
|
|
332
355
|
...DEFAULT_STORAGE_CONFIG,
|
|
333
356
|
...fileConfig,
|
|
@@ -449,6 +472,7 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
449
472
|
}
|
|
450
473
|
var _serverContext = false, PgSyncPool, MEMENTOS_STORAGE_ENV, MEMENTOS_STORAGE_FALLBACK_ENV, LOCAL_DATA_DIR, DEFAULT_STORAGE_CONFIG, STORAGE_CONFIG_DIR, STORAGE_CONFIG_PATH, DATABASE_ENV_NAMES, MODE_ENV_NAMES, warnedDeprecatedModes, SECRET_QUERY_PARAMS;
|
|
451
474
|
var init_storage = __esm(() => {
|
|
475
|
+
init_mode();
|
|
452
476
|
PgSyncPool = class PgSyncPool {
|
|
453
477
|
worker;
|
|
454
478
|
status;
|
|
@@ -777,7 +801,24 @@ var init_api_mode = __esm(() => {
|
|
|
777
801
|
});
|
|
778
802
|
|
|
779
803
|
// src/db/migrations.ts
|
|
780
|
-
var
|
|
804
|
+
var MEMORY_VERSION_SNAPSHOT_TRIGGER = `
|
|
805
|
+
CREATE TRIGGER IF NOT EXISTS memories_version_snapshot
|
|
806
|
+
BEFORE UPDATE ON memories
|
|
807
|
+
WHEN NEW.version > OLD.version
|
|
808
|
+
BEGIN
|
|
809
|
+
INSERT OR IGNORE INTO memory_versions (
|
|
810
|
+
id, memory_id, version, value, importance, scope, category, tags,
|
|
811
|
+
summary, pinned, status, when_to_use, created_at
|
|
812
|
+
) VALUES (
|
|
813
|
+
lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-' ||
|
|
814
|
+
lower(hex(randomblob(2))) || '-' || lower(hex(randomblob(2))) || '-' ||
|
|
815
|
+
lower(hex(randomblob(6))),
|
|
816
|
+
OLD.id, OLD.version, OLD.value, OLD.importance, OLD.scope, OLD.category,
|
|
817
|
+
OLD.tags, OLD.summary, OLD.pinned, OLD.status, OLD.when_to_use,
|
|
818
|
+
OLD.updated_at
|
|
819
|
+
);
|
|
820
|
+
END;
|
|
821
|
+
`, MIGRATIONS;
|
|
781
822
|
var init_migrations = __esm(() => {
|
|
782
823
|
MIGRATIONS = [
|
|
783
824
|
`
|
|
@@ -1675,6 +1716,10 @@ CREATE INDEX IF NOT EXISTS idx_memory_reflection_lessons_memory ON memory_reflec
|
|
|
1675
1716
|
CREATE INDEX IF NOT EXISTS idx_memory_reflection_lessons_kind ON memory_reflection_lessons(kind);
|
|
1676
1717
|
|
|
1677
1718
|
INSERT OR IGNORE INTO _migrations (id) VALUES (35);
|
|
1719
|
+
`,
|
|
1720
|
+
`
|
|
1721
|
+
${MEMORY_VERSION_SNAPSHOT_TRIGGER}
|
|
1722
|
+
INSERT OR IGNORE INTO _migrations (id) VALUES (36);
|
|
1678
1723
|
`
|
|
1679
1724
|
];
|
|
1680
1725
|
});
|
|
@@ -1689,6 +1734,7 @@ __export(exports_database, {
|
|
|
1689
1734
|
now: () => now,
|
|
1690
1735
|
getDbPath: () => getDbPath2,
|
|
1691
1736
|
getDatabase: () => getDatabase,
|
|
1737
|
+
escapeLikePrefix: () => escapeLikePrefix,
|
|
1692
1738
|
closeDatabase: () => closeDatabase
|
|
1693
1739
|
});
|
|
1694
1740
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, cpSync as cpSync2 } from "fs";
|
|
@@ -1863,15 +1909,20 @@ function uuid() {
|
|
|
1863
1909
|
function shortUuid() {
|
|
1864
1910
|
return crypto.randomUUID().slice(0, 8);
|
|
1865
1911
|
}
|
|
1912
|
+
function escapeLikePrefix(s) {
|
|
1913
|
+
return s.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
|
|
1914
|
+
}
|
|
1866
1915
|
function resolvePartialId(db, table, partialId) {
|
|
1867
1916
|
if (!ALLOWED_TABLES.has(table)) {
|
|
1868
1917
|
throw new Error(`Invalid table name: ${table}`);
|
|
1869
1918
|
}
|
|
1919
|
+
if (partialId === "")
|
|
1920
|
+
return null;
|
|
1870
1921
|
if (partialId.length >= 36) {
|
|
1871
1922
|
const row = db.query(`SELECT id FROM ${table} WHERE id = ?`).get(partialId);
|
|
1872
1923
|
return row?.id ?? null;
|
|
1873
1924
|
}
|
|
1874
|
-
const rows = db.query(`SELECT id FROM ${table} WHERE id LIKE
|
|
1925
|
+
const rows = db.query(`SELECT id FROM ${table} WHERE id LIKE ? ESCAPE '\\'`).all(`${escapeLikePrefix(partialId)}%`);
|
|
1875
1926
|
if (rows.length === 1) {
|
|
1876
1927
|
return rows[0].id;
|
|
1877
1928
|
}
|
|
@@ -3000,33 +3051,19 @@ function updateMemory(id, input, db) {
|
|
|
3000
3051
|
const { status, data } = apiJson("PATCH", `/memories/${encodeURIComponent(id)}`, input, { allow404: true });
|
|
3001
3052
|
if (status === 404)
|
|
3002
3053
|
throw new MemoryNotFoundError(id);
|
|
3054
|
+
if (data && typeof input.version === "number" && typeof data.version === "number" && data.version <= input.version) {
|
|
3055
|
+
throw new Error(`Update did not persist for memory ${id}: the server returned success but the record is unchanged ` + `(version still ${data.version}). Your data was NOT written. ` + `The server is likely running a build predating the partial-id fix \u2014 pass the full 36-character id as a workaround.`);
|
|
3056
|
+
}
|
|
3003
3057
|
return data;
|
|
3004
3058
|
}
|
|
3005
3059
|
const d = db || getDatabase();
|
|
3006
3060
|
const existing = getMemory(id, d);
|
|
3007
3061
|
if (!existing)
|
|
3008
3062
|
throw new MemoryNotFoundError(id);
|
|
3063
|
+
const memoryId = existing.id;
|
|
3009
3064
|
if (existing.version !== input.version) {
|
|
3010
3065
|
throw new VersionConflictError(id, input.version, existing.version);
|
|
3011
3066
|
}
|
|
3012
|
-
try {
|
|
3013
|
-
d.run(`INSERT OR IGNORE INTO memory_versions (id, memory_id, version, value, importance, scope, category, tags, summary, pinned, status, when_to_use, created_at)
|
|
3014
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
3015
|
-
uuid(),
|
|
3016
|
-
existing.id,
|
|
3017
|
-
existing.version,
|
|
3018
|
-
existing.value,
|
|
3019
|
-
existing.importance,
|
|
3020
|
-
existing.scope,
|
|
3021
|
-
existing.category,
|
|
3022
|
-
JSON.stringify(existing.tags),
|
|
3023
|
-
existing.summary,
|
|
3024
|
-
existing.pinned ? 1 : 0,
|
|
3025
|
-
existing.status,
|
|
3026
|
-
existing.when_to_use || null,
|
|
3027
|
-
existing.updated_at
|
|
3028
|
-
]);
|
|
3029
|
-
} catch {}
|
|
3030
3067
|
const sets = ["version = version + 1", "updated_at = ?"];
|
|
3031
3068
|
const params = [now()];
|
|
3032
3069
|
if (input.value !== undefined) {
|
|
@@ -3076,15 +3113,18 @@ function updateMemory(id, input, db) {
|
|
|
3076
3113
|
if (input.tags !== undefined) {
|
|
3077
3114
|
sets.push("tags = ?");
|
|
3078
3115
|
params.push(JSON.stringify(input.tags));
|
|
3079
|
-
d.run("DELETE FROM memory_tags WHERE memory_id = ?", [
|
|
3116
|
+
d.run("DELETE FROM memory_tags WHERE memory_id = ?", [memoryId]);
|
|
3080
3117
|
const insertTag = d.prepare("INSERT OR IGNORE INTO memory_tags (memory_id, tag) VALUES (?, ?)");
|
|
3081
3118
|
for (const tag of input.tags) {
|
|
3082
|
-
insertTag.run(
|
|
3119
|
+
insertTag.run(memoryId, tag);
|
|
3083
3120
|
}
|
|
3084
3121
|
}
|
|
3085
|
-
params.push(
|
|
3086
|
-
d.run(`UPDATE memories SET ${sets.join(", ")} WHERE id = ?`, params);
|
|
3087
|
-
|
|
3122
|
+
params.push(memoryId);
|
|
3123
|
+
const result = d.run(`UPDATE memories SET ${sets.join(", ")} WHERE id = ?`, params);
|
|
3124
|
+
if (result.changes === 0) {
|
|
3125
|
+
throw new Error(`Update affected no rows for memory ${memoryId}: the record was read but not written. ` + `This is a bug in @hasna/mementos, not a bad argument \u2014 please report it.`);
|
|
3126
|
+
}
|
|
3127
|
+
const updated = getMemory(memoryId, d);
|
|
3088
3128
|
if (input.value !== undefined) {
|
|
3089
3129
|
try {
|
|
3090
3130
|
const oldLinks = getEntityMemoryLinks(undefined, updated.id, d);
|
|
@@ -3109,10 +3149,11 @@ function deleteMemory(id, db) {
|
|
|
3109
3149
|
return status !== 404;
|
|
3110
3150
|
}
|
|
3111
3151
|
const d = db || getDatabase();
|
|
3112
|
-
const
|
|
3152
|
+
const memoryId = resolvePartialId(d, "memories", id) ?? id;
|
|
3153
|
+
const result = d.run("DELETE FROM memories WHERE id = ?", [memoryId]);
|
|
3113
3154
|
if (result.changes > 0) {
|
|
3114
3155
|
hookRegistry.runHooks("PostMemoryDelete", {
|
|
3115
|
-
memoryId
|
|
3156
|
+
memoryId,
|
|
3116
3157
|
timestamp: Date.now()
|
|
3117
3158
|
});
|
|
3118
3159
|
}
|
|
@@ -3126,11 +3167,12 @@ function bulkDeleteMemories(ids, db) {
|
|
|
3126
3167
|
return data?.deleted ?? 0;
|
|
3127
3168
|
}
|
|
3128
3169
|
const d = db || getDatabase();
|
|
3129
|
-
const
|
|
3130
|
-
const
|
|
3170
|
+
const resolvedIds = ids.map((id) => resolvePartialId(d, "memories", id) ?? id);
|
|
3171
|
+
const placeholders = resolvedIds.map(() => "?").join(",");
|
|
3172
|
+
const countRow = d.query(`SELECT COUNT(*) as c FROM memories WHERE id IN (${placeholders})`).get(...resolvedIds);
|
|
3131
3173
|
const count = countRow.c;
|
|
3132
3174
|
if (count > 0) {
|
|
3133
|
-
d.run(`DELETE FROM memories WHERE id IN (${placeholders})`,
|
|
3175
|
+
d.run(`DELETE FROM memories WHERE id IN (${placeholders})`, resolvedIds);
|
|
3134
3176
|
}
|
|
3135
3177
|
return count;
|
|
3136
3178
|
}
|
|
@@ -5064,6 +5106,32 @@ class AutoMemoryQueue {
|
|
|
5064
5106
|
getStats() {
|
|
5065
5107
|
return { ...this.stats, pending: this.queue.length };
|
|
5066
5108
|
}
|
|
5109
|
+
async waitForIdleForTests(timeoutMs = 3000) {
|
|
5110
|
+
const start = Date.now();
|
|
5111
|
+
while (Date.now() - start < timeoutMs) {
|
|
5112
|
+
if (this.queue.length === 0 && this.activeCount === 0)
|
|
5113
|
+
return;
|
|
5114
|
+
await new Promise((r) => setTimeout(r, 20));
|
|
5115
|
+
}
|
|
5116
|
+
throw new Error("autoMemoryQueue did not become idle before test reset");
|
|
5117
|
+
}
|
|
5118
|
+
resetForTests(handler) {
|
|
5119
|
+
if (this.activeCount !== 0) {
|
|
5120
|
+
throw new Error("Cannot reset autoMemoryQueue while jobs are processing");
|
|
5121
|
+
}
|
|
5122
|
+
this.queue = [];
|
|
5123
|
+
this.running = false;
|
|
5124
|
+
this.stats = {
|
|
5125
|
+
pending: 0,
|
|
5126
|
+
processing: 0,
|
|
5127
|
+
processed: 0,
|
|
5128
|
+
failed: 0,
|
|
5129
|
+
dropped: 0
|
|
5130
|
+
};
|
|
5131
|
+
if (handler !== undefined) {
|
|
5132
|
+
this.handler = handler;
|
|
5133
|
+
}
|
|
5134
|
+
}
|
|
5067
5135
|
startLoop() {
|
|
5068
5136
|
this.running = true;
|
|
5069
5137
|
this.loop();
|
|
@@ -5109,6 +5177,7 @@ var init_auto_memory_queue = __esm(() => {
|
|
|
5109
5177
|
// src/lib/auto-memory.ts
|
|
5110
5178
|
var exports_auto_memory = {};
|
|
5111
5179
|
__export(exports_auto_memory, {
|
|
5180
|
+
resetAutoMemoryForTests: () => resetAutoMemoryForTests,
|
|
5112
5181
|
processConversationTurn: () => processConversationTurn,
|
|
5113
5182
|
getAutoMemoryStats: () => getAutoMemoryStats,
|
|
5114
5183
|
configureAutoMemory: () => configureAutoMemory
|
|
@@ -5269,6 +5338,12 @@ function getAutoMemoryStats() {
|
|
|
5269
5338
|
function configureAutoMemory(config) {
|
|
5270
5339
|
providerRegistry.configure(config);
|
|
5271
5340
|
}
|
|
5341
|
+
async function resetAutoMemoryForTests() {
|
|
5342
|
+
if (autoMemoryQueue.getStats().processing > 0) {
|
|
5343
|
+
await autoMemoryQueue.waitForIdleForTests();
|
|
5344
|
+
}
|
|
5345
|
+
autoMemoryQueue.resetForTests(processJob);
|
|
5346
|
+
}
|
|
5272
5347
|
var DEDUP_SIMILARITY_THRESHOLD = 0.85;
|
|
5273
5348
|
var init_auto_memory = __esm(() => {
|
|
5274
5349
|
init_memories();
|
|
@@ -53041,6 +53116,8 @@ hookRegistry.register({
|
|
|
53041
53116
|
priority: 100,
|
|
53042
53117
|
description: "Trigger async LLM entity extraction when a memory is saved",
|
|
53043
53118
|
handler: async (ctx) => {
|
|
53119
|
+
if (process.env["NODE_ENV"] === "test")
|
|
53120
|
+
return;
|
|
53044
53121
|
if (ctx.wasUpdated)
|
|
53045
53122
|
return;
|
|
53046
53123
|
const processConversationTurn2 = await getAutoMemory();
|
|
@@ -56147,7 +56224,7 @@ function getAgent(idOrName, db) {
|
|
|
56147
56224
|
row = d.query("SELECT * FROM agents WHERE LOWER(name) = ?").get(idOrName.trim().toLowerCase());
|
|
56148
56225
|
if (row)
|
|
56149
56226
|
return parseAgentRow(row);
|
|
56150
|
-
const rows = d.query("SELECT * FROM agents WHERE id LIKE ?").all(`${idOrName}%`);
|
|
56227
|
+
const rows = d.query("SELECT * FROM agents WHERE id LIKE ? ESCAPE '\\'").all(`${escapeLikePrefix(idOrName)}%`);
|
|
56151
56228
|
if (rows.length === 1)
|
|
56152
56229
|
return parseAgentRow(rows[0]);
|
|
56153
56230
|
return null;
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Database } from "bun:sqlite";
|
|
2
2
|
import type { Pool, PoolClient } from "pg";
|
|
3
|
+
import { DEPRECATED_STORAGE_MODE_ALIASES } from "./generated/storage-kit/mode.js";
|
|
3
4
|
/** Called once by the mementos-serve entrypoint; enables the server-only DSN path. */
|
|
4
5
|
export declare function markServerContext(): void;
|
|
6
|
+
export declare function resetServerContextForTests(): void;
|
|
5
7
|
/** True only inside the `mementos-serve` server process. */
|
|
6
8
|
export declare function isServerContext(): boolean;
|
|
7
9
|
export interface RunResult {
|
|
@@ -114,8 +116,15 @@ export declare class PgAdapterAsync {
|
|
|
114
116
|
* back-compat and is explicitly NOT the fleet cutover path.
|
|
115
117
|
*/
|
|
116
118
|
export type StorageMode = "local" | "cloud";
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Deprecated storage-mode aliases accepted as input; all map to `cloud`.
|
|
121
|
+
*
|
|
122
|
+
* DERIVED from the vendored contract, never restated. A hand-written copy of
|
|
123
|
+
* this list is exactly what let `self_hosted` — an alias the contract accepts —
|
|
124
|
+
* fall through mementos' private normalizer as "unrecognised" and silently
|
|
125
|
+
* resolve to `local`.
|
|
126
|
+
*/
|
|
127
|
+
export type DeprecatedStorageMode = (typeof DEPRECATED_STORAGE_MODE_ALIASES)[number];
|
|
119
128
|
/** Any value accepted from env/config for the storage mode. */
|
|
120
129
|
export type StorageModeInput = StorageMode | DeprecatedStorageMode;
|
|
121
130
|
export declare const MEMENTOS_STORAGE_TABLES: readonly ["projects", "agents", "machines", "sessions", "entities", "memories", "relations", "entity_memories", "memory_tags", "memory_versions", "memory_embeddings", "tool_events", "resource_locks", "memory_ratings"];
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EACL,+BAA+B,EAEhC,MAAM,iCAAiC,CAAC;AAiBzC,sFAAsF;AACtF,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAKjD;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IACjC,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC3B,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC7B,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC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AAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AA2ED,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,EAAE,CAKxD;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAEjF;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAGpD"}
|
package/dist/storage.js
CHANGED
|
@@ -46,6 +46,27 @@ var __export = (target, all) => {
|
|
|
46
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
47
|
var __require = import.meta.require;
|
|
48
48
|
|
|
49
|
+
// src/generated/storage-kit/mode.ts
|
|
50
|
+
function normalizeStorageMode(value) {
|
|
51
|
+
const normalized = value.trim().toLowerCase().replace(/-/g, "_");
|
|
52
|
+
if (normalized === "local")
|
|
53
|
+
return { mode: "local", deprecatedAlias: null };
|
|
54
|
+
if (normalized === "cloud")
|
|
55
|
+
return { mode: "cloud", deprecatedAlias: null };
|
|
56
|
+
if (DEPRECATED_STORAGE_MODE_ALIASES.includes(normalized)) {
|
|
57
|
+
return { mode: "cloud", deprecatedAlias: normalized };
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`Unknown storage mode: ${value}. Use local or cloud.`);
|
|
60
|
+
}
|
|
61
|
+
var DEPRECATED_STORAGE_MODE_ALIASES;
|
|
62
|
+
var init_mode = __esm(() => {
|
|
63
|
+
DEPRECATED_STORAGE_MODE_ALIASES = [
|
|
64
|
+
"remote",
|
|
65
|
+
"hybrid",
|
|
66
|
+
"self_hosted"
|
|
67
|
+
];
|
|
68
|
+
});
|
|
69
|
+
|
|
49
70
|
// src/storage.ts
|
|
50
71
|
import { Database } from "bun:sqlite";
|
|
51
72
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -57,6 +78,12 @@ import pg from "pg";
|
|
|
57
78
|
function markServerContext() {
|
|
58
79
|
_serverContext = true;
|
|
59
80
|
}
|
|
81
|
+
function resetServerContextForTests() {
|
|
82
|
+
if (process.env["NODE_ENV"] !== "test") {
|
|
83
|
+
throw new Error("resetServerContextForTests is only available under NODE_ENV=test");
|
|
84
|
+
}
|
|
85
|
+
_serverContext = false;
|
|
86
|
+
}
|
|
60
87
|
function isServerContext() {
|
|
61
88
|
return _serverContext;
|
|
62
89
|
}
|
|
@@ -307,18 +334,20 @@ function warnDeprecatedStorageMode(alias) {
|
|
|
307
334
|
warnedDeprecatedModes.add(alias);
|
|
308
335
|
process.emitWarning(`${MEMENTOS_STORAGE_ENV.mode}="${alias}" is deprecated; use "cloud". ` + `"${alias}" now maps to pure-remote cloud storage. The local<->remote ` + `sync path is deprecated and is not the fleet cutover path.`, { type: "DeprecationWarning", code: "MEMENTOS_STORAGE_MODE_ALIAS" });
|
|
309
336
|
}
|
|
310
|
-
function
|
|
311
|
-
if (!value)
|
|
337
|
+
function normalizeStorageMode2(value, source) {
|
|
338
|
+
if (!value || !value.trim())
|
|
312
339
|
return null;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
340
|
+
let normalized;
|
|
341
|
+
try {
|
|
342
|
+
normalized = normalizeStorageMode(value);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
345
|
+
throw new Error(`mementos: ${source}=${value} is not a valid mode. ${detail}`);
|
|
316
346
|
}
|
|
317
|
-
if (normalized
|
|
318
|
-
warnDeprecatedStorageMode(normalized);
|
|
319
|
-
return "cloud";
|
|
347
|
+
if (normalized.deprecatedAlias) {
|
|
348
|
+
warnDeprecatedStorageMode(normalized.deprecatedAlias);
|
|
320
349
|
}
|
|
321
|
-
return
|
|
350
|
+
return normalized.mode;
|
|
322
351
|
}
|
|
323
352
|
function readConfigFile() {
|
|
324
353
|
if (!existsSync(STORAGE_CONFIG_PATH)) {
|
|
@@ -357,7 +386,7 @@ function getStorageDatabaseEnvName() {
|
|
|
357
386
|
}
|
|
358
387
|
function getStorageModeOverride() {
|
|
359
388
|
for (const env of MODE_ENV_NAMES) {
|
|
360
|
-
const value =
|
|
389
|
+
const value = normalizeStorageMode2(readEnv(env.name) ?? undefined, env.name);
|
|
361
390
|
if (value)
|
|
362
391
|
return value;
|
|
363
392
|
}
|
|
@@ -367,7 +396,7 @@ function getStorageConfig() {
|
|
|
367
396
|
const fileConfig = readConfigFile();
|
|
368
397
|
const modeOverride = getStorageModeOverride();
|
|
369
398
|
const envConnectionString = getConfiguredConnectionString();
|
|
370
|
-
const fileMode =
|
|
399
|
+
const fileMode = normalizeStorageMode2(fileConfig.mode, `${STORAGE_CONFIG_PATH} "mode"`);
|
|
371
400
|
const merged = {
|
|
372
401
|
...DEFAULT_STORAGE_CONFIG,
|
|
373
402
|
...fileConfig,
|
|
@@ -794,6 +823,7 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
|
794
823
|
direction TEXT DEFAULT 'push'
|
|
795
824
|
)`;
|
|
796
825
|
var init_storage = __esm(() => {
|
|
826
|
+
init_mode();
|
|
797
827
|
PgSyncPool = class PgSyncPool {
|
|
798
828
|
worker;
|
|
799
829
|
status;
|
|
@@ -940,6 +970,7 @@ export {
|
|
|
940
970
|
shouldUsePgSsl,
|
|
941
971
|
saveStorageConfig,
|
|
942
972
|
resetSyncMeta,
|
|
973
|
+
resetServerContextForTests,
|
|
943
974
|
resetAllSyncMeta,
|
|
944
975
|
redactDatabaseUrl,
|
|
945
976
|
markServerContext,
|