@voltojs/memories 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/common/contract.d.ts +8 -0
- package/dist/common/contract.d.ts.map +1 -0
- package/dist/common/contract.js +116 -0
- package/dist/common/contract.js.map +1 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +2 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/score.d.ts +29 -0
- package/dist/common/score.d.ts.map +1 -0
- package/dist/common/score.js +88 -0
- package/dist/common/score.js.map +1 -0
- package/dist/file/index.d.ts +3 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +2 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/store.d.ts +25 -0
- package/dist/file/store.d.ts.map +1 -0
- package/dist/file/store.js +415 -0
- package/dist/file/store.js.map +1 -0
- package/dist/inmemory/index.d.ts +3 -0
- package/dist/inmemory/index.d.ts.map +1 -0
- package/dist/inmemory/index.js +2 -0
- package/dist/inmemory/index.js.map +1 -0
- package/dist/inmemory/memory.d.ts +39 -0
- package/dist/inmemory/memory.d.ts.map +1 -0
- package/dist/inmemory/memory.js +165 -0
- package/dist/inmemory/memory.js.map +1 -0
- package/package.json +43 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 volto contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MemoryStore } from "@voltojs/core";
|
|
2
|
+
/**
|
|
3
|
+
* Register the shared contract suite against a store factory. The factory is
|
|
4
|
+
* invoked once per case, so implementations can create an isolated store
|
|
5
|
+
* (fresh directory / fresh instance) every time.
|
|
6
|
+
*/
|
|
7
|
+
export declare function describeMemoryStoreContract(label: string, makeStore: () => MemoryStore | Promise<MemoryStore>): void;
|
|
8
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/common/contract.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAc9D;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAClD,IAAI,CA8GN"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared behavioral contract for MemoryStore implementations
|
|
3
|
+
* (@voltojs/memory-file and @voltojs/memory-inmemory).
|
|
4
|
+
*
|
|
5
|
+
* Test-only: this module imports vitest and must never be reachable from the
|
|
6
|
+
* package's runtime entry point. It pins the query-filter truth table from
|
|
7
|
+
* the core MemoryStore contract (spec 2026-10-20 memory-rag §4.1) so both
|
|
8
|
+
* implementations answer identically — including the tier-only branch and
|
|
9
|
+
* the empty-filter-object case, which regression history shows are easy to
|
|
10
|
+
* break silently in one implementation.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, expect, it } from "vitest";
|
|
13
|
+
const PROJECT_A = { kind: "project", projectId: "contract-a" };
|
|
14
|
+
const PROJECT_B = { kind: "project", projectId: "contract-b" };
|
|
15
|
+
const GLOBAL = { kind: "global" };
|
|
16
|
+
function entry(text, overrides) {
|
|
17
|
+
return { id: "", text, ...overrides };
|
|
18
|
+
}
|
|
19
|
+
function textsOf(entries) {
|
|
20
|
+
return entries.map((e) => e.text).sort();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Register the shared contract suite against a store factory. The factory is
|
|
24
|
+
* invoked once per case, so implementations can create an isolated store
|
|
25
|
+
* (fresh directory / fresh instance) every time.
|
|
26
|
+
*/
|
|
27
|
+
export function describeMemoryStoreContract(label, makeStore) {
|
|
28
|
+
describe(`${label} — MemoryStore contract`, () => {
|
|
29
|
+
it("no filter returns every entry (advanced/test use only)", async () => {
|
|
30
|
+
const store = await makeStore();
|
|
31
|
+
await store.save(entry("shared alpha", { scope: PROJECT_A }));
|
|
32
|
+
await store.save(entry("shared beta", { scope: GLOBAL }));
|
|
33
|
+
const all = await store.query("shared", 10);
|
|
34
|
+
expect(textsOf(all)).toEqual(["shared alpha", "shared beta"]);
|
|
35
|
+
});
|
|
36
|
+
it("{ projectId } returns project entries plus global entries", async () => {
|
|
37
|
+
const store = await makeStore();
|
|
38
|
+
await store.save(entry("shared alpha fact", { scope: PROJECT_A }));
|
|
39
|
+
await store.save(entry("shared gamma fact", { scope: GLOBAL }));
|
|
40
|
+
await store.save(entry("shared delta fact", { scope: PROJECT_B }));
|
|
41
|
+
const hits = await store.query("shared", 10, { projectId: "contract-a" });
|
|
42
|
+
expect(textsOf(hits)).toEqual(["shared alpha fact", "shared gamma fact"]);
|
|
43
|
+
});
|
|
44
|
+
it("{ projectId, includeGlobal: false } returns project entries only", async () => {
|
|
45
|
+
const store = await makeStore();
|
|
46
|
+
await store.save(entry("shared alpha fact", { scope: PROJECT_A }));
|
|
47
|
+
await store.save(entry("shared gamma fact", { scope: GLOBAL }));
|
|
48
|
+
const hits = await store.query("shared", 10, {
|
|
49
|
+
projectId: "contract-a",
|
|
50
|
+
includeGlobal: false,
|
|
51
|
+
});
|
|
52
|
+
expect(textsOf(hits)).toEqual(["shared alpha fact"]);
|
|
53
|
+
});
|
|
54
|
+
it("{ includeGlobal: true } without projectId returns global entries only", async () => {
|
|
55
|
+
const store = await makeStore();
|
|
56
|
+
await store.save(entry("shared alpha fact", { scope: PROJECT_A }));
|
|
57
|
+
await store.save(entry("shared gamma fact", { scope: GLOBAL }));
|
|
58
|
+
const hits = await store.query("shared", 10, { includeGlobal: true });
|
|
59
|
+
expect(textsOf(hits)).toEqual(["shared gamma fact"]);
|
|
60
|
+
});
|
|
61
|
+
it("{ includeGlobal: false } without projectId returns nothing — never any project", async () => {
|
|
62
|
+
const store = await makeStore();
|
|
63
|
+
await store.save(entry("shared alpha fact", { scope: PROJECT_A }));
|
|
64
|
+
await store.save(entry("shared gamma fact", { scope: GLOBAL }));
|
|
65
|
+
const hits = await store.query("shared", 10, { includeGlobal: false });
|
|
66
|
+
expect(hits).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
it("a tier-only filter returns global entries of that tier, never project entries", async () => {
|
|
69
|
+
const store = await makeStore();
|
|
70
|
+
await store.save(entry("shared gamma fact", { scope: GLOBAL, tier: "semantic" }));
|
|
71
|
+
// Regression pin: a project entry with the same tier must NOT surface
|
|
72
|
+
// through a tier-only filter (no project context exists).
|
|
73
|
+
await store.save(entry("shared alpha fact", { scope: PROJECT_A, tier: "semantic" }));
|
|
74
|
+
const hits = await store.query("shared", 10, { tier: "semantic" });
|
|
75
|
+
expect(textsOf(hits)).toEqual(["shared gamma fact"]);
|
|
76
|
+
});
|
|
77
|
+
it("an empty filter object returns nothing", async () => {
|
|
78
|
+
const store = await makeStore();
|
|
79
|
+
await store.save(entry("shared alpha fact", { scope: PROJECT_A }));
|
|
80
|
+
await store.save(entry("shared gamma fact", { scope: GLOBAL }));
|
|
81
|
+
const hits = await store.query("shared", 10, {});
|
|
82
|
+
expect(hits).toEqual([]);
|
|
83
|
+
});
|
|
84
|
+
it("a missing tier normalizes to semantic so tier filters match", async () => {
|
|
85
|
+
const store = await makeStore();
|
|
86
|
+
const id = await store.save(entry("shared tierless fact", { scope: PROJECT_A }));
|
|
87
|
+
const semantic = await store.query("shared", 10, {
|
|
88
|
+
projectId: "contract-a",
|
|
89
|
+
includeGlobal: false,
|
|
90
|
+
tier: "semantic",
|
|
91
|
+
});
|
|
92
|
+
expect(semantic).toHaveLength(1);
|
|
93
|
+
expect(semantic[0]?.id).toBe(id);
|
|
94
|
+
expect(semantic[0]?.tier).toBe("semantic");
|
|
95
|
+
const episodic = await store.query("shared", 10, {
|
|
96
|
+
projectId: "contract-a",
|
|
97
|
+
includeGlobal: false,
|
|
98
|
+
tier: "episodic",
|
|
99
|
+
});
|
|
100
|
+
expect(episodic).toEqual([]);
|
|
101
|
+
});
|
|
102
|
+
it("save with id '' returns the generated id and delete removes the entry", async () => {
|
|
103
|
+
const store = await makeStore();
|
|
104
|
+
const id = await store.save(entry("shared alpha fact", { scope: PROJECT_A }));
|
|
105
|
+
expect(id).toBeTruthy();
|
|
106
|
+
expect(await store.delete(id)).toBe(true);
|
|
107
|
+
const hits = await store.query("shared", 10, {
|
|
108
|
+
projectId: "contract-a",
|
|
109
|
+
includeGlobal: false,
|
|
110
|
+
});
|
|
111
|
+
expect(hits).toEqual([]);
|
|
112
|
+
expect(await store.delete(id)).toBe(false);
|
|
113
|
+
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C,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;YAExB,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE;gBAC3C,SAAS,EAAE,YAAY;gBACvB,aAAa,EAAE,KAAK;aACrB,CAAC,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACzB,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,0BAA0B,GAC3B,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,0BAA0B,GAC3B,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* score.ts — pure lexical scoring for memory retrieval.
|
|
3
|
+
*
|
|
4
|
+
* Zero dependencies, no I/O: every function here is a pure string
|
|
5
|
+
* transformation so both `@voltojs/memory-file` and `@voltojs/memory-inmemory`
|
|
6
|
+
* share one ranking implementation (spec §4.3, decision D4).
|
|
7
|
+
*/
|
|
8
|
+
/** Default per-scope live-entry cap (spec §4.3 / §7). */
|
|
9
|
+
export declare const DEFAULT_MEMORY_MAX_ENTRIES = 5000;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize text for matching: NFKC (folds full-width / ligature forms),
|
|
12
|
+
* lowercase, collapse whitespace runs (incl. NBSP) to single spaces, trim.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeMemoryText(text: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Tokenize a normalized-or-raw query:
|
|
17
|
+
* - ASCII/latin runs matching `[a-z0-9_]+` become one token each;
|
|
18
|
+
* - CJK runs become 2-char sliding windows (a lone char stays a single token).
|
|
19
|
+
*/
|
|
20
|
+
export declare function tokenizeMemoryQuery(text: string): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Score `text` against `query`.
|
|
23
|
+
*
|
|
24
|
+
* Total = sum over query tokens of `min(count, 3)` occurrences in the
|
|
25
|
+
* normalized text, plus +5 when the whole normalized query appears as a
|
|
26
|
+
* contiguous substring. Returns 0 when nothing matched or the query is empty.
|
|
27
|
+
*/
|
|
28
|
+
export declare function scoreMemoryText(query: string, text: string): number;
|
|
29
|
+
//# sourceMappingURL=score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"score.d.ts","sourceRoot":"","sources":["../../src/common/score.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yDAAyD;AACzD,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA0B1D;AAOD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAuBnE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* score.ts — pure lexical scoring for memory retrieval.
|
|
3
|
+
*
|
|
4
|
+
* Zero dependencies, no I/O: every function here is a pure string
|
|
5
|
+
* transformation so both `@voltojs/memory-file` and `@voltojs/memory-inmemory`
|
|
6
|
+
* share one ranking implementation (spec §4.3, decision D4).
|
|
7
|
+
*/
|
|
8
|
+
/** Default per-scope live-entry cap (spec §4.3 / §7). */
|
|
9
|
+
export const DEFAULT_MEMORY_MAX_ENTRIES = 5000;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize text for matching: NFKC (folds full-width / ligature forms),
|
|
12
|
+
* lowercase, collapse whitespace runs (incl. NBSP) to single spaces, trim.
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeMemoryText(text) {
|
|
15
|
+
return text
|
|
16
|
+
.normalize("NFKC")
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.replace(/\s+/g, " ")
|
|
19
|
+
.trim();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Tokenize a normalized-or-raw query:
|
|
23
|
+
* - ASCII/latin runs matching `[a-z0-9_]+` become one token each;
|
|
24
|
+
* - CJK runs become 2-char sliding windows (a lone char stays a single token).
|
|
25
|
+
*/
|
|
26
|
+
export function tokenizeMemoryQuery(text) {
|
|
27
|
+
const normalized = normalizeMemoryText(text);
|
|
28
|
+
const tokens = [];
|
|
29
|
+
// Match runs of word-ish ASCII plus CJK-ish scripts, then split by kind.
|
|
30
|
+
// The CJK class covers unified ideographs (incl. extension A and compat
|
|
31
|
+
// forms), kana, hangul syllables, and astral-plane ideographs (𠮷 etc.);
|
|
32
|
+
// runs of any of them become 2-char sliding windows below.
|
|
33
|
+
const runPattern = /[a-z0-9_]+|[-ヿ㐀-䶿一-鿿豈-가-\u{20000}-\u{2ffff}]+/gu;
|
|
34
|
+
for (const match of normalized.matchAll(runPattern)) {
|
|
35
|
+
const run = match[0];
|
|
36
|
+
// The ASCII class always matches a whole run, so no second test.
|
|
37
|
+
if (/^[a-z0-9_]+$/.test(run)) {
|
|
38
|
+
tokens.push(run);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const chars = Array.from(run);
|
|
42
|
+
if (chars.length === 1) {
|
|
43
|
+
tokens.push(chars[0]);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
for (let i = 0; i + 1 < chars.length; i += 1) {
|
|
47
|
+
tokens.push(`${chars[i]}${chars[i + 1]}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return tokens;
|
|
51
|
+
}
|
|
52
|
+
/** Per-token counted-occurrence cap (spec §4.3 rule 3). */
|
|
53
|
+
const TOKEN_HIT_CAP = 3;
|
|
54
|
+
/** Bonus applied when the normalized query is an exact substring of the text. */
|
|
55
|
+
const SUBSTRING_BONUS = 5;
|
|
56
|
+
/**
|
|
57
|
+
* Score `text` against `query`.
|
|
58
|
+
*
|
|
59
|
+
* Total = sum over query tokens of `min(count, 3)` occurrences in the
|
|
60
|
+
* normalized text, plus +5 when the whole normalized query appears as a
|
|
61
|
+
* contiguous substring. Returns 0 when nothing matched or the query is empty.
|
|
62
|
+
*/
|
|
63
|
+
export function scoreMemoryText(query, text) {
|
|
64
|
+
const normalizedQuery = normalizeMemoryText(query);
|
|
65
|
+
if (normalizedQuery === "")
|
|
66
|
+
return 0;
|
|
67
|
+
const normalizedText = normalizeMemoryText(text);
|
|
68
|
+
if (normalizedText === "")
|
|
69
|
+
return 0;
|
|
70
|
+
let score = 0;
|
|
71
|
+
for (const token of tokenizeMemoryQuery(normalizedQuery)) {
|
|
72
|
+
let count = 0;
|
|
73
|
+
let from = 0;
|
|
74
|
+
while (count < TOKEN_HIT_CAP) {
|
|
75
|
+
const at = normalizedText.indexOf(token, from);
|
|
76
|
+
if (at === -1)
|
|
77
|
+
break;
|
|
78
|
+
count += 1;
|
|
79
|
+
from = at + token.length;
|
|
80
|
+
}
|
|
81
|
+
score += count;
|
|
82
|
+
}
|
|
83
|
+
if (score > 0 && normalizedText.includes(normalizedQuery)) {
|
|
84
|
+
score += SUBSTRING_BONUS;
|
|
85
|
+
}
|
|
86
|
+
return score;
|
|
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AAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* store.ts — append-only JSONL `MemoryStore` scoped per project.
|
|
3
|
+
*
|
|
4
|
+
* One file per scope under `rootDir`: `<projectId>.jsonl` for project
|
|
5
|
+
* entries and `_global.jsonl` for global (or scope-less) entries. The
|
|
6
|
+
* directory is created with mode 0700 and files with 0600 so memory
|
|
7
|
+
* content (model-writable, potentially sensitive) never becomes
|
|
8
|
+
* world-readable (spec §7).
|
|
9
|
+
*
|
|
10
|
+
* Loading is lazy: the first query/save touching a scope parses the file
|
|
11
|
+
* into an in-memory `Map` and every later read is served from that index.
|
|
12
|
+
* Writes append one JSONL row and update the index; deletes append a
|
|
13
|
+
* tombstone row instead of rewriting (spec §4.3).
|
|
14
|
+
*/
|
|
15
|
+
import type { MemoryStore } from "@voltojs/core";
|
|
16
|
+
export interface FileMemoryStoreOptions {
|
|
17
|
+
/** Directory holding `<projectId>.jsonl` / `_global.jsonl`. */
|
|
18
|
+
rootDir: string;
|
|
19
|
+
/** Per-scope live-entry cap; oldest `createdAt` evicted first. */
|
|
20
|
+
maxEntriesPerScope?: number;
|
|
21
|
+
/** Injected clock used to backfill missing `createdAt` and generate ids. */
|
|
22
|
+
now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
export declare function createFileMemoryStore(opts: FileMemoryStoreOptions): MemoryStore;
|
|
25
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/file/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAIV,WAAW,EACZ,MAAM,eAAe,CAAC;AA+BvB,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AA4CD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,GAAG,WAAW,CA+X/E"}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* store.ts — append-only JSONL `MemoryStore` scoped per project.
|
|
3
|
+
*
|
|
4
|
+
* One file per scope under `rootDir`: `<projectId>.jsonl` for project
|
|
5
|
+
* entries and `_global.jsonl` for global (or scope-less) entries. The
|
|
6
|
+
* directory is created with mode 0700 and files with 0600 so memory
|
|
7
|
+
* content (model-writable, potentially sensitive) never becomes
|
|
8
|
+
* world-readable (spec §7).
|
|
9
|
+
*
|
|
10
|
+
* Loading is lazy: the first query/save touching a scope parses the file
|
|
11
|
+
* into an in-memory `Map` and every later read is served from that index.
|
|
12
|
+
* Writes append one JSONL row and update the index; deletes append a
|
|
13
|
+
* tombstone row instead of rewriting (spec §4.3).
|
|
14
|
+
*/
|
|
15
|
+
import * as fs from "node:fs/promises";
|
|
16
|
+
import * as path from "node:path";
|
|
17
|
+
import { scoreMemoryText, DEFAULT_MEMORY_MAX_ENTRIES, } from "../common/index.js";
|
|
18
|
+
const ROW_VERSION = 1;
|
|
19
|
+
/** A missing tier normalizes to this default (core MemoryEntry contract). */
|
|
20
|
+
const DEFAULT_TIER = "semantic";
|
|
21
|
+
const DEFAULT_MAX_ENTRIES_PER_SCOPE = DEFAULT_MEMORY_MAX_ENTRIES;
|
|
22
|
+
/** Compact when the op count exceeds max(1000, live * 3) (spec §4.3). */
|
|
23
|
+
const COMPACT_FLOOR = 1000;
|
|
24
|
+
const COMPACT_MULTIPLE = 3;
|
|
25
|
+
/** Root is created with 0700 and memory files with 0600 (spec §7). */
|
|
26
|
+
const DIR_MODE = 0o700;
|
|
27
|
+
const FILE_MODE = 0o600;
|
|
28
|
+
function isEnoent(err) {
|
|
29
|
+
return (err instanceof Error &&
|
|
30
|
+
"code" in err &&
|
|
31
|
+
err.code === "ENOENT");
|
|
32
|
+
}
|
|
33
|
+
/** Resolve a memory scope to its file name inside `rootDir`. */
|
|
34
|
+
function fileNameFor(scope) {
|
|
35
|
+
return scope.kind === "project"
|
|
36
|
+
? `${scope.projectId}.jsonl`
|
|
37
|
+
: "_global.jsonl";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A project id must be a single safe path segment: separators or `..`
|
|
41
|
+
* would write outside `rootDir` (same guard as the spill store).
|
|
42
|
+
*/
|
|
43
|
+
function isValidProjectId(projectId) {
|
|
44
|
+
if (projectId.trim() === "")
|
|
45
|
+
return false;
|
|
46
|
+
if (projectId === "." || projectId === "..")
|
|
47
|
+
return false;
|
|
48
|
+
// `_global` is reserved: it names the shared _global.jsonl file, so a
|
|
49
|
+
// project with that id would read and write the global scope — leaking
|
|
50
|
+
// its memories into every project's view and vice versa.
|
|
51
|
+
if (projectId === "_global")
|
|
52
|
+
return false;
|
|
53
|
+
return !projectId.includes("/") && !projectId.includes("\\");
|
|
54
|
+
}
|
|
55
|
+
function requireValidProjectId(projectId) {
|
|
56
|
+
if (!isValidProjectId(projectId)) {
|
|
57
|
+
throw new Error(`Invalid projectId: ${JSON.stringify(projectId)} — must be a non-empty path segment`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Treat a missing scope as global (spec §4.1). */
|
|
61
|
+
function scopeOf(entry) {
|
|
62
|
+
return entry.scope ?? { kind: "global" };
|
|
63
|
+
}
|
|
64
|
+
export function createFileMemoryStore(opts) {
|
|
65
|
+
const { rootDir, maxEntriesPerScope = DEFAULT_MAX_ENTRIES_PER_SCOPE, now = () => Date.now(), } = opts;
|
|
66
|
+
const indexes = new Map();
|
|
67
|
+
// In-flight cold loads, keyed like `indexes`. Each entry is removed as soon
|
|
68
|
+
// as the read settles (success or failure), so a failed load is retried on
|
|
69
|
+
// the next access instead of being cached as an error.
|
|
70
|
+
const loads = new Map();
|
|
71
|
+
// Serializes writes per scope so appends and compactions never interleave.
|
|
72
|
+
const queues = new Map();
|
|
73
|
+
let idCounter = 0;
|
|
74
|
+
function filePath(scope) {
|
|
75
|
+
return path.join(rootDir, fileNameFor(scope));
|
|
76
|
+
}
|
|
77
|
+
function generateId() {
|
|
78
|
+
// Deterministic within the single-process assumption (spec §9.6): the
|
|
79
|
+
// monotonic counter keeps same-millisecond ids apart, and the pid keeps
|
|
80
|
+
// two processes from colliding. No randomness, so tests can pin ids.
|
|
81
|
+
idCounter += 1;
|
|
82
|
+
return `mem-${process.pid}-${now()}-${idCounter}`;
|
|
83
|
+
}
|
|
84
|
+
async function ensureDir() {
|
|
85
|
+
await fs.mkdir(rootDir, { recursive: true, mode: DIR_MODE });
|
|
86
|
+
}
|
|
87
|
+
/** Parse one line; returns undefined for torn/invalid lines (spec §6). */
|
|
88
|
+
function parseRow(line) {
|
|
89
|
+
const trimmed = line.trim();
|
|
90
|
+
if (trimmed === "")
|
|
91
|
+
return undefined;
|
|
92
|
+
let parsed;
|
|
93
|
+
try {
|
|
94
|
+
parsed = JSON.parse(trimmed);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Torn/partial line — skip without failing the load (spec §6).
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
101
|
+
return undefined;
|
|
102
|
+
const candidate = parsed;
|
|
103
|
+
if (candidate.version !== ROW_VERSION) {
|
|
104
|
+
console.warn(`Skipping memory line with unknown version: ${JSON.stringify(candidate.version)}`);
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
if (candidate.op === "upsert") {
|
|
108
|
+
const entry = candidate.entry;
|
|
109
|
+
if (typeof entry === "object" &&
|
|
110
|
+
entry !== null &&
|
|
111
|
+
typeof entry.id === "string" &&
|
|
112
|
+
typeof entry.text === "string") {
|
|
113
|
+
return { version: ROW_VERSION, op: "upsert", entry: entry };
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
if (candidate.op === "delete") {
|
|
118
|
+
const id = candidate.id;
|
|
119
|
+
if (typeof id === "string") {
|
|
120
|
+
return { version: ROW_VERSION, op: "delete", id };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
async function readRows(target) {
|
|
126
|
+
let raw;
|
|
127
|
+
try {
|
|
128
|
+
raw = await fs.readFile(target, "utf-8");
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
if (isEnoent(err))
|
|
132
|
+
return [];
|
|
133
|
+
throw err;
|
|
134
|
+
}
|
|
135
|
+
const rows = [];
|
|
136
|
+
for (const line of raw.split("\n")) {
|
|
137
|
+
const row = parseRow(line);
|
|
138
|
+
if (row !== undefined)
|
|
139
|
+
rows.push(row);
|
|
140
|
+
}
|
|
141
|
+
return rows;
|
|
142
|
+
}
|
|
143
|
+
async function loadScope(scope) {
|
|
144
|
+
const key = fileNameFor(scope);
|
|
145
|
+
const cached = indexes.get(key);
|
|
146
|
+
if (cached !== undefined)
|
|
147
|
+
return cached;
|
|
148
|
+
// Concurrent cold-start readers share one in-flight read. Without this, a
|
|
149
|
+
// query and a save hitting a fresh scope each build their own index from
|
|
150
|
+
// the same file; whichever `indexes.set` lands last overwrites the other
|
|
151
|
+
// one's applied writes, making them invisible in memory and — once a later
|
|
152
|
+
// compact rewrites the file from the stale map — lost on disk.
|
|
153
|
+
const inflight = loads.get(key);
|
|
154
|
+
if (inflight !== undefined)
|
|
155
|
+
return inflight;
|
|
156
|
+
const loading = readRows(filePath(scope)).then((rows) => {
|
|
157
|
+
const entries = new Map();
|
|
158
|
+
for (const row of rows) {
|
|
159
|
+
if (row.op === "upsert") {
|
|
160
|
+
entries.set(row.entry.id, row.entry);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
entries.delete(row.id);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const index = { entries, ops: rows.length };
|
|
167
|
+
indexes.set(key, index);
|
|
168
|
+
loads.delete(key);
|
|
169
|
+
return index;
|
|
170
|
+
}, (err) => {
|
|
171
|
+
loads.delete(key);
|
|
172
|
+
throw err;
|
|
173
|
+
});
|
|
174
|
+
loads.set(key, loading);
|
|
175
|
+
return loading;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Evict entries beyond the per-scope cap, oldest `createdAt` first.
|
|
179
|
+
* Returns the evicted ids so the caller can persist tombstones — an
|
|
180
|
+
* in-memory-only eviction would resurface on the next reload.
|
|
181
|
+
*/
|
|
182
|
+
function enforceCap(index) {
|
|
183
|
+
if (index.entries.size <= maxEntriesPerScope)
|
|
184
|
+
return [];
|
|
185
|
+
const sorted = [...index.entries.values()].sort((a, b) => (a.createdAt ?? 0) - (b.createdAt ?? 0));
|
|
186
|
+
const overflow = index.entries.size - maxEntriesPerScope;
|
|
187
|
+
const victims = [];
|
|
188
|
+
for (let i = 0; i < overflow; i += 1) {
|
|
189
|
+
const victim = sorted[i];
|
|
190
|
+
if (victim !== undefined) {
|
|
191
|
+
index.entries.delete(victim.id);
|
|
192
|
+
victims.push(victim.id);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return victims;
|
|
196
|
+
}
|
|
197
|
+
/** Rewrite the scope file as one upsert row per live entry (atomic rename). */
|
|
198
|
+
async function compact(scope, index) {
|
|
199
|
+
const target = filePath(scope);
|
|
200
|
+
// Compaction runs inside the per-scope write queue, so one pid-stamped
|
|
201
|
+
// tmp name is unique without randomness; the catch removes it when the
|
|
202
|
+
// rename never happened so a failed compaction leaves no orphan behind.
|
|
203
|
+
const tmp = `${target}.tmp.${process.pid}`;
|
|
204
|
+
const lines = [...index.entries.values()].map((entry) => JSON.stringify({ version: ROW_VERSION, op: "upsert", entry }));
|
|
205
|
+
const text = lines.length > 0 ? `${lines.join("\n")}\n` : "";
|
|
206
|
+
await ensureDir();
|
|
207
|
+
try {
|
|
208
|
+
await fs.writeFile(tmp, text, { encoding: "utf-8", mode: FILE_MODE });
|
|
209
|
+
await fs.rename(tmp, target);
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
await fs.rm(tmp, { force: true }).catch(() => undefined);
|
|
213
|
+
throw err;
|
|
214
|
+
}
|
|
215
|
+
index.ops = index.entries.size;
|
|
216
|
+
}
|
|
217
|
+
/** Append one or more rows, then refresh the in-memory index and cap/compaction. */
|
|
218
|
+
async function appendRows(scope, rows) {
|
|
219
|
+
if (rows.length === 0)
|
|
220
|
+
return;
|
|
221
|
+
const key = fileNameFor(scope);
|
|
222
|
+
const previous = queues.get(key) ?? Promise.resolve();
|
|
223
|
+
const task = async () => {
|
|
224
|
+
const index = await loadScope(scope);
|
|
225
|
+
// Apply the batch to a copy and publish it only after the append has
|
|
226
|
+
// reached disk (spec §4.3 write order: append, then update the index).
|
|
227
|
+
// Mutating the live index first would leave phantom entries — or
|
|
228
|
+
// resurrected eviction victims — in memory whenever the append fails,
|
|
229
|
+
// and a later recall would return rows that were never persisted.
|
|
230
|
+
const nextEntries = new Map(index.entries);
|
|
231
|
+
let nextOps = index.ops;
|
|
232
|
+
// Track evictions across the batch: applying the upsert first may
|
|
233
|
+
// push the scope over the cap, and its victims must reach disk as
|
|
234
|
+
// delete rows in this same append, or a reload resurrects them.
|
|
235
|
+
let victims = [];
|
|
236
|
+
for (const row of rows) {
|
|
237
|
+
if (row.op === "upsert") {
|
|
238
|
+
nextEntries.set(row.entry.id, row.entry);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
nextEntries.delete(row.id);
|
|
242
|
+
}
|
|
243
|
+
nextOps += 1;
|
|
244
|
+
victims = victims.concat(enforceCap({ entries: nextEntries }));
|
|
245
|
+
}
|
|
246
|
+
const persisted = rows.concat(victims.map((id) => ({ version: ROW_VERSION, op: "delete", id })));
|
|
247
|
+
const text = persisted.map((row) => `${JSON.stringify(row)}\n`).join("");
|
|
248
|
+
await ensureDir();
|
|
249
|
+
await fs.appendFile(filePath(scope), text, {
|
|
250
|
+
encoding: "utf-8",
|
|
251
|
+
mode: FILE_MODE,
|
|
252
|
+
});
|
|
253
|
+
// The write reached disk: publish the new view.
|
|
254
|
+
index.entries = nextEntries;
|
|
255
|
+
index.ops = nextOps + persisted.length - rows.length;
|
|
256
|
+
if (index.ops > Math.max(COMPACT_FLOOR, index.entries.size * COMPACT_MULTIPLE)) {
|
|
257
|
+
await compact(scope, index);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const next = previous.then(task, task);
|
|
261
|
+
queues.set(key, next.catch(() => undefined));
|
|
262
|
+
await next;
|
|
263
|
+
}
|
|
264
|
+
/** Append a single row (see {@link appendRows}). */
|
|
265
|
+
async function appendRow(scope, row) {
|
|
266
|
+
await appendRows(scope, [row]);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Every scope on disk: global plus every project file that has been
|
|
270
|
+
* loaded or already exists under `rootDir` (the no-filter query path
|
|
271
|
+
* must see every entry, spec §4.1).
|
|
272
|
+
*/
|
|
273
|
+
async function allScopes() {
|
|
274
|
+
const scopes = [{ kind: "global" }];
|
|
275
|
+
const seen = new Set(["_global.jsonl"]);
|
|
276
|
+
for (const key of indexes.keys()) {
|
|
277
|
+
if (seen.has(key))
|
|
278
|
+
continue;
|
|
279
|
+
seen.add(key);
|
|
280
|
+
scopes.push({ kind: "project", projectId: key.replace(/\.jsonl$/, "") });
|
|
281
|
+
}
|
|
282
|
+
const dirents = await fs.readdir(rootDir).catch((err) => {
|
|
283
|
+
// A missing root is the normal first-use case; anything else (EACCES
|
|
284
|
+
// etc.) would silently truncate the scope list, so surface it.
|
|
285
|
+
if (!isEnoent(err)) {
|
|
286
|
+
console.warn(`memory-file: cannot list ${rootDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
287
|
+
}
|
|
288
|
+
return [];
|
|
289
|
+
});
|
|
290
|
+
for (const name of dirents) {
|
|
291
|
+
if (!name.endsWith(".jsonl") || seen.has(name))
|
|
292
|
+
continue;
|
|
293
|
+
seen.add(name);
|
|
294
|
+
scopes.push({ kind: "project", projectId: name.replace(/\.jsonl$/, "") });
|
|
295
|
+
}
|
|
296
|
+
return scopes;
|
|
297
|
+
}
|
|
298
|
+
/** Resolve which scopes a filter reads (spec §4.1). */
|
|
299
|
+
async function scopesForFilter(filter) {
|
|
300
|
+
if (filter === undefined) {
|
|
301
|
+
// No filter: every entry (advanced/test use only).
|
|
302
|
+
return allScopes();
|
|
303
|
+
}
|
|
304
|
+
if (filter.projectId !== undefined) {
|
|
305
|
+
requireValidProjectId(filter.projectId);
|
|
306
|
+
const project = {
|
|
307
|
+
kind: "project",
|
|
308
|
+
projectId: filter.projectId,
|
|
309
|
+
};
|
|
310
|
+
if (filter.includeGlobal === false)
|
|
311
|
+
return [project];
|
|
312
|
+
return [project, { kind: "global" }];
|
|
313
|
+
}
|
|
314
|
+
if (filter.includeGlobal === true)
|
|
315
|
+
return [{ kind: "global" }];
|
|
316
|
+
// A tier-only filter has no project context: global only, never every
|
|
317
|
+
// project. includeGlobal:false (or an empty filter object) returns nothing.
|
|
318
|
+
if (filter.includeGlobal === undefined && filter.tier !== undefined) {
|
|
319
|
+
return [{ kind: "global" }];
|
|
320
|
+
}
|
|
321
|
+
return [];
|
|
322
|
+
}
|
|
323
|
+
async function collectEntries(scopes) {
|
|
324
|
+
const collected = [];
|
|
325
|
+
const seenScopes = new Set();
|
|
326
|
+
for (const scope of scopes) {
|
|
327
|
+
const key = fileNameFor(scope);
|
|
328
|
+
if (seenScopes.has(key))
|
|
329
|
+
continue;
|
|
330
|
+
seenScopes.add(key);
|
|
331
|
+
const index = await loadScope(scope);
|
|
332
|
+
collected.push(...index.entries.values());
|
|
333
|
+
}
|
|
334
|
+
return collected;
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
async save(input) {
|
|
338
|
+
const scope = scopeOf(input);
|
|
339
|
+
if (scope.kind === "project")
|
|
340
|
+
requireValidProjectId(scope.projectId);
|
|
341
|
+
const id = input.id === "" ? generateId() : input.id;
|
|
342
|
+
const stored = {
|
|
343
|
+
...input,
|
|
344
|
+
id,
|
|
345
|
+
createdAt: input.createdAt ?? now(),
|
|
346
|
+
scope,
|
|
347
|
+
// Normalize the missing tier to the default so both stores answer a
|
|
348
|
+
// tier-filtered query identically for tier-less entries (core
|
|
349
|
+
// MemoryEntry contract).
|
|
350
|
+
tier: input.tier ?? DEFAULT_TIER,
|
|
351
|
+
};
|
|
352
|
+
await appendRow(scope, { version: ROW_VERSION, op: "upsert", entry: stored });
|
|
353
|
+
return id;
|
|
354
|
+
},
|
|
355
|
+
async query(text, k = 10, filter) {
|
|
356
|
+
const scopes = await scopesForFilter(filter);
|
|
357
|
+
if (scopes.length === 0)
|
|
358
|
+
return [];
|
|
359
|
+
const candidates = await collectEntries(scopes);
|
|
360
|
+
const tier = filter?.tier;
|
|
361
|
+
const scored = candidates
|
|
362
|
+
// Entries persisted before tier normalization lack the field; treat
|
|
363
|
+
// them as the default tier (same rule as save).
|
|
364
|
+
.filter((entry) => tier === undefined || (entry.tier ?? DEFAULT_TIER) === tier)
|
|
365
|
+
.map((entry) => ({ entry, score: scoreMemoryText(text, entry.text) }))
|
|
366
|
+
.filter((r) => r.score > 0)
|
|
367
|
+
.sort((a, b) => b.score - a.score ||
|
|
368
|
+
(b.entry.createdAt ?? 0) - (a.entry.createdAt ?? 0));
|
|
369
|
+
// Return copies: handing out the index's own objects would let a
|
|
370
|
+
// caller mutate the in-memory view (the inmemory store copies too).
|
|
371
|
+
return scored.slice(0, k).map((r) => ({ ...r.entry }));
|
|
372
|
+
},
|
|
373
|
+
async delete(id) {
|
|
374
|
+
// The id may live in any scope: check every known scope plus both
|
|
375
|
+
// lazily-loaded candidates so a tombstone lands in the right file.
|
|
376
|
+
const scopes = [{ kind: "global" }];
|
|
377
|
+
for (const key of indexes.keys()) {
|
|
378
|
+
if (key !== "_global.jsonl") {
|
|
379
|
+
scopes.push({ kind: "project", projectId: key.replace(/\.jsonl$/, "") });
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
for (const scope of scopes) {
|
|
383
|
+
const index = await loadScope(scope);
|
|
384
|
+
if (index.entries.has(id)) {
|
|
385
|
+
await appendRow(scope, { version: ROW_VERSION, op: "delete", id });
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// Unknown id: also probe existing project files not yet loaded.
|
|
390
|
+
const dirents = await fs.readdir(rootDir).catch((err) => {
|
|
391
|
+
// A missing root is the normal first-use case; anything else (EACCES
|
|
392
|
+
// etc.) would silently truncate the scope list, so surface it.
|
|
393
|
+
if (!isEnoent(err)) {
|
|
394
|
+
console.warn(`memory-file: cannot list ${rootDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
395
|
+
}
|
|
396
|
+
return [];
|
|
397
|
+
});
|
|
398
|
+
for (const name of dirents) {
|
|
399
|
+
if (!name.endsWith(".jsonl") || name === "_global.jsonl")
|
|
400
|
+
continue;
|
|
401
|
+
const scope = {
|
|
402
|
+
kind: "project",
|
|
403
|
+
projectId: name.replace(/\.jsonl$/, ""),
|
|
404
|
+
};
|
|
405
|
+
const index = await loadScope(scope);
|
|
406
|
+
if (index.entries.has(id)) {
|
|
407
|
+
await appendRow(scope, { version: ROW_VERSION, op: "delete", id });
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
//# sourceM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F,CAAC;gBACJ,CAAC;gBACD,OAAO,EAAc,CAAC;YACxB,CAAC,CAAC,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,eAAe;oBAAE,SAAS;gBACnE,MAAM,KAAK,GAAgB;oBACzB,IAAI,EAAE,SAAS;oBACf,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;iBACxC,CAAC;gBACF,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC1B,MAAM,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;oBACnE,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inmemory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/inmemory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory layered MemoryStore implementation.
|
|
3
|
+
*
|
|
4
|
+
* Implements the `MemoryStore` port with lexical scoring (spec §4.1/§4.3):
|
|
5
|
+
* - query filters by scope / tier first, then ranks with `scoreMemoryText`
|
|
6
|
+
* from `@voltojs/memory-common`, returning only entries with score > 0.
|
|
7
|
+
* - A missing entry `scope` is treated as global (spec §4.1).
|
|
8
|
+
* - `id: ""` is replaced by a store-generated id; missing `createdAt` is
|
|
9
|
+
* backfilled from the injected clock.
|
|
10
|
+
*
|
|
11
|
+
* Tier bookkeeping uses the public `MemoryEntry.tier` field plus a local
|
|
12
|
+
* fallback tier for entries saved before tiering was explicit. The local
|
|
13
|
+
* `MemoryTier` union also carries "working", a local-only concept that the
|
|
14
|
+
* core port does not define (spec §4.1 core tier is episodic / semantic).
|
|
15
|
+
*/
|
|
16
|
+
import type { MemoryStore, MemoryEntry, Embedder } from "@voltojs/core";
|
|
17
|
+
export type MemoryTier = "working" | "episodic" | "semantic";
|
|
18
|
+
export interface InMemoryMemoryStoreOptions {
|
|
19
|
+
/** Embedder for semantic layer similarity search (optional override) */
|
|
20
|
+
embedder?: Embedder;
|
|
21
|
+
/** Default tier for save operations (default: "semantic") */
|
|
22
|
+
defaultTier?: MemoryTier;
|
|
23
|
+
/** Injected clock used to backfill missing `createdAt` (default Date.now). */
|
|
24
|
+
now?: () => number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* In-process store with no entry cap: it holds whatever the caller saved in
|
|
28
|
+
* this process only, and no production wiring uses it as a durable memory
|
|
29
|
+
* (the file store owns persistence and enforces DEFAULT_MEMORY_MAX_ENTRIES).
|
|
30
|
+
*/
|
|
31
|
+
export declare function createInMemoryMemoryStore(opts?: InMemoryMemoryStoreOptions): MemoryStore & {
|
|
32
|
+
/** Query by tier (optional filter) */
|
|
33
|
+
queryByTier(text: string, k: number, tier?: MemoryTier): Promise<MemoryEntry[]>;
|
|
34
|
+
/** Save with explicit tier */
|
|
35
|
+
saveWithTier(entry: Omit<MemoryEntry, "id"> & {
|
|
36
|
+
id?: string;
|
|
37
|
+
}, tier: MemoryTier): Promise<string>;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/inmemory/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAGX,QAAQ,EACT,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAE7D,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAQD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,GAAE,0BAA+B,GACpC,WAAW,GAAG;IACf,sCAAsC;IACtC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAChF,8BAA8B;IAC9B,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnG,CAqKA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory layered MemoryStore implementation.
|
|
3
|
+
*
|
|
4
|
+
* Implements the `MemoryStore` port with lexical scoring (spec §4.1/§4.3):
|
|
5
|
+
* - query filters by scope / tier first, then ranks with `scoreMemoryText`
|
|
6
|
+
* from `@voltojs/memory-common`, returning only entries with score > 0.
|
|
7
|
+
* - A missing entry `scope` is treated as global (spec §4.1).
|
|
8
|
+
* - `id: ""` is replaced by a store-generated id; missing `createdAt` is
|
|
9
|
+
* backfilled from the injected clock.
|
|
10
|
+
*
|
|
11
|
+
* Tier bookkeeping uses the public `MemoryEntry.tier` field plus a local
|
|
12
|
+
* fallback tier for entries saved before tiering was explicit. The local
|
|
13
|
+
* `MemoryTier` union also carries "working", a local-only concept that the
|
|
14
|
+
* core port does not define (spec §4.1 core tier is episodic / semantic).
|
|
15
|
+
*/
|
|
16
|
+
import { scoreMemoryText } from "../common/index.js";
|
|
17
|
+
/**
|
|
18
|
+
* In-process store with no entry cap: it holds whatever the caller saved in
|
|
19
|
+
* this process only, and no production wiring uses it as a durable memory
|
|
20
|
+
* (the file store owns persistence and enforces DEFAULT_MEMORY_MAX_ENTRIES).
|
|
21
|
+
*/
|
|
22
|
+
export function createInMemoryMemoryStore(opts = {}) {
|
|
23
|
+
const { embedder, defaultTier = "semantic", now = () => Date.now(), } = opts;
|
|
24
|
+
const entries = new Map();
|
|
25
|
+
let idCounter = 0;
|
|
26
|
+
function generateId() {
|
|
27
|
+
idCounter++;
|
|
28
|
+
return `mem-${idCounter}-${now()}`;
|
|
29
|
+
}
|
|
30
|
+
/** Backfill missing createdAt from the injected clock (spec §4.1). */
|
|
31
|
+
function withCreatedAt(entry) {
|
|
32
|
+
return entry.createdAt ?? now();
|
|
33
|
+
}
|
|
34
|
+
async function storeEntry(input, tier) {
|
|
35
|
+
const id = input.id && input.id !== "" ? input.id : generateId();
|
|
36
|
+
const stored = {
|
|
37
|
+
...input,
|
|
38
|
+
id,
|
|
39
|
+
createdAt: withCreatedAt({ ...input, id }),
|
|
40
|
+
tier: input.tier ?? (tier === "working" ? undefined : tier),
|
|
41
|
+
_tier: tier,
|
|
42
|
+
};
|
|
43
|
+
entries.set(id, stored);
|
|
44
|
+
// Compute embedding for semantic layer if embedder is available
|
|
45
|
+
if (tier === "semantic" && embedder && input.text) {
|
|
46
|
+
try {
|
|
47
|
+
const embeddings = await embedder.embed([input.text]);
|
|
48
|
+
if (embeddings[0]) {
|
|
49
|
+
stored._embedding = embeddings[0];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Embedding failure is non-fatal — entry is still saved
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return id;
|
|
57
|
+
}
|
|
58
|
+
/** Scope of an entry, treating a missing scope as global (spec §4.1). */
|
|
59
|
+
function scopeOf(entry) {
|
|
60
|
+
return entry.scope ?? { kind: "global" };
|
|
61
|
+
}
|
|
62
|
+
/** Whether an entry passes the §4.1 scope branches of `filter`. */
|
|
63
|
+
function matchesScope(entry, filter) {
|
|
64
|
+
if (filter === undefined)
|
|
65
|
+
return true;
|
|
66
|
+
const scope = scopeOf(entry);
|
|
67
|
+
if (filter.projectId !== undefined) {
|
|
68
|
+
if (filter.includeGlobal === false) {
|
|
69
|
+
return scope.kind === "project" && scope.projectId === filter.projectId;
|
|
70
|
+
}
|
|
71
|
+
return (scope.kind === "global" ||
|
|
72
|
+
scope.projectId === filter.projectId);
|
|
73
|
+
}
|
|
74
|
+
if (filter.includeGlobal === true)
|
|
75
|
+
return scope.kind === "global";
|
|
76
|
+
// A tier-only filter still has no project context: search global only,
|
|
77
|
+
// never every project (spec §4.1). An empty filter object returns nothing.
|
|
78
|
+
if (filter.includeGlobal === undefined && filter.tier !== undefined) {
|
|
79
|
+
return scope.kind === "global";
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/** Resolve the tier used for filtering (public field wins, local fallback). */
|
|
84
|
+
function tierOf(entry) {
|
|
85
|
+
// Narrowed to core tiers: entries saved via save() / saveWithTier() write
|
|
86
|
+
// both fields, and "working" never reaches the public `tier` field.
|
|
87
|
+
const publicTier = entry.tier;
|
|
88
|
+
return publicTier ?? entry._tier;
|
|
89
|
+
}
|
|
90
|
+
/** Filter by scope / tier, score lexically, keep score > 0 (spec §4.3). */
|
|
91
|
+
async function queryFiltered(text, k, filter, localTier) {
|
|
92
|
+
const tier = filter?.tier ?? localTier;
|
|
93
|
+
const candidates = [...entries.values()].filter((e) => matchesScope(e, filter) && (tier === undefined || tierOf(e) === tier));
|
|
94
|
+
// Optional embedding path: only used when every candidate has an
|
|
95
|
+
// embedding; otherwise fall through to the shared lexical scorer.
|
|
96
|
+
if (embedder && candidates.length > 0 && candidates.every((e) => e._embedding)) {
|
|
97
|
+
try {
|
|
98
|
+
const queryEmbeddings = await embedder.embed([text]);
|
|
99
|
+
const queryVec = queryEmbeddings[0];
|
|
100
|
+
if (queryVec) {
|
|
101
|
+
return candidates
|
|
102
|
+
.map((e) => ({
|
|
103
|
+
entry: e,
|
|
104
|
+
score: e._embedding ? cosineSimilarity(queryVec, e._embedding) : 0,
|
|
105
|
+
}))
|
|
106
|
+
.filter((r) => r.score > 0)
|
|
107
|
+
.sort((a, b) => b.score - a.score ||
|
|
108
|
+
(b.entry.createdAt ?? 0) - (a.entry.createdAt ?? 0))
|
|
109
|
+
.slice(0, k)
|
|
110
|
+
.map((item) => stripInternal(item.entry));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Fall through to lexical scoring
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return candidates
|
|
118
|
+
.map((entry) => ({ entry, score: scoreMemoryText(text, entry.text) }))
|
|
119
|
+
.filter((r) => r.score > 0)
|
|
120
|
+
.sort((a, b) => b.score - a.score ||
|
|
121
|
+
(b.entry.createdAt ?? 0) - (a.entry.createdAt ?? 0))
|
|
122
|
+
.slice(0, k)
|
|
123
|
+
.map((r) => stripInternal(r.entry));
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
async save(entry) {
|
|
127
|
+
return storeEntry(entry, entry.tier ?? defaultTier);
|
|
128
|
+
},
|
|
129
|
+
async saveWithTier(entry, tier) {
|
|
130
|
+
return storeEntry(entry, tier);
|
|
131
|
+
},
|
|
132
|
+
async query(text, k = 10, filter) {
|
|
133
|
+
return queryFiltered(text, k, filter);
|
|
134
|
+
},
|
|
135
|
+
async queryByTier(text, k, tier) {
|
|
136
|
+
return queryFiltered(text, k, undefined, tier);
|
|
137
|
+
},
|
|
138
|
+
async delete(id) {
|
|
139
|
+
return entries.delete(id);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function cosineSimilarity(a, b) {
|
|
144
|
+
const len = Math.min(a.length, b.length);
|
|
145
|
+
let dot = 0;
|
|
146
|
+
let normA = 0;
|
|
147
|
+
let normB = 0;
|
|
148
|
+
for (let i = 0; i < len; i++) {
|
|
149
|
+
const ai = a[i] ?? 0;
|
|
150
|
+
const bi = b[i] ?? 0;
|
|
151
|
+
dot += ai * bi;
|
|
152
|
+
normA += ai * ai;
|
|
153
|
+
normB += bi * bi;
|
|
154
|
+
}
|
|
155
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
156
|
+
return denominator === 0 ? 0 : dot / denominator;
|
|
157
|
+
}
|
|
158
|
+
/** Strip internal _tier/_embedding fields before returning to caller */
|
|
159
|
+
function stripInternal(entry) {
|
|
160
|
+
const { _tier: _t, _embedding: _e, ...rest } = entry;
|
|
161
|
+
void _t;
|
|
162
|
+
void _e;
|
|
163
|
+
return rest;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/inmemory/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAmBrD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAmC,EAAE;IAOrC,MAAM,EACJ,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GACvB,GAAG,IAAI,CAAC;IACT,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC/C,IAAI,SAAS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,CAAC;IACrD,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltojs/memories",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/common/index.js",
|
|
6
|
+
"types": "./dist/common/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./common": {
|
|
9
|
+
"types": "./dist/common/index.d.ts",
|
|
10
|
+
"import": "./dist/common/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./file": {
|
|
13
|
+
"types": "./dist/file/index.d.ts",
|
|
14
|
+
"import": "./dist/file/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./inmemory": {
|
|
17
|
+
"types": "./dist/inmemory/index.d.ts",
|
|
18
|
+
"import": "./dist/inmemory/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"!dist/**/__tests__"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/voltojs/volto.git"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@voltojs/core": "^0.2.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc --build",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"lint": "eslint src/",
|
|
44
|
+
"test": "vitest run"
|
|
45
|
+
}
|
|
6
46
|
}
|
package/README.md
DELETED