@hasna/mementos 0.14.82 → 0.14.84
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/Dockerfile.package +0 -1
- package/README.md +13 -10
- package/dashboard/bun.lock +519 -0
- package/dist/cli/commands/storage.d.ts.map +1 -1
- package/dist/cli/index.js +3459 -1447
- package/dist/db/api-mode.d.ts +5 -1
- package/dist/db/api-mode.d.ts.map +1 -1
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/store-backend.d.ts +3 -3
- package/dist/db/store-backend.d.ts.map +1 -1
- package/dist/generated/storage-kit/backend.d.ts +20 -0
- package/dist/generated/storage-kit/backend.d.ts.map +1 -0
- package/dist/generated/storage-kit/index.d.ts +2 -2
- package/dist/generated/storage-kit/index.d.ts.map +1 -1
- package/dist/generated/storage-kit/migrations.d.ts.map +1 -1
- package/dist/generated/storage-kit/own.d.ts +11 -0
- package/dist/generated/storage-kit/own.d.ts.map +1 -0
- package/dist/generated/storage-kit/pool.d.ts +7 -6
- package/dist/generated/storage-kit/pool.d.ts.map +1 -1
- package/dist/generated/storage-kit/tls.d.ts +30 -3
- package/dist/generated/storage-kit/tls.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3450 -1424
- package/dist/lib/retired-storage-mode.d.ts +11 -0
- package/dist/lib/retired-storage-mode.d.ts.map +1 -0
- package/dist/lib/storage-sync.d.ts +2 -2
- package/dist/lib/storage-sync.d.ts.map +1 -1
- package/dist/mcp/index.js +3416 -1423
- package/dist/mcp/tools/project-tools.d.ts.map +1 -1
- package/dist/project-registration/project-resources.d.ts.map +1 -1
- package/dist/project-registration.js +182 -132
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +24 -1
- package/dist/server/index.js +3390 -1379
- package/dist/storage.d.ts +18 -50
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +151 -122
- package/dist/test-support/store-isolation.d.ts +5 -0
- package/dist/test-support/store-isolation.d.ts.map +1 -1
- package/docker-entrypoint.sh +4 -5
- package/hasna.contract.json +2 -2
- package/package.json +5 -5
- package/dist/generated/storage-kit/mode.d.ts +0 -48
- package/dist/generated/storage-kit/mode.d.ts.map +0 -1
package/dist/storage.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Database } from "bun:sqlite";
|
|
2
2
|
import type { Pool, PoolClient } from "pg";
|
|
3
|
-
import {
|
|
3
|
+
import { type ServerDataBackend } from "./generated/storage-kit/backend.js";
|
|
4
4
|
/** Called once by the mementos-serve entrypoint; enables the server-only DSN path. */
|
|
5
5
|
export declare function markServerContext(): void;
|
|
6
6
|
export declare function resetServerContextForTests(): void;
|
|
@@ -84,7 +84,7 @@ export declare class PgAdapter implements DbAdapter {
|
|
|
84
84
|
/**
|
|
85
85
|
* Bun-sqlite-style `query()` shim so the CLI/MCP/server call sites that do
|
|
86
86
|
* `db.query(sql).get(...)` / `.all(...)` / `.run(...)` work unchanged against
|
|
87
|
-
* Postgres in
|
|
87
|
+
* Postgres in the postgresql backend. Behaves like {@link prepare}.
|
|
88
88
|
*/
|
|
89
89
|
query(sql: string): PreparedStatement;
|
|
90
90
|
close(): void;
|
|
@@ -103,40 +103,14 @@ export declare class PgAdapterAsync {
|
|
|
103
103
|
transaction<T>(fn: (client: PoolClient) => Promise<T>): Promise<T>;
|
|
104
104
|
get raw(): Pool;
|
|
105
105
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Canonical storage-mode axis (aligned with the shared cloud-runtime contract).
|
|
108
|
-
*
|
|
109
|
-
* - `local` — SQLite on disk. Default. Unchanged behavior.
|
|
110
|
-
* - `cloud` — pure remote: reads AND writes go directly to cloud Postgres.
|
|
111
|
-
*
|
|
112
|
-
* The legacy values `remote` and `hybrid` are still accepted as INPUT (env or
|
|
113
|
-
* config file) for backwards compatibility, but they are DEPRECATED aliases
|
|
114
|
-
* that normalize to `cloud`. See {@link DeprecatedStorageMode}. The historical
|
|
115
|
-
* local<->remote sync engine (the "hybrid sync path") is retained only for
|
|
116
|
-
* back-compat and is explicitly NOT the fleet cutover path.
|
|
117
|
-
*/
|
|
118
|
-
export type StorageMode = "local" | "cloud";
|
|
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];
|
|
128
|
-
/** Any value accepted from env/config for the storage mode. */
|
|
129
|
-
export type StorageModeInput = StorageMode | DeprecatedStorageMode;
|
|
130
106
|
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"];
|
|
131
107
|
export declare const STORAGE_TABLES: readonly ["projects", "agents", "machines", "sessions", "entities", "memories", "relations", "entity_memories", "memory_tags", "memory_versions", "memory_embeddings", "tool_events", "resource_locks", "memory_ratings"];
|
|
132
108
|
export type MementosStorageTable = (typeof MEMENTOS_STORAGE_TABLES)[number];
|
|
133
109
|
export declare const MEMENTOS_STORAGE_ENV: {
|
|
134
110
|
readonly databaseUrl: "HASNA_MEMENTOS_DATABASE_URL";
|
|
135
|
-
readonly mode: "HASNA_MEMENTOS_STORAGE_MODE";
|
|
136
111
|
};
|
|
137
112
|
export declare const MEMENTOS_STORAGE_FALLBACK_ENV: {
|
|
138
113
|
readonly databaseUrl: "MEMENTOS_DATABASE_URL";
|
|
139
|
-
readonly mode: "MEMENTOS_STORAGE_MODE";
|
|
140
114
|
};
|
|
141
115
|
export interface StorageConfig {
|
|
142
116
|
rds: {
|
|
@@ -146,7 +120,6 @@ export interface StorageConfig {
|
|
|
146
120
|
password_env: string;
|
|
147
121
|
ssl: boolean;
|
|
148
122
|
};
|
|
149
|
-
mode: StorageMode;
|
|
150
123
|
auto_sync_interval_minutes: number;
|
|
151
124
|
feedback_endpoint: string;
|
|
152
125
|
sync: {
|
|
@@ -162,9 +135,10 @@ export interface StorageEnvStatus {
|
|
|
162
135
|
active_name: string;
|
|
163
136
|
configured: boolean;
|
|
164
137
|
}
|
|
165
|
-
|
|
138
|
+
/** The server data backend, from the shared storage kit: `sqlite | postgresql`. */
|
|
139
|
+
export type StorageRuntimeKind = ServerDataBackend;
|
|
166
140
|
export interface StorageRuntimeContract {
|
|
167
|
-
contract: "mementos-
|
|
141
|
+
contract: "mementos-storage-runtime-v1";
|
|
168
142
|
kind: StorageRuntimeKind;
|
|
169
143
|
fail_closed: boolean;
|
|
170
144
|
local: {
|
|
@@ -177,9 +151,8 @@ export interface StorageRuntimeContract {
|
|
|
177
151
|
reason: string;
|
|
178
152
|
};
|
|
179
153
|
};
|
|
180
|
-
|
|
181
|
-
adapter: "postgres";
|
|
182
|
-
purpose: "primary-runtime";
|
|
154
|
+
backend: {
|
|
155
|
+
adapter: "sqlite" | "postgres";
|
|
183
156
|
requested: boolean;
|
|
184
157
|
configured: boolean;
|
|
185
158
|
source: "env" | "config-file" | "none";
|
|
@@ -189,17 +162,6 @@ export interface StorageRuntimeContract {
|
|
|
189
162
|
fail_closed: boolean;
|
|
190
163
|
missing: string[];
|
|
191
164
|
};
|
|
192
|
-
object_storage: {
|
|
193
|
-
s3: {
|
|
194
|
-
supported: false;
|
|
195
|
-
mutation_allowed: false;
|
|
196
|
-
reason: string;
|
|
197
|
-
};
|
|
198
|
-
aws: {
|
|
199
|
-
mutation_allowed: false;
|
|
200
|
-
reason: string;
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
165
|
migrations: {
|
|
204
166
|
target: "postgres-rds-compatible";
|
|
205
167
|
command: "mementos storage migrate";
|
|
@@ -210,7 +172,6 @@ export interface StorageRuntimeContract {
|
|
|
210
172
|
};
|
|
211
173
|
}
|
|
212
174
|
export interface SafeStorageConfigSummary {
|
|
213
|
-
mode: StorageMode;
|
|
214
175
|
auto_sync_interval_minutes: number;
|
|
215
176
|
feedback_endpoint_configured: boolean;
|
|
216
177
|
sync: StorageConfig["sync"];
|
|
@@ -226,9 +187,8 @@ export interface SafeStorageConfigSummary {
|
|
|
226
187
|
export interface NativeStorageStatus {
|
|
227
188
|
ok: boolean;
|
|
228
189
|
service: "mementos";
|
|
229
|
-
|
|
190
|
+
backend: StorageRuntimeKind;
|
|
230
191
|
local_default: boolean;
|
|
231
|
-
remote_enabled: boolean;
|
|
232
192
|
runtime: StorageRuntimeContract;
|
|
233
193
|
database: {
|
|
234
194
|
configured: boolean;
|
|
@@ -240,7 +200,6 @@ export interface NativeStorageStatus {
|
|
|
240
200
|
tables: readonly MementosStorageTable[];
|
|
241
201
|
env: {
|
|
242
202
|
databaseUrl: StorageEnvStatus;
|
|
243
|
-
mode: StorageEnvStatus;
|
|
244
203
|
};
|
|
245
204
|
issues: string[];
|
|
246
205
|
warnings: string[];
|
|
@@ -251,8 +210,17 @@ export declare function getConfigPath(): string;
|
|
|
251
210
|
export declare function getStorageDatabaseEnv(): StorageEnv | null;
|
|
252
211
|
export declare function getStorageDatabaseUrl(): string | null;
|
|
253
212
|
export declare function getStorageDatabaseEnvName(): string;
|
|
213
|
+
/**
|
|
214
|
+
* The server data backend selected by the environment: `postgresql` when
|
|
215
|
+
* HASNA_MEMENTOS_DATABASE_URL is set, `sqlite` otherwise. Runs the fail-loud
|
|
216
|
+
* ratchet first, so a retired storage-mode variable throws here rather than
|
|
217
|
+
* being silently ignored. Delegated to the vendored storage kit so the key
|
|
218
|
+
* spec and the ratchet cannot drift from the shared contract.
|
|
219
|
+
*/
|
|
220
|
+
export declare function getStorageBackend(env?: NodeJS.ProcessEnv): ServerDataBackend;
|
|
221
|
+
/** The database URL for the selected server backend, or `null` when sqlite. */
|
|
222
|
+
export declare function getStorageBackendDatabaseUrl(env?: NodeJS.ProcessEnv): string | null;
|
|
254
223
|
export declare function getStorageConfig(): StorageConfig;
|
|
255
|
-
export declare function getStorageMode(): StorageMode;
|
|
256
224
|
export declare function redactDatabaseUrl(value: string | null): string | null;
|
|
257
225
|
export interface PostgresConnectionStringValidation {
|
|
258
226
|
ok: boolean;
|
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;AAC3C,OAAO,
|
|
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,EAAgD,KAAK,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAkB1H,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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GAAG,IAAI,CAGhE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAGpD"}
|
package/dist/storage.js
CHANGED
|
@@ -46,24 +46,109 @@ 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/
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
// src/generated/storage-kit/own.ts
|
|
50
|
+
function ownProp(source, key) {
|
|
51
|
+
if (source === null || source === undefined)
|
|
52
|
+
return;
|
|
53
|
+
const kind = typeof source;
|
|
54
|
+
if (kind !== "object" && kind !== "function")
|
|
55
|
+
return;
|
|
56
|
+
if (!Object.hasOwn(source, key))
|
|
57
|
+
return;
|
|
58
|
+
return source[key];
|
|
59
|
+
}
|
|
60
|
+
function ownString(source, key) {
|
|
61
|
+
const value = ownProp(source, key);
|
|
62
|
+
return typeof value === "string" ? value : undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/generated/storage-kit/backend.ts
|
|
66
|
+
function envToken(name) {
|
|
67
|
+
return name.toUpperCase().replace(/-/g, "_");
|
|
68
|
+
}
|
|
69
|
+
function serverDataBackendEnvKeys(name) {
|
|
70
|
+
const token = envToken(name);
|
|
71
|
+
return {
|
|
72
|
+
databaseUrlKeys: [`HASNA_${token}_DATABASE_URL`, `${token}_DATABASE_URL`]
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function legacyModeKeys(name) {
|
|
76
|
+
const token = envToken(name);
|
|
77
|
+
return [
|
|
78
|
+
`HASNA_${token}_STORAGE_MODE`,
|
|
79
|
+
`HASNA_${token}_MODE`,
|
|
80
|
+
`${token}_STORAGE_MODE`,
|
|
81
|
+
`${token}_MODE`
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
function firstEnv(env, keys) {
|
|
85
|
+
for (const key of keys) {
|
|
86
|
+
const value = ownString(env, key)?.trim();
|
|
87
|
+
if (value)
|
|
88
|
+
return { key, value };
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function firstDefinedEnvKey(env, keys) {
|
|
93
|
+
for (const key of keys) {
|
|
94
|
+
if (Object.hasOwn(env, key) && env[key] !== undefined)
|
|
95
|
+
return key;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
function assertNoLegacyStorageMode(name, env = process.env) {
|
|
100
|
+
const legacyKey = firstDefinedEnvKey(env, legacyModeKeys(name));
|
|
101
|
+
if (!legacyKey)
|
|
102
|
+
return;
|
|
103
|
+
const canonicalDatabaseUrl = serverDataBackendEnvKeys(name).databaseUrlKeys[0];
|
|
104
|
+
throw new Error(`${legacyKey} was removed. Delete the storage-mode variable; ` + `set ${canonicalDatabaseUrl} to select the postgresql server backend, ` + `or leave it unset for sqlite.`);
|
|
105
|
+
}
|
|
106
|
+
function resolveServerDataBackend(name, env = process.env) {
|
|
107
|
+
assertNoLegacyStorageMode(name, env);
|
|
108
|
+
const databaseUrl = firstEnv(env, serverDataBackendEnvKeys(name).databaseUrlKeys);
|
|
109
|
+
if (!databaseUrl) {
|
|
110
|
+
return {
|
|
111
|
+
backend: "sqlite",
|
|
112
|
+
source: "default",
|
|
113
|
+
databaseUrlPresent: false,
|
|
114
|
+
databaseUrlSource: null
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
backend: "postgresql",
|
|
119
|
+
source: databaseUrl.key,
|
|
120
|
+
databaseUrlPresent: true,
|
|
121
|
+
databaseUrlSource: databaseUrl.key
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function resolveDatabaseUrl(name, env = process.env) {
|
|
125
|
+
assertNoLegacyStorageMode(name, env);
|
|
126
|
+
const hit = firstEnv(env, serverDataBackendEnvKeys(name).databaseUrlKeys);
|
|
127
|
+
return hit?.value ?? null;
|
|
128
|
+
}
|
|
129
|
+
var init_backend = () => {};
|
|
130
|
+
|
|
131
|
+
// src/lib/retired-storage-mode.ts
|
|
132
|
+
function firstDefinedEnvKey2(env, keys) {
|
|
133
|
+
for (const key of keys) {
|
|
134
|
+
if (Object.hasOwn(env, key) && env[key] !== undefined)
|
|
135
|
+
return key;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function assertNoLegacyStorageMode2(env = process.env) {
|
|
140
|
+
const legacyKey = firstDefinedEnvKey2(env, LEGACY_STORAGE_MODE_KEYS);
|
|
141
|
+
if (!legacyKey)
|
|
142
|
+
return;
|
|
143
|
+
throw new Error(`${legacyKey} was removed. Deployment modes no longer exist: delete the storage-mode variable. ` + `The client uses the local SQLite store, or the HTTP API selected by ` + `HASNA_MEMENTOS_API_URL + HASNA_MEMENTOS_API_KEY. ` + `On the server, set HASNA_MEMENTOS_DATABASE_URL to select the postgresql backend, ` + `or leave it unset for sqlite.`);
|
|
144
|
+
}
|
|
145
|
+
var LEGACY_STORAGE_MODE_KEYS;
|
|
146
|
+
var init_retired_storage_mode = __esm(() => {
|
|
147
|
+
LEGACY_STORAGE_MODE_KEYS = [
|
|
148
|
+
"HASNA_MEMENTOS_STORAGE_MODE",
|
|
149
|
+
"HASNA_MEMENTOS_MODE",
|
|
150
|
+
"MEMENTOS_STORAGE_MODE",
|
|
151
|
+
"MEMENTOS_MODE"
|
|
67
152
|
];
|
|
68
153
|
});
|
|
69
154
|
|
|
@@ -328,27 +413,6 @@ function readEnv(name) {
|
|
|
328
413
|
const value = process.env[name]?.trim();
|
|
329
414
|
return value ? value : null;
|
|
330
415
|
}
|
|
331
|
-
function warnDeprecatedStorageMode(alias) {
|
|
332
|
-
if (warnedDeprecatedModes.has(alias))
|
|
333
|
-
return;
|
|
334
|
-
warnedDeprecatedModes.add(alias);
|
|
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" });
|
|
336
|
-
}
|
|
337
|
-
function normalizeStorageMode2(value, source) {
|
|
338
|
-
if (!value || !value.trim())
|
|
339
|
-
return null;
|
|
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}`);
|
|
346
|
-
}
|
|
347
|
-
if (normalized.deprecatedAlias) {
|
|
348
|
-
warnDeprecatedStorageMode(normalized.deprecatedAlias);
|
|
349
|
-
}
|
|
350
|
-
return normalized.mode;
|
|
351
|
-
}
|
|
352
416
|
function readConfigFile() {
|
|
353
417
|
if (!existsSync(STORAGE_CONFIG_PATH)) {
|
|
354
418
|
return {};
|
|
@@ -384,19 +448,15 @@ function getStorageDatabaseUrl() {
|
|
|
384
448
|
function getStorageDatabaseEnvName() {
|
|
385
449
|
return getStorageEnvName("databaseUrl");
|
|
386
450
|
}
|
|
387
|
-
function
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
return null;
|
|
451
|
+
function getStorageBackend(env = process.env) {
|
|
452
|
+
return resolveServerDataBackend("mementos", env).backend;
|
|
453
|
+
}
|
|
454
|
+
function getStorageBackendDatabaseUrl(env = process.env) {
|
|
455
|
+
return resolveDatabaseUrl("mementos", env);
|
|
394
456
|
}
|
|
395
457
|
function getStorageConfig() {
|
|
458
|
+
assertNoLegacyStorageMode2();
|
|
396
459
|
const fileConfig = readConfigFile();
|
|
397
|
-
const modeOverride = getStorageModeOverride();
|
|
398
|
-
const envConnectionString = getConfiguredConnectionString();
|
|
399
|
-
const fileMode = normalizeStorageMode2(fileConfig.mode, `${STORAGE_CONFIG_PATH} "mode"`);
|
|
400
460
|
const merged = {
|
|
401
461
|
...DEFAULT_STORAGE_CONFIG,
|
|
402
462
|
...fileConfig,
|
|
@@ -407,19 +467,10 @@ function getStorageConfig() {
|
|
|
407
467
|
sync: {
|
|
408
468
|
...DEFAULT_STORAGE_CONFIG.sync,
|
|
409
469
|
...fileConfig.sync ?? {}
|
|
410
|
-
}
|
|
411
|
-
mode: fileMode ?? DEFAULT_STORAGE_CONFIG.mode
|
|
470
|
+
}
|
|
412
471
|
};
|
|
413
|
-
if (modeOverride) {
|
|
414
|
-
merged.mode = modeOverride;
|
|
415
|
-
} else if (envConnectionString && merged.mode === "local") {
|
|
416
|
-
merged.mode = "cloud";
|
|
417
|
-
}
|
|
418
472
|
return merged;
|
|
419
473
|
}
|
|
420
|
-
function getStorageMode() {
|
|
421
|
-
return getStorageConfig().mode;
|
|
422
|
-
}
|
|
423
474
|
function isSecretQueryParam(key) {
|
|
424
475
|
const normalized = key.trim().toLowerCase();
|
|
425
476
|
return SECRET_QUERY_PARAMS.has(normalized) || /(?:secret|token|password|passphrase|credential|api[_-]?key|apikey|private[_-]?key|auth|session)/i.test(normalized);
|
|
@@ -490,7 +541,7 @@ function storageEnvStatus(key) {
|
|
|
490
541
|
configured: readEnv(activeName) !== null
|
|
491
542
|
};
|
|
492
543
|
}
|
|
493
|
-
function
|
|
544
|
+
function postgresBackendStatus(config) {
|
|
494
545
|
const env = getStorageDatabaseEnv();
|
|
495
546
|
const envUrl = env ? readEnv(env.name) : null;
|
|
496
547
|
if (env && envUrl) {
|
|
@@ -528,12 +579,8 @@ function remoteDatabaseConfigStatus(config) {
|
|
|
528
579
|
rds_compatible: configured
|
|
529
580
|
};
|
|
530
581
|
}
|
|
531
|
-
function runtimeKindFor(mode) {
|
|
532
|
-
return mode === "cloud" ? "cloud-postgres" : "local-sqlite";
|
|
533
|
-
}
|
|
534
582
|
function getSafeStorageConfigSummary(config = getStorageConfig()) {
|
|
535
583
|
return {
|
|
536
|
-
mode: config.mode,
|
|
537
584
|
auto_sync_interval_minutes: config.auto_sync_interval_minutes,
|
|
538
585
|
feedback_endpoint_configured: config.feedback_endpoint.trim() !== "",
|
|
539
586
|
sync: { ...config.sync },
|
|
@@ -548,29 +595,30 @@ function getSafeStorageConfigSummary(config = getStorageConfig()) {
|
|
|
548
595
|
};
|
|
549
596
|
}
|
|
550
597
|
function getStorageStatus() {
|
|
598
|
+
assertNoLegacyStorageMode2();
|
|
551
599
|
const config = getStorageConfig();
|
|
552
|
-
const
|
|
553
|
-
const
|
|
554
|
-
const
|
|
600
|
+
const backend = getStorageBackend();
|
|
601
|
+
const postgresRequested = backend === "postgresql";
|
|
602
|
+
const postgres = postgresBackendStatus(config);
|
|
555
603
|
const issues = [];
|
|
556
604
|
const warnings = [];
|
|
557
|
-
if (
|
|
558
|
-
issues.push(`
|
|
605
|
+
if (postgresRequested && !postgres.configured) {
|
|
606
|
+
issues.push(`PostgreSQL is selected (HASNA_MEMENTOS_DATABASE_URL) but not configured. ${postgres.issues.join(" ")}`);
|
|
559
607
|
}
|
|
560
|
-
if (
|
|
561
|
-
warnings.push(`
|
|
608
|
+
if (!postgresRequested && postgres.issues.length > 0 && postgres.source !== "none") {
|
|
609
|
+
warnings.push(`PostgreSQL configuration is present but invalid; the postgresql backend stays disabled until fixed. ${postgres.issues.join(" ")}`);
|
|
562
610
|
}
|
|
563
|
-
if (
|
|
564
|
-
warnings.push("
|
|
611
|
+
if (!postgresRequested && postgres.configured) {
|
|
612
|
+
warnings.push("PostgreSQL configuration is present, but the selected backend is sqlite; the postgresql backend stays disabled until HASNA_MEMENTOS_DATABASE_URL is set.");
|
|
565
613
|
}
|
|
566
|
-
const failClosed =
|
|
614
|
+
const failClosed = postgresRequested && !postgres.configured;
|
|
567
615
|
const runtime = {
|
|
568
|
-
contract: "mementos-
|
|
569
|
-
kind:
|
|
616
|
+
contract: "mementos-storage-runtime-v1",
|
|
617
|
+
kind: backend,
|
|
570
618
|
fail_closed: failClosed,
|
|
571
619
|
local: {
|
|
572
620
|
adapter: "sqlite",
|
|
573
|
-
primary_runtime:
|
|
621
|
+
primary_runtime: backend === "sqlite",
|
|
574
622
|
data_dir: LOCAL_DATA_DIR,
|
|
575
623
|
config_path: STORAGE_CONFIG_PATH,
|
|
576
624
|
local_file_sync: {
|
|
@@ -578,34 +626,22 @@ function getStorageStatus() {
|
|
|
578
626
|
reason: "Mementos stores local state in SQLite; it does not sync raw local data files."
|
|
579
627
|
}
|
|
580
628
|
},
|
|
581
|
-
|
|
629
|
+
backend: {
|
|
582
630
|
adapter: "postgres",
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
rds_compatible: remote.rds_compatible,
|
|
631
|
+
requested: postgresRequested,
|
|
632
|
+
configured: postgres.configured,
|
|
633
|
+
source: postgres.source,
|
|
634
|
+
env_name: postgres.env_name,
|
|
635
|
+
redacted_url: postgres.redacted_url,
|
|
636
|
+
rds_compatible: postgres.rds_compatible,
|
|
590
637
|
fail_closed: failClosed,
|
|
591
|
-
missing:
|
|
592
|
-
},
|
|
593
|
-
object_storage: {
|
|
594
|
-
s3: {
|
|
595
|
-
supported: false,
|
|
596
|
-
mutation_allowed: false,
|
|
597
|
-
reason: "No S3 object-storage adapter is part of this runtime."
|
|
598
|
-
},
|
|
599
|
-
aws: {
|
|
600
|
-
mutation_allowed: false,
|
|
601
|
-
reason: "Diagnostics do not store sensitive values, change AWS resources, deploy, or mutate production data."
|
|
602
|
-
}
|
|
638
|
+
missing: postgres.missing
|
|
603
639
|
},
|
|
604
640
|
migrations: {
|
|
605
641
|
target: "postgres-rds-compatible",
|
|
606
642
|
command: "mementos storage migrate",
|
|
607
643
|
dry_run_command: "mementos storage migrate --dry-run",
|
|
608
|
-
configured:
|
|
644
|
+
configured: postgres.configured,
|
|
609
645
|
mutates_remote_on_apply: true,
|
|
610
646
|
requires_approval_for_live_run: true
|
|
611
647
|
}
|
|
@@ -613,21 +649,19 @@ function getStorageStatus() {
|
|
|
613
649
|
return {
|
|
614
650
|
ok: issues.length === 0,
|
|
615
651
|
service: "mementos",
|
|
616
|
-
|
|
617
|
-
local_default:
|
|
618
|
-
remote_enabled: remoteRequested,
|
|
652
|
+
backend,
|
|
653
|
+
local_default: backend === "sqlite",
|
|
619
654
|
runtime,
|
|
620
655
|
database: {
|
|
621
|
-
configured:
|
|
622
|
-
redacted_url:
|
|
623
|
-
source:
|
|
624
|
-
env_name:
|
|
625
|
-
rds_compatible:
|
|
656
|
+
configured: postgres.configured,
|
|
657
|
+
redacted_url: postgres.redacted_url,
|
|
658
|
+
source: postgres.source,
|
|
659
|
+
env_name: postgres.env_name,
|
|
660
|
+
rds_compatible: postgres.rds_compatible
|
|
626
661
|
},
|
|
627
662
|
tables: MEMENTOS_STORAGE_TABLES,
|
|
628
663
|
env: {
|
|
629
|
-
databaseUrl: storageEnvStatus("databaseUrl")
|
|
630
|
-
mode: storageEnvStatus("mode")
|
|
664
|
+
databaseUrl: storageEnvStatus("databaseUrl")
|
|
631
665
|
},
|
|
632
666
|
issues,
|
|
633
667
|
warnings,
|
|
@@ -643,8 +677,9 @@ function getConfiguredConnectionString() {
|
|
|
643
677
|
return getStorageDatabaseUrl() ?? undefined;
|
|
644
678
|
}
|
|
645
679
|
function getStorageConnectionString(dbName = "mementos") {
|
|
680
|
+
assertNoLegacyStorageMode2();
|
|
646
681
|
if (!isServerContext()) {
|
|
647
|
-
throw new Error("Refusing to construct an RDS Postgres DSN outside the mementos-serve server. " + "The raw database DSN is NEVER distributed to client machines. " + "Clients must use the
|
|
682
|
+
throw new Error("Refusing to construct an RDS Postgres DSN outside the mementos-serve server. " + "The raw database DSN is NEVER distributed to client machines. " + "Clients must use the HTTP API: set HASNA_MEMENTOS_API_URL and " + "HASNA_MEMENTOS_API_KEY (and unset HASNA_MEMENTOS_DATABASE_URL).");
|
|
648
683
|
}
|
|
649
684
|
const envConnectionString = getConfiguredConnectionString();
|
|
650
685
|
if (envConnectionString) {
|
|
@@ -815,7 +850,7 @@ function resetAllSyncMeta(db) {
|
|
|
815
850
|
ensureSyncMetaTable(db);
|
|
816
851
|
db.run("DELETE FROM _sync_meta");
|
|
817
852
|
}
|
|
818
|
-
var _serverContext = false, PgSyncPool, MEMENTOS_STORAGE_TABLES, STORAGE_TABLES, MEMENTOS_STORAGE_ENV, MEMENTOS_STORAGE_FALLBACK_ENV, LOCAL_DATA_DIR, DEFAULT_STORAGE_CONFIG, STORAGE_CONFIG_DIR, STORAGE_CONFIG_PATH, DATABASE_ENV_NAMES,
|
|
853
|
+
var _serverContext = false, PgSyncPool, MEMENTOS_STORAGE_TABLES, STORAGE_TABLES, MEMENTOS_STORAGE_ENV, MEMENTOS_STORAGE_FALLBACK_ENV, LOCAL_DATA_DIR, DEFAULT_STORAGE_CONFIG, STORAGE_CONFIG_DIR, STORAGE_CONFIG_PATH, DATABASE_ENV_NAMES, SECRET_QUERY_PARAMS, getMementosStorageStatus, SYNC_EXCLUDED_TABLE_PATTERNS, SYNC_META_TABLE_SQL = `
|
|
819
854
|
CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
820
855
|
table_name TEXT PRIMARY KEY,
|
|
821
856
|
last_synced_at TEXT,
|
|
@@ -823,7 +858,8 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
|
823
858
|
direction TEXT DEFAULT 'push'
|
|
824
859
|
)`;
|
|
825
860
|
var init_storage = __esm(() => {
|
|
826
|
-
|
|
861
|
+
init_backend();
|
|
862
|
+
init_retired_storage_mode();
|
|
827
863
|
PgSyncPool = class PgSyncPool {
|
|
828
864
|
worker;
|
|
829
865
|
status;
|
|
@@ -910,12 +946,10 @@ var init_storage = __esm(() => {
|
|
|
910
946
|
];
|
|
911
947
|
STORAGE_TABLES = MEMENTOS_STORAGE_TABLES;
|
|
912
948
|
MEMENTOS_STORAGE_ENV = {
|
|
913
|
-
databaseUrl: "HASNA_MEMENTOS_DATABASE_URL"
|
|
914
|
-
mode: "HASNA_MEMENTOS_STORAGE_MODE"
|
|
949
|
+
databaseUrl: "HASNA_MEMENTOS_DATABASE_URL"
|
|
915
950
|
};
|
|
916
951
|
MEMENTOS_STORAGE_FALLBACK_ENV = {
|
|
917
|
-
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
918
|
-
mode: "MEMENTOS_STORAGE_MODE"
|
|
952
|
+
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
919
953
|
};
|
|
920
954
|
LOCAL_DATA_DIR = join(homedir(), ".hasna", "mementos");
|
|
921
955
|
DEFAULT_STORAGE_CONFIG = {
|
|
@@ -926,7 +960,6 @@ var init_storage = __esm(() => {
|
|
|
926
960
|
password_env: "MEMENTOS_DATABASE_PASSWORD",
|
|
927
961
|
ssl: true
|
|
928
962
|
},
|
|
929
|
-
mode: "local",
|
|
930
963
|
auto_sync_interval_minutes: 0,
|
|
931
964
|
feedback_endpoint: "",
|
|
932
965
|
sync: {
|
|
@@ -939,11 +972,6 @@ var init_storage = __esm(() => {
|
|
|
939
972
|
{ name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
|
|
940
973
|
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
|
|
941
974
|
];
|
|
942
|
-
MODE_ENV_NAMES = [
|
|
943
|
-
{ name: MEMENTOS_STORAGE_ENV.mode, deprecated: false },
|
|
944
|
-
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.mode, deprecated: false }
|
|
945
|
-
];
|
|
946
|
-
warnedDeprecatedModes = new Set;
|
|
947
975
|
SECRET_QUERY_PARAMS = new Set([
|
|
948
976
|
"password",
|
|
949
977
|
"pass",
|
|
@@ -983,12 +1011,13 @@ export {
|
|
|
983
1011
|
getSyncMetaForTable,
|
|
984
1012
|
getSyncMetaAll,
|
|
985
1013
|
getStorageStatus,
|
|
986
|
-
getStorageMode,
|
|
987
1014
|
getStorageDatabaseUrl,
|
|
988
1015
|
getStorageDatabaseEnvName,
|
|
989
1016
|
getStorageDatabaseEnv,
|
|
990
1017
|
getStorageConnectionString,
|
|
991
1018
|
getStorageConfig,
|
|
1019
|
+
getStorageBackendDatabaseUrl,
|
|
1020
|
+
getStorageBackend,
|
|
992
1021
|
getSafeStorageConfigSummary,
|
|
993
1022
|
getMementosStorageStatus,
|
|
994
1023
|
getConfigPath,
|
|
@@ -5,6 +5,11 @@ import type { StoreBackendReport } from "../db/store-backend.js";
|
|
|
5
5
|
* retyped, so adding a selector in src/db/api-mode.ts or src/storage.ts
|
|
6
6
|
* automatically widens what the harnesses neutralize.
|
|
7
7
|
*
|
|
8
|
+
* The retired storage-mode keys stay in the set even though the ratchet turns
|
|
9
|
+
* them into errors: a harness child that inherits a stale variable from the
|
|
10
|
+
* operator shell must have it DELETED (a blank value would still throw), and
|
|
11
|
+
* the preload must keep the suite runnable on a machine that still exports one.
|
|
12
|
+
*
|
|
8
13
|
* `MEMENTOS_DATABASE_PASSWORD` is not a selector but is the store credential;
|
|
9
14
|
* removing it can only make the child more local, never less.
|
|
10
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-isolation.d.ts","sourceRoot":"","sources":["../../src/test-support/store-isolation.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"store-isolation.d.ts","sourceRoot":"","sources":["../../src/test-support/store-isolation.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAIjE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAUpD,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,yDAA0D,CAAC;AAExF,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKxB;AASD,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;CAUjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQnG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,MAAM,SAAmB,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,qFAKxB,CAAC;AAEX,iFAAiF;AACjF,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE5D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kBAAkB,CAAC,CAsD7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,SAA0B,GAAG,IAAI,CAQ9F"}
|
package/docker-entrypoint.sh
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# mementos container entrypoint
|
|
4
4
|
# -----------------------------------------------------------------------------
|
|
5
5
|
# Bridges the hasna-app Terraform module's injected env (DATABASE_URL,
|
|
6
|
-
# API_KEY_SIGNING_SECRET, PORT) to mementos' native env,
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# API_KEY_SIGNING_SECRET, PORT) to mementos' native env, and binds to all
|
|
7
|
+
# interfaces so the ALB target group is reachable. Migrations run against the
|
|
8
|
+
# OWNER DSN (DDL); the long-running service runs against the least-privilege
|
|
9
|
+
# APP DSN.
|
|
10
10
|
# =============================================================================
|
|
11
11
|
set -e
|
|
12
12
|
|
|
@@ -14,7 +14,6 @@ set -e
|
|
|
14
14
|
export MEMENTOS_HOST="${MEMENTOS_HOST:-0.0.0.0}"
|
|
15
15
|
|
|
16
16
|
# Amendment A1 — serve/CLI read+write RDS directly.
|
|
17
|
-
export HASNA_MEMENTOS_STORAGE_MODE="${HASNA_MEMENTOS_STORAGE_MODE:-cloud}"
|
|
18
17
|
|
|
19
18
|
# Select the DSN by workload: migrations need the owner role (DDL); everything
|
|
20
19
|
# else uses the app role. MIGRATION_DATABASE_URL is optional; falls back to
|