@melandlabs/memory-store 0.2.7 → 0.3.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/dist/config-2Q092MUz.d.ts +470 -0
- package/dist/http.d.ts +1 -1
- package/dist/http.js +367 -98
- package/dist/index.d.ts +3 -3
- package/dist/index.js +724 -99
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +370 -98
- package/dist/search/unified-search.d.ts +3 -101
- package/dist/search/unified-search.js +368 -99
- package/dist/server/cli-http.js +376 -98
- package/dist/server/cli-mcp.js +379 -98
- package/dist/server/cli-shared.d.ts +1 -1
- package/dist/server/cli-shared.js +10 -1
- package/dist/storage/postgres-raw-message-factory.d.ts +1 -1
- package/dist/storage/raw-message-store.d.ts +1 -1
- package/dist/storage/raw-message-store.js +1 -1
- package/dist/storage/sqlite-raw-message-store.d.ts +1 -1
- package/dist/storage/sqlite-vector-index.d.ts +1 -1
- package/package.json +10 -9
- package/dist/config-Ll6ktm4D.d.ts +0 -183
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melandlabs/memory-store",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
61
61
|
"hono": "^4.6.14",
|
|
62
62
|
"zod": "^4.3.6",
|
|
63
|
-
"@melandlabs/ai": "0.
|
|
64
|
-
"@melandlabs/sqlite": "0.
|
|
65
|
-
"@melandlabs/
|
|
66
|
-
"@melandlabs/
|
|
63
|
+
"@melandlabs/ai": "0.3.0",
|
|
64
|
+
"@melandlabs/sqlite": "0.3.0",
|
|
65
|
+
"@melandlabs/rag": "0.2.2",
|
|
66
|
+
"@melandlabs/shared": "0.3.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@melandlabs/ai-rag": "0.2.
|
|
70
|
-
"@melandlabs/indexeddb": "0.
|
|
69
|
+
"@melandlabs/ai-rag": "0.2.4",
|
|
70
|
+
"@melandlabs/indexeddb": "0.3.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependenciesMeta": {
|
|
73
73
|
"@melandlabs/ai-rag": {
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@types/node": "^22.13.10",
|
|
82
82
|
"typescript": "^5.6.3",
|
|
83
|
-
"@melandlabs/config": "0.
|
|
84
|
-
"@melandlabs/ai-rag": "0.2.
|
|
83
|
+
"@melandlabs/config": "0.3.0",
|
|
84
|
+
"@melandlabs/ai-rag": "0.2.4"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build": "tsup",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"lint": "biome check .",
|
|
90
90
|
"lint:fix": "biome check --write .",
|
|
91
91
|
"test": "vitest run",
|
|
92
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
92
93
|
"test:watch": "vitest"
|
|
93
94
|
}
|
|
94
95
|
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory store configuration — injected by the host application.
|
|
3
|
-
*
|
|
4
|
-
* The memory-store package is intentionally decoupled from the
|
|
5
|
-
* opencontext web app's database layer. Each consumer wires up its own
|
|
6
|
-
* implementation of the `db` contract.
|
|
7
|
-
*
|
|
8
|
-
* Backend selection is env-var driven, not host-injected:
|
|
9
|
-
* - Default: local SQLite at `~/.opencontext/memory/store.db`
|
|
10
|
-
* (override with `MEMORY_STORE_DB_PATH`).
|
|
11
|
-
* - Set `OPENCONTEXT_MEMORY_STORE_BACKEND=postgres` to opt into the
|
|
12
|
-
* host's registered Postgres factory (call `registerPostgresFactory`
|
|
13
|
-
* at startup). SQLite stays as the default in every other case.
|
|
14
|
-
*
|
|
15
|
-
* Required for raw-message persistence:
|
|
16
|
-
* - `db.getDb()` — returns a Drizzle DB handle (Postgres path only)
|
|
17
|
-
*
|
|
18
|
-
* Required for vector indexing:
|
|
19
|
-
* - one of `vector.sqlite-vec.dbPath` or `vector.chroma.url`
|
|
20
|
-
*
|
|
21
|
-
* Required for unified semantic search:
|
|
22
|
-
* - `unified.embedQuery` — the embedding provider's query embedder
|
|
23
|
-
*
|
|
24
|
-
* Optional for cross-source unified search:
|
|
25
|
-
* - `unified.searchKnowledge` — RAG over uploaded documents
|
|
26
|
-
* - `unified.searchInsights` — over extracted insights
|
|
27
|
-
*
|
|
28
|
-
* If `unified.*` are absent, the SDK still works but the corresponding
|
|
29
|
-
* sources in `searchUnifiedMemory` will return empty results with a
|
|
30
|
-
* warning — fine for a standalone memory daemon.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
interface MemoryStoreDb {
|
|
34
|
-
/** Resolve the active Drizzle DB handle. Must be server-side. */
|
|
35
|
-
getDb(): unknown;
|
|
36
|
-
/** Whether the DB has finished initializing (optional, for startup gating). */
|
|
37
|
-
isDbInitialized?(): boolean;
|
|
38
|
-
/** Initialize the DB (optional, called by `createMemoryStore` if present). */
|
|
39
|
-
initDb?(): unknown;
|
|
40
|
-
/**
|
|
41
|
-
* Drizzle table references for the postgres backend. Required when
|
|
42
|
-
* running outside Tauri mode without a registered factory. The host
|
|
43
|
-
* application owns the actual schema.
|
|
44
|
-
*/
|
|
45
|
-
tables?: {
|
|
46
|
-
rawMessages?: unknown;
|
|
47
|
-
memorySummaries?: unknown;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Placeholder for the historical host-injected environment. The fields
|
|
52
|
-
* it used to expose (`isTauriMode`, `getTauriDbPath`, `getTauriDataDir`)
|
|
53
|
-
* were Tauri-specific and have been removed. Backend selection is now
|
|
54
|
-
* driven entirely by the `OPENCONTEXT_MEMORY_STORE_BACKEND` env var.
|
|
55
|
-
*
|
|
56
|
-
* The interface is kept (empty) so existing `env?: MemoryStoreEnv`
|
|
57
|
-
* parameters on the public surface still type-check, but new code
|
|
58
|
-
* should not need to construct a value of this type.
|
|
59
|
-
*/
|
|
60
|
-
interface MemoryStoreEnv {
|
|
61
|
-
}
|
|
62
|
-
type VectorBackend = "sqlite-vec" | "chroma";
|
|
63
|
-
interface MemoryStoreVectorConfig {
|
|
64
|
-
/** Active backend selector. Defaults to env-based detection. */
|
|
65
|
-
backend?: VectorBackend;
|
|
66
|
-
/** SQLite-vec options (used when backend === "sqlite-vec"). */
|
|
67
|
-
sqliteVec?: {
|
|
68
|
-
dbPath?: string;
|
|
69
|
-
insightsCollection?: string;
|
|
70
|
-
};
|
|
71
|
-
/** Chroma options (used when backend === "chroma"). */
|
|
72
|
-
chroma?: {
|
|
73
|
-
url?: string;
|
|
74
|
-
rawMessagesCollection?: string;
|
|
75
|
-
insightsCollection?: string;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
type EmbedQueryFn = (input: {
|
|
79
|
-
userId: string;
|
|
80
|
-
query: string;
|
|
81
|
-
authToken?: string;
|
|
82
|
-
}) => Promise<number[]>;
|
|
83
|
-
interface UnifiedSearchKnowledgeResult {
|
|
84
|
-
chunkId: string;
|
|
85
|
-
documentId: string;
|
|
86
|
-
documentName: string;
|
|
87
|
-
content: string;
|
|
88
|
-
similarity: number;
|
|
89
|
-
chunkIndex: number;
|
|
90
|
-
}
|
|
91
|
-
interface UnifiedSearchInsightsResult {
|
|
92
|
-
id: string;
|
|
93
|
-
content: string;
|
|
94
|
-
similarity: number;
|
|
95
|
-
metadata: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
interface UnifiedSearchDeps {
|
|
98
|
-
/** Embed a query string using the active user's provider. */
|
|
99
|
-
embedQuery?: EmbedQueryFn;
|
|
100
|
-
/**
|
|
101
|
-
* Postgres-side ANN search over `raw_messages`. Used when chroma is
|
|
102
|
-
* not enabled but the host has a postgres-backed manager. If both
|
|
103
|
-
* chroma and this are absent, the memory source will return empty
|
|
104
|
-
* (with a warning) in standalone mode.
|
|
105
|
-
*/
|
|
106
|
-
searchRawMessagesAnn?: (input: {
|
|
107
|
-
userId: string;
|
|
108
|
-
queryEmbedding: number[];
|
|
109
|
-
limit: number;
|
|
110
|
-
threshold: number;
|
|
111
|
-
botId?: string;
|
|
112
|
-
}) => Promise<Array<{
|
|
113
|
-
id: string;
|
|
114
|
-
content: string;
|
|
115
|
-
similarity: number;
|
|
116
|
-
metadata: Record<string, unknown>;
|
|
117
|
-
}>>;
|
|
118
|
-
/** RAG over uploaded knowledge documents. Returns a list of chunk hits. */
|
|
119
|
-
searchKnowledge?: (input: {
|
|
120
|
-
userId: string;
|
|
121
|
-
query: string;
|
|
122
|
-
options: {
|
|
123
|
-
limit: number;
|
|
124
|
-
threshold: number;
|
|
125
|
-
documentIds?: string[];
|
|
126
|
-
};
|
|
127
|
-
authToken?: string;
|
|
128
|
-
}) => Promise<UnifiedSearchKnowledgeResult[]>;
|
|
129
|
-
/** Semantic search over extracted insights. */
|
|
130
|
-
searchInsights?: (input: {
|
|
131
|
-
userId: string;
|
|
132
|
-
query: string;
|
|
133
|
-
limit: number;
|
|
134
|
-
threshold: number;
|
|
135
|
-
botIds?: string[];
|
|
136
|
-
includeArchived?: boolean;
|
|
137
|
-
authToken?: string;
|
|
138
|
-
}) => Promise<UnifiedSearchInsightsResult[]>;
|
|
139
|
-
/**
|
|
140
|
-
* Optional BM25 (lexical) sub-query for the memory source. Mirrors the
|
|
141
|
-
* `searchRawMessagesAnn` shape but operates on FTS5 keywords instead of
|
|
142
|
-
* dense embeddings. When absent, the unified pipeline skips the lexical
|
|
143
|
-
* path and emits a `memory_lexical_search_not_configured` warning.
|
|
144
|
-
*/
|
|
145
|
-
searchRawMessagesLexical?: (input: {
|
|
146
|
-
userId: string;
|
|
147
|
-
keywords: string[];
|
|
148
|
-
limit: number;
|
|
149
|
-
botId?: string;
|
|
150
|
-
}) => Promise<Array<{
|
|
151
|
-
id: string;
|
|
152
|
-
content: string;
|
|
153
|
-
similarity: number;
|
|
154
|
-
metadata: Record<string, unknown>;
|
|
155
|
-
}>>;
|
|
156
|
-
}
|
|
157
|
-
interface MemoryStoreConfig {
|
|
158
|
-
/**
|
|
159
|
-
* Database handle factory. Required for the Postgres backend
|
|
160
|
-
* (`OPENCONTEXT_MEMORY_STORE_BACKEND=postgres`).
|
|
161
|
-
*/
|
|
162
|
-
db?: MemoryStoreDb;
|
|
163
|
-
/**
|
|
164
|
-
* Custom SQLite database file path for the default SQLite backend.
|
|
165
|
-
*
|
|
166
|
-
* If provided, this takes precedence over the `MEMORY_STORE_DB_PATH`
|
|
167
|
-
* environment variable and the default `~/.opencontext/memory/store.db`.
|
|
168
|
-
*
|
|
169
|
-
* For backward compatibility with early tutorials, `db.path` is also
|
|
170
|
-
* honoured when `db` is supplied as `{ type, path }`.
|
|
171
|
-
*/
|
|
172
|
-
dbPath?: string;
|
|
173
|
-
/** Environment helpers. Defaults to a process.env-only stub if omitted. */
|
|
174
|
-
env?: MemoryStoreEnv;
|
|
175
|
-
/** Vector backend config. Defaults to env-based detection. */
|
|
176
|
-
vector?: MemoryStoreVectorConfig;
|
|
177
|
-
/** Optional cross-source search providers. */
|
|
178
|
-
unified?: UnifiedSearchDeps;
|
|
179
|
-
/** Optional logger. Defaults to console. */
|
|
180
|
-
logger?: Pick<Console, "log" | "warn" | "error">;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export type { EmbedQueryFn as E, MemoryStoreConfig as M, UnifiedSearchInsightsResult as U, VectorBackend as V, MemoryStoreDb as a, MemoryStoreEnv as b, UnifiedSearchKnowledgeResult as c, UnifiedSearchDeps as d };
|