@hasna/mementos 0.14.58 → 0.14.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/info-report.d.ts.map +1 -1
- package/dist/cli/index.js +266 -113
- package/dist/db/api-mode.d.ts.map +1 -1
- package/dist/db/memories.d.ts +32 -0
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/index.js +110 -65
- package/dist/lib/asmr/recall.d.ts +3 -0
- package/dist/lib/asmr/recall.d.ts.map +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +239 -267
- package/dist/mcp/tools/graph-utils.d.ts.map +1 -1
- package/dist/mcp/tools/memory-crud.d.ts.map +1 -1
- package/dist/mcp/tools/memory-search.d.ts.map +1 -1
- package/dist/mcp/tools/storage-tools.d.ts.map +1 -1
- package/dist/mcp/tools/system-tools-memory-admin.d.ts +1 -1
- package/dist/mcp/tools/system-tools-memory-admin.d.ts.map +1 -1
- package/dist/mcp/tools/system-tools-shared.d.ts.map +1 -1
- package/dist/mcp/tools/utility-tools.d.ts.map +1 -1
- package/dist/server/index.js +722 -53
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/lib/remote-sync.d.ts +0 -49
- package/dist/lib/remote-sync.d.ts.map +0 -1
- package/dist/mcp/tools/memory-sync.d.ts +0 -3
- package/dist/mcp/tools/memory-sync.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-mode.d.ts","sourceRoot":"","sources":["../../src/db/api-mode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-mode.d.ts","sourceRoot":"","sources":["../../src/db/api-mode.ts"],"names":[],"mappings":"AAmCA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAqBD,6EAA6E;AAC7E,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAK/C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAGnC;AAED,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBAF5B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CAK/B;AAsGD,sGAAsG;AACtG,wBAAgB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAiB9G;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAe/D"}
|
package/dist/db/memories.d.ts
CHANGED
|
@@ -38,6 +38,37 @@ export declare function getMemoryByKey(key: string, scope?: string, agentId?: st
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function getMemoriesByKey(key: string, scope?: string, agentId?: string, projectId?: string, db?: Database): Memory[];
|
|
40
40
|
export declare function listMemories(filter?: MemoryFilter, db?: Database): Memory[];
|
|
41
|
+
export interface MemoryBriefingResult {
|
|
42
|
+
new: Memory[];
|
|
43
|
+
updated: Memory[];
|
|
44
|
+
expired: Memory[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Delta briefing: memories created / updated / expired since a timestamp,
|
|
48
|
+
* scoped by machine visibility. Transport-aware: in API mode the whole
|
|
49
|
+
* computation runs on the self-hosted server (the client has no DB).
|
|
50
|
+
*
|
|
51
|
+
* `visible_machine_id`: a resolved value (the caller resolves its own current
|
|
52
|
+
* machine). `null`/`undefined` restricts to machine-agnostic memories; a string
|
|
53
|
+
* also includes memories local to that machine.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getMemoryBriefing(opts: {
|
|
56
|
+
since: string;
|
|
57
|
+
scope?: string;
|
|
58
|
+
project_id?: string;
|
|
59
|
+
visible_machine_id?: string | null;
|
|
60
|
+
limit?: number;
|
|
61
|
+
}, db?: Database): MemoryBriefingResult;
|
|
62
|
+
/**
|
|
63
|
+
* Low-trust memories (trust_score below a threshold) for poisoning review.
|
|
64
|
+
* Transport-aware: API mode reads from the self-hosted server.
|
|
65
|
+
*/
|
|
66
|
+
export declare function listLowTrustMemories(opts?: {
|
|
67
|
+
threshold?: number;
|
|
68
|
+
project_id?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
}, db?: Database): Memory[];
|
|
41
72
|
/**
|
|
42
73
|
* List memories ordered by most-recently-accessed (the `history` surface).
|
|
43
74
|
* Only returns memories that have been accessed at least once.
|
|
@@ -83,5 +114,6 @@ export declare function semanticSearch(queryText: string, options?: {
|
|
|
83
114
|
scope?: string;
|
|
84
115
|
agent_id?: string;
|
|
85
116
|
project_id?: string;
|
|
117
|
+
index_missing?: boolean;
|
|
86
118
|
}, db?: Database): Promise<SemanticSearchResult[]>;
|
|
87
119
|
//# sourceMappingURL=memories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/db/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/db/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,i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,EACN,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,oBAAoB,EAAE,CAAC,CA4DjC"}
|
package/dist/index.js
CHANGED
|
@@ -723,6 +723,10 @@ var init_storage = __esm(() => {
|
|
|
723
723
|
});
|
|
724
724
|
|
|
725
725
|
// src/db/api-mode.ts
|
|
726
|
+
import { tmpdir } from "os";
|
|
727
|
+
import { join as join2 } from "path";
|
|
728
|
+
import { writeFileSync as writeFileSync2, unlinkSync } from "fs";
|
|
729
|
+
import { randomUUID } from "crypto";
|
|
726
730
|
function firstEnv(...keys) {
|
|
727
731
|
for (const k of keys) {
|
|
728
732
|
const v = process.env[k]?.trim();
|
|
@@ -758,33 +762,60 @@ function apiRequestRaw(method, path, body) {
|
|
|
758
762
|
throw new Error("api-mode: not configured (HASNA_MEMENTOS_API_URL / HASNA_MEMENTOS_API_KEY)");
|
|
759
763
|
const url = `${cfg.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
|
|
760
764
|
const hasBody = body !== undefined && body !== null;
|
|
761
|
-
const
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
765
|
+
const timeout = process.env["HASNA_MEMENTOS_API_TIMEOUT"] || DEFAULT_TIMEOUT_S;
|
|
766
|
+
const headerLines = `Authorization: Bearer ${cfg.apiKey}
|
|
767
|
+
x-api-key: ${cfg.apiKey}
|
|
768
|
+
`;
|
|
769
|
+
const args = [
|
|
770
|
+
"curl",
|
|
771
|
+
"-sS",
|
|
772
|
+
"--fail-with-body",
|
|
773
|
+
"-m",
|
|
774
|
+
timeout,
|
|
775
|
+
"-X",
|
|
776
|
+
method,
|
|
777
|
+
"-H",
|
|
778
|
+
"@-",
|
|
779
|
+
"-H",
|
|
780
|
+
"Content-Type: application/json",
|
|
781
|
+
"-H",
|
|
782
|
+
"Accept: application/json",
|
|
783
|
+
"-w",
|
|
784
|
+
"\\n%{http_code}"
|
|
785
|
+
];
|
|
786
|
+
let bodyFile;
|
|
787
|
+
if (hasBody) {
|
|
788
|
+
bodyFile = join2(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
|
|
789
|
+
writeFileSync2(bodyFile, JSON.stringify(body), { mode: 384 });
|
|
790
|
+
args.push("--data-binary", `@${bodyFile}`);
|
|
791
|
+
}
|
|
792
|
+
args.push(url);
|
|
793
|
+
const childEnv = {};
|
|
794
|
+
for (const [k, v] of Object.entries(process.env)) {
|
|
795
|
+
if (v === undefined)
|
|
796
|
+
continue;
|
|
797
|
+
if (k === "HASNA_MEMENTOS_API_KEY" || k === "MEMENTOS_API_KEY")
|
|
798
|
+
continue;
|
|
799
|
+
childEnv[k] = v;
|
|
800
|
+
}
|
|
801
|
+
let out = "";
|
|
802
|
+
let err = "";
|
|
803
|
+
try {
|
|
804
|
+
const proc = Bun.spawnSync(args, {
|
|
805
|
+
stdin: Buffer.from(headerLines),
|
|
806
|
+
stdout: "pipe",
|
|
807
|
+
stderr: "pipe",
|
|
808
|
+
env: childEnv
|
|
809
|
+
});
|
|
810
|
+
out = proc.stdout ? new TextDecoder().decode(proc.stdout) : "";
|
|
811
|
+
err = proc.stderr ? new TextDecoder().decode(proc.stderr) : "";
|
|
812
|
+
} finally {
|
|
813
|
+
if (bodyFile) {
|
|
814
|
+
try {
|
|
815
|
+
unlinkSync(bodyFile);
|
|
816
|
+
} catch {}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
788
819
|
const nl = out.lastIndexOf(`
|
|
789
820
|
`);
|
|
790
821
|
const codeStr = nl >= 0 ? out.slice(nl + 1).trim() : "";
|
|
@@ -1763,7 +1794,7 @@ __export(exports_database, {
|
|
|
1763
1794
|
closeDatabase: () => closeDatabase
|
|
1764
1795
|
});
|
|
1765
1796
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, cpSync } from "fs";
|
|
1766
|
-
import { dirname, join as
|
|
1797
|
+
import { dirname, join as join3, resolve } from "path";
|
|
1767
1798
|
function isInMemoryDb(path) {
|
|
1768
1799
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
1769
1800
|
}
|
|
@@ -1772,7 +1803,7 @@ function findNearestMementosDb(startDir) {
|
|
|
1772
1803
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
1773
1804
|
const legacyHomeDb = resolve(home, ".mementos", "mementos.db");
|
|
1774
1805
|
while (true) {
|
|
1775
|
-
const candidate =
|
|
1806
|
+
const candidate = join3(dir, ".mementos", "mementos.db");
|
|
1776
1807
|
if (existsSync2(candidate) && resolve(candidate) !== legacyHomeDb)
|
|
1777
1808
|
return candidate;
|
|
1778
1809
|
const parent = dirname(dir);
|
|
@@ -1785,7 +1816,7 @@ function findNearestMementosDb(startDir) {
|
|
|
1785
1816
|
function findGitRoot(startDir) {
|
|
1786
1817
|
let dir = resolve(startDir);
|
|
1787
1818
|
while (true) {
|
|
1788
|
-
if (existsSync2(
|
|
1819
|
+
if (existsSync2(join3(dir, ".git")))
|
|
1789
1820
|
return dir;
|
|
1790
1821
|
const parent = dirname(dir);
|
|
1791
1822
|
if (parent === dir)
|
|
@@ -1796,10 +1827,10 @@ function findGitRoot(startDir) {
|
|
|
1796
1827
|
}
|
|
1797
1828
|
function migrateGlobalDir() {
|
|
1798
1829
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
1799
|
-
const newDir =
|
|
1800
|
-
const oldDir =
|
|
1830
|
+
const newDir = join3(home, ".hasna", "mementos");
|
|
1831
|
+
const oldDir = join3(home, ".mementos");
|
|
1801
1832
|
if (!existsSync2(newDir) && existsSync2(oldDir)) {
|
|
1802
|
-
mkdirSync2(
|
|
1833
|
+
mkdirSync2(join3(home, ".hasna"), { recursive: true });
|
|
1803
1834
|
cpSync(oldDir, newDir, { recursive: true });
|
|
1804
1835
|
}
|
|
1805
1836
|
}
|
|
@@ -1815,12 +1846,12 @@ function getDbPath() {
|
|
|
1815
1846
|
if (process.env["MEMENTOS_DB_SCOPE"] === "project") {
|
|
1816
1847
|
const gitRoot = findGitRoot(cwd);
|
|
1817
1848
|
if (gitRoot) {
|
|
1818
|
-
return
|
|
1849
|
+
return join3(gitRoot, ".mementos", "mementos.db");
|
|
1819
1850
|
}
|
|
1820
1851
|
}
|
|
1821
1852
|
migrateGlobalDir();
|
|
1822
1853
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
1823
|
-
return
|
|
1854
|
+
return join3(home, ".hasna", "mementos", "mementos.db");
|
|
1824
1855
|
}
|
|
1825
1856
|
function ensureDir(filePath) {
|
|
1826
1857
|
if (isInMemoryDb(filePath))
|
|
@@ -49003,6 +49034,14 @@ function getEntityMemoryLinks(entityId, memoryId, db) {
|
|
|
49003
49034
|
// src/db/memories.ts
|
|
49004
49035
|
init_api_mode();
|
|
49005
49036
|
function runEntityExtraction(_memory, _projectId, _d) {}
|
|
49037
|
+
function applyContentType(d, id, memory, contentType) {
|
|
49038
|
+
if (!contentType || contentType === "text")
|
|
49039
|
+
return;
|
|
49040
|
+
try {
|
|
49041
|
+
d.run("UPDATE memories SET content_type = ? WHERE id = ?", [contentType, id]);
|
|
49042
|
+
memory.content_type = contentType;
|
|
49043
|
+
} catch {}
|
|
49044
|
+
}
|
|
49006
49045
|
function parseMemoryRow(row) {
|
|
49007
49046
|
return {
|
|
49008
49047
|
id: row["id"],
|
|
@@ -49107,6 +49146,7 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
49107
49146
|
insertTag2.run(existing.id, tag);
|
|
49108
49147
|
}
|
|
49109
49148
|
const merged = getMemory(existing.id, d);
|
|
49149
|
+
applyContentType(d, existing.id, merged, input.content_type);
|
|
49110
49150
|
try {
|
|
49111
49151
|
const existingMemories = listMemoriesByKey(input.key, d);
|
|
49112
49152
|
const trustScore = computeTrustScore(safeValue, input.key, existingMemories, input.importance);
|
|
@@ -49156,6 +49196,7 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
49156
49196
|
insertTag.run(id, tag);
|
|
49157
49197
|
}
|
|
49158
49198
|
const memory = getMemory(id, d);
|
|
49199
|
+
applyContentType(d, id, memory, input.content_type);
|
|
49159
49200
|
try {
|
|
49160
49201
|
const existingMemories = listMemoriesByKey(input.key, d);
|
|
49161
49202
|
const trustScore = computeTrustScore(safeValue, input.key, existingMemories, input.importance);
|
|
@@ -49582,6 +49623,10 @@ function incrementRecallCount(id, db) {
|
|
|
49582
49623
|
} catch {}
|
|
49583
49624
|
}
|
|
49584
49625
|
function cleanExpiredMemories(db) {
|
|
49626
|
+
if (!db && isApiMode()) {
|
|
49627
|
+
const { data } = apiJson("POST", "/memories/clean");
|
|
49628
|
+
return data?.cleaned ?? 0;
|
|
49629
|
+
}
|
|
49585
49630
|
const d = db || getDatabase();
|
|
49586
49631
|
const timestamp = now();
|
|
49587
49632
|
const countRow = d.query("SELECT COUNT(*) as c FROM memories WHERE expires_at IS NOT NULL AND expires_at < ?").get(timestamp);
|
|
@@ -51196,9 +51241,9 @@ function formatMementosProjectPanel(panel) {
|
|
|
51196
51241
|
`);
|
|
51197
51242
|
}
|
|
51198
51243
|
// src/lib/config.ts
|
|
51199
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, readdirSync, writeFileSync as
|
|
51244
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, readdirSync, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, cpSync as cpSync2 } from "fs";
|
|
51200
51245
|
import { homedir as homedir2 } from "os";
|
|
51201
|
-
import { basename, dirname as dirname2, join as
|
|
51246
|
+
import { basename, dirname as dirname2, join as join4, resolve as resolve2 } from "path";
|
|
51202
51247
|
function isInMemoryDb2(path) {
|
|
51203
51248
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
51204
51249
|
}
|
|
@@ -51261,7 +51306,7 @@ function isValidCategory(value) {
|
|
|
51261
51306
|
return VALID_CATEGORIES.includes(value);
|
|
51262
51307
|
}
|
|
51263
51308
|
function loadConfig() {
|
|
51264
|
-
const configPath =
|
|
51309
|
+
const configPath = join4(homeDir(), ".hasna", "mementos", "config.json");
|
|
51265
51310
|
let fileConfig = {};
|
|
51266
51311
|
if (existsSync3(configPath)) {
|
|
51267
51312
|
try {
|
|
@@ -51291,7 +51336,7 @@ function findFileWalkingUp(filename) {
|
|
|
51291
51336
|
let dir = process.cwd();
|
|
51292
51337
|
const legacyHomeMementosDb = resolve2(homeDir(), ".mementos", "mementos.db");
|
|
51293
51338
|
while (true) {
|
|
51294
|
-
const candidate =
|
|
51339
|
+
const candidate = join4(dir, filename);
|
|
51295
51340
|
if (existsSync3(candidate) && resolve2(candidate) !== legacyHomeMementosDb) {
|
|
51296
51341
|
return candidate;
|
|
51297
51342
|
}
|
|
@@ -51305,7 +51350,7 @@ function findFileWalkingUp(filename) {
|
|
|
51305
51350
|
function findGitRoot2() {
|
|
51306
51351
|
let dir = process.cwd();
|
|
51307
51352
|
while (true) {
|
|
51308
|
-
if (existsSync3(
|
|
51353
|
+
if (existsSync3(join4(dir, ".git"))) {
|
|
51309
51354
|
return dir;
|
|
51310
51355
|
}
|
|
51311
51356
|
const parent = dirname2(dir);
|
|
@@ -51316,10 +51361,10 @@ function findGitRoot2() {
|
|
|
51316
51361
|
}
|
|
51317
51362
|
}
|
|
51318
51363
|
function profilesDir() {
|
|
51319
|
-
return
|
|
51364
|
+
return join4(homeDir(), ".hasna", "mementos", "profiles");
|
|
51320
51365
|
}
|
|
51321
51366
|
function globalConfigPath() {
|
|
51322
|
-
return
|
|
51367
|
+
return join4(homeDir(), ".hasna", "mementos", "config.json");
|
|
51323
51368
|
}
|
|
51324
51369
|
function readGlobalConfig() {
|
|
51325
51370
|
const p = globalConfigPath();
|
|
@@ -51334,7 +51379,7 @@ function readGlobalConfig() {
|
|
|
51334
51379
|
function writeGlobalConfig(data) {
|
|
51335
51380
|
const p = globalConfigPath();
|
|
51336
51381
|
ensureDir2(dirname2(p));
|
|
51337
|
-
|
|
51382
|
+
writeFileSync3(p, JSON.stringify(data, null, 2), "utf-8");
|
|
51338
51383
|
}
|
|
51339
51384
|
function getActiveProfile() {
|
|
51340
51385
|
const envProfile = process.env["MEMENTOS_PROFILE"];
|
|
@@ -51359,20 +51404,20 @@ function listProfiles() {
|
|
|
51359
51404
|
return readdirSync(dir).filter((f) => f.endsWith(".db")).map((f) => basename(f, ".db")).sort();
|
|
51360
51405
|
}
|
|
51361
51406
|
function deleteProfile(name) {
|
|
51362
|
-
const dbPath =
|
|
51407
|
+
const dbPath = join4(profilesDir(), `${name}.db`);
|
|
51363
51408
|
if (!existsSync3(dbPath))
|
|
51364
51409
|
return false;
|
|
51365
|
-
|
|
51410
|
+
unlinkSync2(dbPath);
|
|
51366
51411
|
if (getActiveProfile() === name)
|
|
51367
51412
|
setActiveProfile(null);
|
|
51368
51413
|
return true;
|
|
51369
51414
|
}
|
|
51370
51415
|
function getDbPath2() {
|
|
51371
51416
|
const _home = homeDir();
|
|
51372
|
-
const _newDir =
|
|
51373
|
-
const _oldDir =
|
|
51417
|
+
const _newDir = join4(_home, ".hasna", "mementos");
|
|
51418
|
+
const _oldDir = join4(_home, ".mementos");
|
|
51374
51419
|
if (!existsSync3(_newDir) && existsSync3(_oldDir)) {
|
|
51375
|
-
mkdirSync3(
|
|
51420
|
+
mkdirSync3(join4(_home, ".hasna"), { recursive: true });
|
|
51376
51421
|
cpSync2(_oldDir, _newDir, { recursive: true });
|
|
51377
51422
|
}
|
|
51378
51423
|
const envDbPath = process.env["HASNA_MEMENTOS_DB_PATH"] ?? process.env["MEMENTOS_DB_PATH"];
|
|
@@ -51386,7 +51431,7 @@ function getDbPath2() {
|
|
|
51386
51431
|
}
|
|
51387
51432
|
const profile = getActiveProfile();
|
|
51388
51433
|
if (profile) {
|
|
51389
|
-
const profilePath =
|
|
51434
|
+
const profilePath = join4(profilesDir(), `${profile}.db`);
|
|
51390
51435
|
ensureDir2(dirname2(profilePath));
|
|
51391
51436
|
return profilePath;
|
|
51392
51437
|
}
|
|
@@ -51394,16 +51439,16 @@ function getDbPath2() {
|
|
|
51394
51439
|
if (dbScope === "project") {
|
|
51395
51440
|
const gitRoot = findGitRoot2();
|
|
51396
51441
|
if (gitRoot) {
|
|
51397
|
-
const dbPath =
|
|
51442
|
+
const dbPath = join4(gitRoot, ".mementos", "mementos.db");
|
|
51398
51443
|
ensureDir2(dirname2(dbPath));
|
|
51399
51444
|
return dbPath;
|
|
51400
51445
|
}
|
|
51401
51446
|
}
|
|
51402
|
-
const found = findFileWalkingUp(
|
|
51447
|
+
const found = findFileWalkingUp(join4(".mementos", "mementos.db"));
|
|
51403
51448
|
if (found) {
|
|
51404
51449
|
return found;
|
|
51405
51450
|
}
|
|
51406
|
-
const fallback =
|
|
51451
|
+
const fallback = join4(homeDir(), ".hasna", "mementos", "mementos.db");
|
|
51407
51452
|
ensureDir2(dirname2(fallback));
|
|
51408
51453
|
return fallback;
|
|
51409
51454
|
}
|
|
@@ -51789,19 +51834,19 @@ function runCleanup(config, db) {
|
|
|
51789
51834
|
return { expired, evicted, archived, unused_archived, deprioritized };
|
|
51790
51835
|
}
|
|
51791
51836
|
// src/lib/sync.ts
|
|
51792
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync3, writeFileSync as
|
|
51837
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
51793
51838
|
import { homedir as homedir3 } from "os";
|
|
51794
|
-
import { join as
|
|
51839
|
+
import { join as join5 } from "path";
|
|
51795
51840
|
function getAgentSyncDir(agentName) {
|
|
51796
|
-
const dir =
|
|
51841
|
+
const dir = join5(homedir3(), ".hasna", "mementos", "agents", agentName);
|
|
51797
51842
|
if (!existsSync4(dir)) {
|
|
51798
51843
|
mkdirSync4(dir, { recursive: true });
|
|
51799
51844
|
}
|
|
51800
51845
|
return dir;
|
|
51801
51846
|
}
|
|
51802
51847
|
function setHighWaterMark(agentDir, timestamp) {
|
|
51803
|
-
const markFile =
|
|
51804
|
-
|
|
51848
|
+
const markFile = join5(agentDir, ".highwatermark");
|
|
51849
|
+
writeFileSync4(markFile, timestamp, "utf-8");
|
|
51805
51850
|
}
|
|
51806
51851
|
function resolveConflict(local, remote, resolution) {
|
|
51807
51852
|
switch (resolution) {
|
|
@@ -51821,8 +51866,8 @@ function pushMemories(agentName, agentId, projectId, db) {
|
|
|
51821
51866
|
status: "active",
|
|
51822
51867
|
limit: 1e4
|
|
51823
51868
|
}, db);
|
|
51824
|
-
const outFile =
|
|
51825
|
-
|
|
51869
|
+
const outFile = join5(agentDir, "memories.json");
|
|
51870
|
+
writeFileSync4(outFile, JSON.stringify(memories, null, 2), "utf-8");
|
|
51826
51871
|
if (memories.length > 0) {
|
|
51827
51872
|
const latest = memories.reduce((a, b) => new Date(a.updated_at).getTime() > new Date(b.updated_at).getTime() ? a : b);
|
|
51828
51873
|
setHighWaterMark(agentDir, latest.updated_at);
|
|
@@ -51831,7 +51876,7 @@ function pushMemories(agentName, agentId, projectId, db) {
|
|
|
51831
51876
|
}
|
|
51832
51877
|
function pullMemories(agentName, conflictResolution = "prefer-newer", db) {
|
|
51833
51878
|
const agentDir = getAgentSyncDir(agentName);
|
|
51834
|
-
const inFile =
|
|
51879
|
+
const inFile = join5(agentDir, "memories.json");
|
|
51835
51880
|
if (!existsSync4(inFile)) {
|
|
51836
51881
|
return { pulled: 0, conflicts: 0 };
|
|
51837
51882
|
}
|
|
@@ -54330,12 +54375,12 @@ var gatherTrainingData = async (options = {}) => {
|
|
|
54330
54375
|
};
|
|
54331
54376
|
};
|
|
54332
54377
|
// src/lib/model-config.ts
|
|
54333
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as
|
|
54378
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
54334
54379
|
import { homedir as homedir4 } from "os";
|
|
54335
|
-
import { join as
|
|
54380
|
+
import { join as join6 } from "path";
|
|
54336
54381
|
var DEFAULT_MODEL = "gpt-4o-mini";
|
|
54337
|
-
var CONFIG_DIR =
|
|
54338
|
-
var CONFIG_PATH =
|
|
54382
|
+
var CONFIG_DIR = join6(homedir4(), ".hasna", "mementos");
|
|
54383
|
+
var CONFIG_PATH = join6(CONFIG_DIR, "config.json");
|
|
54339
54384
|
function readConfig() {
|
|
54340
54385
|
if (!existsSync5(CONFIG_PATH))
|
|
54341
54386
|
return {};
|
|
@@ -54350,7 +54395,7 @@ function writeConfig(config2) {
|
|
|
54350
54395
|
if (!existsSync5(CONFIG_DIR)) {
|
|
54351
54396
|
mkdirSync5(CONFIG_DIR, { recursive: true });
|
|
54352
54397
|
}
|
|
54353
|
-
|
|
54398
|
+
writeFileSync5(CONFIG_PATH, JSON.stringify(config2, null, 2) + `
|
|
54354
54399
|
`, "utf-8");
|
|
54355
54400
|
}
|
|
54356
54401
|
function getActiveModel() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../../src/lib/asmr/recall.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI1D,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,UAAU,CAAC,CAerB"}
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA4CpE,0FAA0F;AAC1F,eAAO,IAAI,SAAS,EAAE,SAAS,GAAG,IAAW,CAAC;AAqB9C,wBAAgB,WAAW,IAAI,SAAS,CA2EvC"}
|