@hasna/mementos 0.14.87 → 0.14.88
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/bun.lock +3 -0
- package/dist/cli/brains.d.ts.map +1 -1
- package/dist/cli/commands/io-backup.d.ts.map +1 -1
- package/dist/cli/commands/io-restore.d.ts.map +1 -1
- package/dist/cli/commands/system-profile.d.ts.map +1 -1
- package/dist/cli/helpers.d.ts.map +1 -1
- package/dist/cli/index.js +952 -681
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/db/pg-migrate.d.ts.map +1 -1
- package/dist/diagnostics/historical-project-registration-receipt.js +116 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +808 -543
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/model-config.d.ts +1 -1
- package/dist/lib/paths.d.ts +51 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/profile-sync.d.ts.map +1 -1
- package/dist/lib/search.d.ts.map +1 -1
- package/dist/lib/storage-sync.d.ts.map +1 -1
- package/dist/lib/sync.d.ts.map +1 -1
- package/dist/mcp/index.js +815 -548
- package/dist/project-registration.js +179 -42
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/helpers.d.ts +31 -0
- package/dist/server/helpers.d.ts.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +872 -554
- package/dist/server/routes/system-synthesis.d.ts.map +1 -1
- package/dist/storage.d.ts +18 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +134 -17
- package/package.json +5 -3
- package/postinstall.mjs +34 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-synthesis.d.ts","sourceRoot":"","sources":["../../../src/server/routes/system-synthesis.ts"],"names":[],"mappings":"AAMA,wBAAgB,6BAA6B,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"system-synthesis.d.ts","sourceRoot":"","sources":["../../../src/server/routes/system-synthesis.ts"],"names":[],"mappings":"AAMA,wBAAgB,6BAA6B,IAAI,IAAI,CA6DpD"}
|
package/dist/storage.d.ts
CHANGED
|
@@ -247,6 +247,24 @@ export declare function getStorageStatus(): NativeStorageStatus;
|
|
|
247
247
|
export declare const getMementosStorageStatus: typeof getStorageStatus;
|
|
248
248
|
export declare function saveStorageConfig(config: StorageConfig): void;
|
|
249
249
|
export declare function getStorageConnectionString(dbName?: string): string;
|
|
250
|
+
/**
|
|
251
|
+
* Operator-only DSN resolution for the migrate commands.
|
|
252
|
+
*
|
|
253
|
+
* `storage migrate` / `migrate-pg` are deliberately-invoked operator commands
|
|
254
|
+
* (docs/CUTOVER-RUNBOOK.md §3): they run from an approved, database-reachable
|
|
255
|
+
* administrative environment — on this fleet, the ECS one-shot migrate task
|
|
256
|
+
* that holds the DSN via Secrets Manager as HASNA_MEMENTOS_DATABASE_URL, the
|
|
257
|
+
* same credential the serve task uses. The explicit `--connection-string` form
|
|
258
|
+
* was already sanctioned; this resolves the SAME configured DSN for the
|
|
259
|
+
* operator verb without forcing the value onto the command line.
|
|
260
|
+
*
|
|
261
|
+
* This is NOT the client data path. Every read/write surface (getDatabase,
|
|
262
|
+
* getCloudDatabase, storage-sync, MCP data tools) keeps the fail-closed guard
|
|
263
|
+
* in {@link getStorageConnectionString}. Only the migrate operator surfaces
|
|
264
|
+
* call this, and only they may: a DSN must already be present on the machine
|
|
265
|
+
* for the env/config form to resolve, so this adds no exfiltration surface.
|
|
266
|
+
*/
|
|
267
|
+
export declare function getStorageConnectionStringForOperator(dbName?: string): string;
|
|
250
268
|
export declare const SYNC_EXCLUDED_TABLE_PATTERNS: RegExp[];
|
|
251
269
|
export declare function isSyncExcludedTable(table: string): boolean;
|
|
252
270
|
export declare function listSqliteTables(db: DbAdapter): string[];
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"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EAAE,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAEvD;AAsHD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AA0FD,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
|
@@ -152,11 +152,119 @@ var init_retired_storage_mode = __esm(() => {
|
|
|
152
152
|
];
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
//
|
|
156
|
-
import { Database } from "bun:sqlite";
|
|
157
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
155
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
158
156
|
import { homedir } from "os";
|
|
159
157
|
import { join } from "path";
|
|
158
|
+
function assertApp(app) {
|
|
159
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
160
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
161
|
+
}
|
|
162
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
163
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function envOf(options) {
|
|
167
|
+
return options.env ?? process.env;
|
|
168
|
+
}
|
|
169
|
+
function envValue(options, kind) {
|
|
170
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
171
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
172
|
+
}
|
|
173
|
+
function isMacOS(platform) {
|
|
174
|
+
return platform === "darwin";
|
|
175
|
+
}
|
|
176
|
+
function baseDir(kind, options) {
|
|
177
|
+
const override = envValue(options, kind);
|
|
178
|
+
if (override)
|
|
179
|
+
return override;
|
|
180
|
+
const home = options.home ?? homedir();
|
|
181
|
+
const platform = options.platform ?? process.platform;
|
|
182
|
+
if (isMacOS(platform)) {
|
|
183
|
+
switch (kind) {
|
|
184
|
+
case "config":
|
|
185
|
+
case "data":
|
|
186
|
+
return join(home, "Library", "Application Support", "Hasna");
|
|
187
|
+
case "cache":
|
|
188
|
+
return join(home, "Library", "Caches", "Hasna");
|
|
189
|
+
case "state":
|
|
190
|
+
return join(home, "Library", "Logs", "Hasna");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
switch (kind) {
|
|
194
|
+
case "config":
|
|
195
|
+
return join(home, ".config", "hasna");
|
|
196
|
+
case "data":
|
|
197
|
+
return join(home, ".local", "share", "hasna");
|
|
198
|
+
case "state":
|
|
199
|
+
return join(home, ".local", "state", "hasna");
|
|
200
|
+
case "cache":
|
|
201
|
+
return join(home, ".cache", "hasna");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function resolvePath(kind, options) {
|
|
205
|
+
assertApp(options.app);
|
|
206
|
+
const appSegment = options.internal === true ? join("internal", options.app) : options.app;
|
|
207
|
+
return join(baseDir(kind, options), appSegment);
|
|
208
|
+
}
|
|
209
|
+
function dataDir(options) {
|
|
210
|
+
return resolvePath("data", options);
|
|
211
|
+
}
|
|
212
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
213
|
+
var init_dist = __esm(() => {
|
|
214
|
+
KIND_ENV = {
|
|
215
|
+
config: "HASNA_CONFIG_HOME",
|
|
216
|
+
data: "HASNA_DATA_HOME",
|
|
217
|
+
state: "HASNA_STATE_HOME",
|
|
218
|
+
cache: "HASNA_CACHE_HOME"
|
|
219
|
+
};
|
|
220
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// src/lib/paths.ts
|
|
224
|
+
import { existsSync } from "fs";
|
|
225
|
+
import { homedir as homedir2 } from "os";
|
|
226
|
+
import { join as join2, resolve } from "path";
|
|
227
|
+
function effectiveHome() {
|
|
228
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2() || "/tmp";
|
|
229
|
+
}
|
|
230
|
+
function legacyDataRoot() {
|
|
231
|
+
return join2(effectiveHome(), ".hasna", "mementos");
|
|
232
|
+
}
|
|
233
|
+
function resolverDataRoot() {
|
|
234
|
+
return dataDir({
|
|
235
|
+
app: "mementos",
|
|
236
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function adoptResolverDataRoot(resolved, env = process.env) {
|
|
240
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
241
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
242
|
+
return true;
|
|
243
|
+
return existsSync(join2(resolved, "mementos.db"));
|
|
244
|
+
}
|
|
245
|
+
function exactDataRoot() {
|
|
246
|
+
for (const key of ["HASNA_MEMENTOS_HOME", "MEMENTOS_HOME"]) {
|
|
247
|
+
const dir = process.env[key]?.trim();
|
|
248
|
+
if (dir)
|
|
249
|
+
return resolve(dir);
|
|
250
|
+
}
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
function getDataRoot() {
|
|
254
|
+
const exact = exactDataRoot();
|
|
255
|
+
if (exact)
|
|
256
|
+
return exact;
|
|
257
|
+
const resolved = resolverDataRoot();
|
|
258
|
+
return adoptResolverDataRoot(resolved) ? resolve(resolved) : resolve(legacyDataRoot());
|
|
259
|
+
}
|
|
260
|
+
var init_paths = __esm(() => {
|
|
261
|
+
init_dist();
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// src/storage.ts
|
|
265
|
+
import { Database } from "bun:sqlite";
|
|
266
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
267
|
+
import { join as join3 } from "path";
|
|
160
268
|
import { fileURLToPath } from "url";
|
|
161
269
|
import { Worker } from "worker_threads";
|
|
162
270
|
import pg from "pg";
|
|
@@ -415,7 +523,7 @@ function readEnv(name) {
|
|
|
415
523
|
return value ? value : null;
|
|
416
524
|
}
|
|
417
525
|
function readConfigFile() {
|
|
418
|
-
if (!
|
|
526
|
+
if (!existsSync2(STORAGE_CONFIG_PATH)) {
|
|
419
527
|
return {};
|
|
420
528
|
}
|
|
421
529
|
try {
|
|
@@ -677,11 +785,7 @@ function saveStorageConfig(config) {
|
|
|
677
785
|
function getConfiguredConnectionString() {
|
|
678
786
|
return getStorageDatabaseUrl() ?? undefined;
|
|
679
787
|
}
|
|
680
|
-
function
|
|
681
|
-
assertNoLegacyStorageMode2();
|
|
682
|
-
if (!isServerContext()) {
|
|
683
|
-
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).");
|
|
684
|
-
}
|
|
788
|
+
function resolveConfiguredConnectionString(dbName) {
|
|
685
789
|
const envConnectionString = getConfiguredConnectionString();
|
|
686
790
|
if (envConnectionString) {
|
|
687
791
|
const validation = validatePostgresConnectionString(envConnectionString);
|
|
@@ -700,7 +804,7 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
700
804
|
missing.push("storage.rds.username");
|
|
701
805
|
}
|
|
702
806
|
if (missing.length > 0) {
|
|
703
|
-
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure
|
|
807
|
+
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ${STORAGE_CONFIG_PATH}.`);
|
|
704
808
|
}
|
|
705
809
|
const password = process.env[password_env];
|
|
706
810
|
if (!password) {
|
|
@@ -709,6 +813,17 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
709
813
|
const sslParam = ssl ? "?sslmode=require" : "";
|
|
710
814
|
return `postgres://${username}:${encodeURIComponent(password)}@${host}:${port}/${dbName}${sslParam}`;
|
|
711
815
|
}
|
|
816
|
+
function getStorageConnectionString(dbName = "mementos") {
|
|
817
|
+
assertNoLegacyStorageMode2();
|
|
818
|
+
if (!isServerContext()) {
|
|
819
|
+
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).");
|
|
820
|
+
}
|
|
821
|
+
return resolveConfiguredConnectionString(dbName);
|
|
822
|
+
}
|
|
823
|
+
function getStorageConnectionStringForOperator(dbName = "mementos") {
|
|
824
|
+
assertNoLegacyStorageMode2();
|
|
825
|
+
return resolveConfiguredConnectionString(dbName);
|
|
826
|
+
}
|
|
712
827
|
function isSyncExcludedTable(table) {
|
|
713
828
|
return SYNC_EXCLUDED_TABLE_PATTERNS.some((pattern) => pattern.test(table));
|
|
714
829
|
}
|
|
@@ -878,6 +993,7 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
|
878
993
|
var init_storage = __esm(() => {
|
|
879
994
|
init_backend();
|
|
880
995
|
init_retired_storage_mode();
|
|
996
|
+
init_paths();
|
|
881
997
|
PgSyncPool = class PgSyncPool {
|
|
882
998
|
worker;
|
|
883
999
|
status;
|
|
@@ -895,12 +1011,12 @@ var init_storage = __esm(() => {
|
|
|
895
1011
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
896
1012
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
897
1013
|
const candidates = [
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1014
|
+
join3(here, `pg-sync-worker${ext}`),
|
|
1015
|
+
join3(here, "..", `pg-sync-worker${ext}`),
|
|
1016
|
+
join3(here, "..", "..", `pg-sync-worker${ext}`)
|
|
901
1017
|
];
|
|
902
1018
|
for (const candidate of candidates) {
|
|
903
|
-
if (
|
|
1019
|
+
if (existsSync2(candidate))
|
|
904
1020
|
return candidate;
|
|
905
1021
|
}
|
|
906
1022
|
return candidates[0];
|
|
@@ -988,7 +1104,7 @@ var init_storage = __esm(() => {
|
|
|
988
1104
|
MEMENTOS_STORAGE_FALLBACK_ENV = {
|
|
989
1105
|
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
990
1106
|
};
|
|
991
|
-
LOCAL_DATA_DIR =
|
|
1107
|
+
LOCAL_DATA_DIR = getDataRoot();
|
|
992
1108
|
DEFAULT_STORAGE_CONFIG = {
|
|
993
1109
|
rds: {
|
|
994
1110
|
host: "",
|
|
@@ -1003,8 +1119,8 @@ var init_storage = __esm(() => {
|
|
|
1003
1119
|
schedule_minutes: 0
|
|
1004
1120
|
}
|
|
1005
1121
|
};
|
|
1006
|
-
STORAGE_CONFIG_DIR =
|
|
1007
|
-
STORAGE_CONFIG_PATH =
|
|
1122
|
+
STORAGE_CONFIG_DIR = join3(LOCAL_DATA_DIR, "storage");
|
|
1123
|
+
STORAGE_CONFIG_PATH = join3(STORAGE_CONFIG_DIR, "config.json");
|
|
1008
1124
|
DATABASE_ENV_NAMES = [
|
|
1009
1125
|
{ name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
|
|
1010
1126
|
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
|
|
@@ -1051,6 +1167,7 @@ export {
|
|
|
1051
1167
|
getStorageDatabaseUrl,
|
|
1052
1168
|
getStorageDatabaseEnvName,
|
|
1053
1169
|
getStorageDatabaseEnv,
|
|
1170
|
+
getStorageConnectionStringForOperator,
|
|
1054
1171
|
getStorageConnectionString,
|
|
1055
1172
|
getStorageConfig,
|
|
1056
1173
|
getStorageBackendDatabaseUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/mementos",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.88",
|
|
4
4
|
"description": "Universal memory system for AI agents - CLI + MCP server + library API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"bun.lock",
|
|
37
37
|
"hasna.contract.json",
|
|
38
38
|
"LICENSE",
|
|
39
|
-
"README.md"
|
|
39
|
+
"README.md",
|
|
40
|
+
"postinstall.mjs"
|
|
40
41
|
],
|
|
41
42
|
"scripts": {
|
|
42
43
|
"clean": "rm -rf dist",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"dev:cli": "bun run src/cli/index.tsx",
|
|
55
56
|
"dev:mcp": "bun run src/mcp/index.ts",
|
|
56
57
|
"dev:serve": "bun run src/server/index.ts",
|
|
57
|
-
"postinstall": "
|
|
58
|
+
"postinstall": "node postinstall.mjs",
|
|
58
59
|
"build:js": "bun run clean && bun build src/cli/index.tsx --outdir dist/cli --target bun --external ink --external react --external chalk --external @modelcontextprotocol/sdk --external @hasna/contracts --external @hasna/contracts/schemas --external @hasna/contracts/auth --external pg && bun build src/mcp/index.ts --outdir dist/mcp --target bun --external @modelcontextprotocol/sdk --external @hasna/contracts --external @hasna/contracts/schemas --external @hasna/contracts/auth --external pg && bun build src/server/index.ts --outdir dist/server --target bun --external @hasna/contracts --external @hasna/contracts/schemas --external @hasna/contracts/auth --external pg && bun build src/index.ts src/storage.ts src/pg-sync-worker.ts src/project-registration.ts --outdir dist --target bun --external @hasna/contracts --external @hasna/contracts/schemas --external @hasna/contracts/auth --external pg && bun build src/diagnostics/historical-project-registration-receipt.ts --outdir dist/diagnostics --target bun --external pg && bun build src/sdk/index.ts --outdir dist/sdk --target bun && tsc --emitDeclarationOnly --outDir dist"
|
|
59
60
|
},
|
|
60
61
|
"keywords": [
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
"@ai-sdk/openai-compatible": "^2.0.48",
|
|
93
94
|
"@hasna/contracts": "0.10.6",
|
|
94
95
|
"@hasna/events": "0.1.6",
|
|
96
|
+
"@hasna/paths": "0.1.0",
|
|
95
97
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
96
98
|
"ai": "^6.0.199",
|
|
97
99
|
"chalk": "^5.4.1",
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Best-effort install-time creation of the mementos data home, resolving the
|
|
2
|
+
// SAME effective data root the runtime uses (src/lib/paths.ts getDataRoot): an
|
|
3
|
+
// exact-app override (HASNA_MEMENTOS_HOME / MEMENTOS_HOME) wins; otherwise the
|
|
4
|
+
// @hasna/paths XDG data home once adopted (HASNA_DATA_HOME set, or mementos.db
|
|
5
|
+
// already migrated there); otherwise the legacy ~/.hasna/mementos default.
|
|
6
|
+
// Failures are non-fatal: the runtime creates the same directories on first use.
|
|
7
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
const EXACT_OVERRIDES = [
|
|
12
|
+
(process.env["HASNA_MEMENTOS_HOME"] || "").trim(),
|
|
13
|
+
(process.env["MEMENTOS_HOME"] || "").trim(),
|
|
14
|
+
].filter(Boolean);
|
|
15
|
+
const DATA_HOME_OVERRIDE = (process.env["HASNA_DATA_HOME"] || "").trim();
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const { dataDir } = await import("@hasna/paths");
|
|
19
|
+
const home = process.env["HOME"] || process.env["USERPROFILE"] || homedir();
|
|
20
|
+
const resolved = dataDir({ app: "mementos", home });
|
|
21
|
+
let root;
|
|
22
|
+
if (EXACT_OVERRIDES.length > 0) {
|
|
23
|
+
root = EXACT_OVERRIDES[0];
|
|
24
|
+
} else if (DATA_HOME_OVERRIDE || existsSync(join(resolved, "mementos.db"))) {
|
|
25
|
+
root = resolved;
|
|
26
|
+
} else {
|
|
27
|
+
root = join(home, ".hasna", "mementos");
|
|
28
|
+
}
|
|
29
|
+
for (const sub of ["", "profiles", "agents", "training", "backups", "storage"]) {
|
|
30
|
+
mkdirSync(join(root, sub), { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
// never fail an install over pre-created directories
|
|
34
|
+
}
|